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

Conversation

sungik-choi
Copy link
Contributor

@sungik-choi sungik-choi commented Apr 26, 2023

Self Checklist

  • I wrote a PR title in English.
  • I added an appropriate label to the PR.
  • I wrote a commit message in English.
  • I wrote a commit message according to the Conventional Commits specification.
  • I added the appropriate changeset for the changes.
  • [Component] I wrote a unit test about the implementation.
  • [Component] I wrote a storybook document about the implementation.
  • [Component] I tested the implementation in various browsers.
    • Windows: Chrome, Edge, (Optional) Firefox
    • macOS: Chrome, Edge, Safari, (Optional) Firefox
  • [New Component] I added my username to the correct directory in the CODEOWNERS file.

Related Issue

Fixes #369

Summary

아이콘의 접근성을 개선합니다.

Details

  • 시각적인 변화는 없습니다.
  • 아이콘 내부적으로 visually hidden 된 텍스트를 추가로 렌더합니다. 따라서 Icon 의 루트는 svg가 아니라 React.Fragment가 됩니다.
  • 가장 좋은 방법은 링크에서처럼 용처별로 구분하여 적절한 처리를 가하는 것이지만, 현재 컴포넌트 구조(예 - 버튼이 아이콘만 있는 버튼인지 아닌지 구분이 불가능)에선 적용이 어렵다고 판단했습니다. radix ui의 Accessible Icon을 사용하여 내부에 스크린 리더로만 접근 가능한 라벨을 추가하는 방향으로 우선 통일합니다.

Breaking change or not (Yes/No)

No

References

@sungik-choi sungik-choi added the a11y Issue or PR related to accessibility label Apr 26, 2023
@sungik-choi sungik-choi self-assigned this Apr 26, 2023
@changeset-bot
Copy link

changeset-bot bot commented Apr 26, 2023

🦋 Changeset detected

Latest commit: 9e8bde6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@channel.io/bezier-react Minor
bezier-figma-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR


const pipe = (...fn: Function[]) => (arg: any) => fn.reduce((acc, cur) => cur(acc), arg)

export function createIconLabel(svgName: string): string {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

svgr에 의해 생성되는 컴포넌트명을 적절한 라벨로 변경하는 함수.

Most icons or icon systems come with no accessibility built-in. For example, the same visual cross icon may in fact mean "close" or "delete". This component lets you give meaning to icons used throughout your app.
https://www.radix-ui.com/docs/primitives/utilities/accessible-icon#accessibility

아이콘의 형태와 다르게 실제 의미가 무엇인지를 라벨로 제공하면 더욱 좋지만, 현재 별도의 아이콘 메타데이터를 제공하고 있지 않아 절충안으로 아이콘 이름을 라벨로 지정했습니다.

@github-actions
Copy link
Contributor

github-actions bot commented Apr 26, 2023

Chromatic Report

🚀 Congratulations! Your build was successful!

@codecov
Copy link

codecov bot commented Apr 26, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.02 🎉

Comparison is base (06d2a5f) 78.18% compared to head (9e8bde6) 78.21%.

Additional details and impacted files
@@             Coverage Diff             @@
##           next-v1    #1310      +/-   ##
===========================================
+ Coverage    78.18%   78.21%   +0.02%     
===========================================
  Files          294      293       -1     
  Lines         3796     3801       +5     
  Branches       838      838              
===========================================
+ Hits          2968     2973       +5     
  Misses         545      545              
  Partials       283      283              
Impacted Files Coverage Δ
...ges/bezier-react/src/components/Icon/Icon.types.ts 100.00% <ø> (ø)
packages/bezier-react/src/components/Icon/Icon.tsx 100.00% <100.00%> (ø)

... and 4 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@@ -223,7 +223,7 @@ describe('Tabs', () => {
const { getByRole } = renderTabs()
const tabItem1 = getByRole('tab', { name: TAB1 })
const tabItem2 = getByRole('tab', { name: TAB2 })
const tabAction = getByRole('link', { name: ACTION1 })
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

안좋은 케이스. ${ACTION1} Open In New Window 같은 방식으로 라벨이 만들어짐. 이런 경우는 아이콘이 장식 요소로 사용되기때문에 그냥 hidden되는 편이 낫습니다.

@sungik-choi sungik-choi merged commit b37f197 into channel-io:next-v1 Apr 27, 2023
@sungik-choi sungik-choi deleted the enhance/icon-a11y branch April 27, 2023 08:49
@sungik-choi sungik-choi mentioned this pull request May 18, 2023
9 tasks
@yangwooseong yangwooseong mentioned this pull request May 8, 2024
6 tasks
yangwooseong added a commit that referenced this pull request May 13, 2024
<!--
  How to write a good PR title:
- Follow [the Conventional Commits
specification](https://www.conventionalcommits.org/en/v1.0.0/).
  - Give as much context as necessary and as little as possible
  - Prefix it with [WIP] while it’s a work in progress
-->

## Self Checklist

- [x] I wrote a PR title in **English** and added an appropriate
**label** to the PR.
- [x] I wrote the commit message in **English** and to follow [**the
Conventional Commits
specification**](https://www.conventionalcommits.org/en/v1.0.0/).
- [x] I [added the
**changeset**](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md)
about the changes that needed to be released. (or didn't have to)
- [x] I wrote or updated **documentation** related to the changes. (or
didn't have to)
- [x] I wrote or updated **tests** related to the changes. (or didn't
have to)
- [x] I tested the changes in various browsers. (or didn't have to)
  - Windows: Chrome, Edge, (Optional) Firefox
  - macOS: Chrome, Edge, Safari, (Optional) Firefox

## Related Issue

<!-- Please link to issue if one exists -->

<!-- Fixes #0000 -->

- Fixes #2199

## Summary

<!-- Please brief explanation of the changes made -->

- 아이콘만 있는 `AlphaIconButton` 컴포넌트를 구현합니다. 

## Details

<!-- Please elaborate description of the changes -->

- 스타일은 버튼 컴포넌트에서 거의 그대로 가져왔습니다.#2180 까지는 복붙으로 구현한 후에 후속작업에서 버튼 컴포넌트의
스타일을 background-color, color, hover effect 별로 믹스인으로 분리하고 이를 재사용하는 형태로
리팩토링할 예정입니다.
- 아이콘만 있는 경우 접근성을 위해 적절히 라벨을 주는 것이 필요합니다. 이를 위해서 (i) hidden text 를 주는 방법
(ii) aria-label 을 주는 방법 등이 있는데, hidden text 를 주면 문제가 발생한 경우가 있기도 하고
aria-label 을 주는 것이 간편해보여서 이 방법으로 하려고 합니다.
([#](#1310)). 다만
aria-label을 required로 해야할 지는 의문입니다. 다른 라이브러리를 찾아보니 라이브러리마다 다른 부분이기도 하고,
베지어에서는 접근성 관련 속성을 required로 한 적이 없어서 optional이 좋겠다는 생각입니다.
- `IconButtonStyleVariant`, `IconButtonColor` 타입을 export 할 필요는 없는 것 같아서
하지 않았습니다. 이전에는 enum으로 사용하고 있어서 export 해야만 했는데 현재는 그렇지 않아서
`IconButtonProps['variant']` 처럼 사용하는 것이 가능합니다. 이거는 V2 컴포넌트 전반적으로 컨벤션이
맞춰지면 좋을 것 같아서 의견 부탁드립니다. (@sungik-choi)

### Breaking change? (Yes/No)

<!-- If Yes, please describe the impact and migration path for users -->

- No

## References

<!-- Please list any other resources or points the reviewer should be
aware of -->

- https://www.sarasoueidan.com/blog/accessible-icon-buttons/
- https://v2.chakra-ui.com/docs/components/icon-button#usage
- https://primer.style/components/icon-button/react/alpha#iconbutton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a11y Issue or PR related to accessibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement Icon's accessibility
2 participants