Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance accessibility of icons #1310

Merged
merged 14 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions packages/bezier-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
},
"dependencies": {
"@babel/runtime": "^7.12.13",
"@radix-ui/react-accessible-icon": "^1.0.2",
"@radix-ui/react-checkbox": "^1.0.3",
"@radix-ui/react-separator": "^1.0.0",
"@radix-ui/react-slider": "^1.0.0",
Expand Down
19 changes: 15 additions & 4 deletions packages/bezier-react/scripts/icon-template.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
function iconTemplate({ imports, componentName, props, jsx }, { tpl }) {
function iconTemplate({ imports, componentName, props, interfaces, jsx }, { tpl }) {
return tpl`
${imports}
import { createBezierIcon } from '../utils'

${interfaces}

import * as AccessibleIcon from '@radix-ui/react-accessible-icon';

import { createIconLabel, createBezierIcon } from '../utils'

const label = createIconLabel('${componentName}')

function ${componentName}(${props}) {
const Svg = ${jsx}

return (
${jsx}
<AccessibleIcon.Root label={label}>
{ Svg }
</AccessibleIcon.Root>
)
}

export default createBezierIcon(${componentName})
`
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,12 @@ exports[`AvatarGroup Ellipsis type - Icon Snapshot 1`] = `
class="c4"
>
<svg
aria-hidden="true"
class="c5"
color="bgtxt-absolute-white-dark"
data-testid="bezier-react-icon"
fill="none"
focusable="false"
foundation="[object Object]"
height="16"
marginbottom="0"
Expand All @@ -421,6 +423,11 @@ exports[`AvatarGroup Ellipsis type - Icon Snapshot 1`] = `
fill-rule="evenodd"
/>
</svg>
<span
style="position: absolute; border: 0px; width: 1px; height: 1px; padding: 0px; margin: -1px; overflow: hidden; clip: rect(0px, 0px, 0px, 0px); white-space: nowrap; word-wrap: normal;"
>
More
</span>
</div>
<div
class="c1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,12 @@ exports[`Select Test > Default Style > Snapshot > 1`] = `
</span>
</div>
<svg
aria-hidden="true"
class="c4"
color="txt-black-darker"
data-testid="bezier-react-icon"
fill="none"
focusable="false"
foundation="[object Object]"
height="16"
marginbottom="0"
Expand All @@ -149,6 +151,11 @@ exports[`Select Test > Default Style > Snapshot > 1`] = `
fill-rule="evenodd"
/>
</svg>
<span
style="position: absolute; border: 0px; width: 1px; height: 1px; padding: 0px; margin: -1px; overflow: hidden; clip: rect(0px, 0px, 0px, 0px); white-space: nowrap; word-wrap: normal;"
>
Chevron Down
</span>
</button>
</div>
`;
Expand Down Expand Up @@ -284,10 +291,12 @@ exports[`Select Test > rightContent > Snapshot > 1`] = `
</div>
</div>
<svg
aria-hidden="true"
class="c4"
color="txt-black-darker"
data-testid="bezier-react-icon"
fill="none"
focusable="false"
foundation="[object Object]"
height="16"
marginbottom="0"
Expand All @@ -305,6 +314,11 @@ exports[`Select Test > rightContent > Snapshot > 1`] = `
fill-rule="evenodd"
/>
</svg>
<span
style="position: absolute; border: 0px; width: 1px; height: 1px; padding: 0px; margin: -1px; overflow: hidden; clip: rect(0px, 0px, 0px, 0px); white-space: nowrap; word-wrap: normal;"
>
Chevron Down
</span>
</button>
</div>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ exports[`Help > Snapshot > 1`] = `
}

<svg
aria-hidden="true"
class="c0 "
color="txt-black-dark"
data-testid="bezier-react-help"
fill="none"
focusable="false"
foundation="[object Object]"
height="16"
marginbottom="0"
Expand Down
6 changes: 4 additions & 2 deletions packages/bezier-react/src/components/Icon/Icon.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ import { Text } from '~/src/components/Text'

import { Icon } from './Icon'
import mdx from './Icon.mdx'
import type IconProps from './Icon.types'
import { IconSize } from './Icon.types'
import {
type IconProps,
IconSize,
} from './Icon.types'
import icons, {
ArrowLeftIcon,
BookmarkFilledIcon,
Expand Down
2 changes: 1 addition & 1 deletion packages/bezier-react/src/components/Icon/Icon.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
ICON_TEST_ID,
Icon,
} from './Icon'
import type IconProps from './Icon.types'
import { type IconProps } from './Icon.types'
import { AllIcon } from './generated'

describe('Icon test >', () => {
Expand Down
6 changes: 4 additions & 2 deletions packages/bezier-react/src/components/Icon/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import React, {
memo,
} from 'react'

import type IconProps from './Icon.types'
import { IconSize } from './Icon.types'
import {
type IconProps,
IconSize,
} from './Icon.types'

import Styled from './Icon.styled'

Expand Down
2 changes: 1 addition & 1 deletion packages/bezier-react/src/components/Icon/Icon.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ interface IconOptions {
marginLeft?: number
}

export default interface IconProps extends
export interface IconProps extends
Omit<BezierComponentProps, 'as'>,
SizeProps<IconSize>,
ColorProps,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-restricted-imports */
import type IconProps from '../Icon.types'
import { type IconProps } from '../Icon.types'
import { type IconName } from '../generated'
/* eslint-enable no-restricted-imports */

Expand Down
7 changes: 5 additions & 2 deletions packages/bezier-react/src/components/Icon/generated/All.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions packages/bezier-react/src/components/Icon/generated/Api.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions packages/bezier-react/src/components/Icon/generated/Apple.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions packages/bezier-react/src/components/Icon/generated/Apps.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading