Skip to content

Commit a1e5587

Browse files
authored
feat: add passive flag and alt to img (#309)
* feat: add passive flag and alt to img * fix: change defer to loading attribute for iframe * feat: add i18n for alt and title * feat: remove passive flag from EventListener * feat: add passive flag and alt to img * fix: change defer to loading attribute for iframe * feat: add i18n for alt and title * feat: remove passive flag from EventListener * feat: add passive flag and alt to img * fix: change defer to loading attribute for iframe * feat: add i18n for alt and title * feat: remove passive flag from EventListener * feat: add passive flag and alt to img * feat: add i18n for alt and title * feat: remove passive flag from EventListener
1 parent b5bf237 commit a1e5587

File tree

30 files changed

+123
-5
lines changed

30 files changed

+123
-5
lines changed

src/blocks/Security/Security.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {AnimateBlock, FullWidthBackground, HTML, ImageBase, Link, Media} from '.
44
import {Col, Grid, Row} from '../../grid';
55
import {SecurityBlockProps} from '../../models';
66
import {block} from '../../utils';
7+
import i18n from './i18n';
78

89
import './Security.scss';
910

@@ -26,7 +27,11 @@ export const SecurityBlock = (props: SecurityBlockProps) => {
2627
<Row className={b('points')}>
2728
{points.map(({text, link, img}, index) => (
2829
<Col key={index} className={b('point')} sizes={{sm: 4, all: 12}}>
29-
<ImageBase className={b('point-icon')} src={img} />
30+
<ImageBase
31+
className={b('point-icon')}
32+
src={img}
33+
alt={text || i18n('image-alt')}
34+
/>
3035
<HTML className={b('point-text')} block={true}>
3136
{text}
3237
</HTML>

src/blocks/Security/i18n/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"image-alt": "Point icon"
3+
}

src/blocks/Security/i18n/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import {registerKeyset} from '../../../utils/registerKeyset';
2+
3+
import en from './en.json';
4+
import ru from './ru.json';
5+
6+
const COMPONENT = 'SecurityBlock';
7+
8+
export default registerKeyset({en, ru}, COMPONENT);

src/blocks/Security/i18n/ru.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"image-alt": "Иконка"
3+
}

src/components/Button/Button.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {useMetrika} from '../../hooks/useMetrika';
88
import {Github} from '../../icons';
99
import {ButtonProps as ButtonParams, DefaultEventNames} from '../../models';
1010
import {block, setUrlTld} from '../../utils';
11-
import ImageBase from '../ImageBase/ImageBase';
11+
import i18n from './i18n';
1212
import {ICON_QA, OldButtonSize, OldButtonTheme, toCommonSize, toCommonView} from './utils';
1313

1414
import './Button.scss';
@@ -73,7 +73,9 @@ const Button = (props: ButtonProps) => {
7373
}
7474

7575
let icon;
76-
let image = img && <ImageBase className={b('image')} src={buttonImg.url} alt={buttonImg.alt} />;
76+
let image = img && (
77+
<img className={b('image')} src={buttonImg.url} alt={buttonImg.alt || i18n('image-alt')} />
78+
);
7779

7880
if (theme === 'github') {
7981
icon = <Icon className={b('icon')} data={Github} size={24} qa={ICON_QA} />;

src/components/Button/i18n/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"image-alt": "Button image"
3+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import {registerKeyset} from '../../../utils/registerKeyset';
2+
3+
import en from './en.json';
4+
import ru from './ru.json';
5+
6+
const COMPONENT = 'Button';
7+
8+
export default registerKeyset({en, ru}, COMPONENT);

src/components/Button/i18n/ru.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"image-alt": "Иконка кнопки"
3+
}

src/components/Control/Control.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {Icon} from '@gravity-ui/uikit';
44
import {SVGIconData} from '@gravity-ui/uikit/build/esm/components/Icon/types';
55

66
import {block} from '../../utils';
7+
import i18n from './i18n';
78

89
import './Control.scss';
910

@@ -33,6 +34,7 @@ const Control = (props: ControlProps) => {
3334
return (
3435
<button
3536
type="button"
37+
aria-label={i18n('aria-label')}
3638
className={b({size, theme, disabled}, className)}
3739
onClick={disabled ? undefined : onClick}
3840
disabled={disabled}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"aria-label": "Button label"
3+
}

0 commit comments

Comments
 (0)