-
Notifications
You must be signed in to change notification settings - Fork 614
Octicon remediation: aria-label #4811
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5a7678d
correct aria-label
siddharthkp 81dd29e
fix playground for Octicon and CircleOcticon
siddharthkp 3432a9b
CicleOcticon: move aria-label to the icon, not the container
siddharthkp 6a9cbd4
clean up aria-label in playground
siddharthkp 43067f7
clean up meta for CircleBadge
siddharthkp eb8b644
CircleBadge.Icon story: add aria-label in playground
siddharthkp 98b6fed
Create cool-lobsters-nail.md
siddharthkp ce8073b
add aria-label to circle badge default story
siddharthkp a395b0f
add aria-label to CircleOcticon default story
siddharthkp 83fce5d
Merge branch 'main' into octicon-remediation-1
siddharthkp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@primer/react": patch | ||
--- | ||
|
||
Octicon: Add aria-label to the Icon instead of it's container |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 25 additions & 30 deletions
55
packages/react/src/CircleOcticon/CircleOcticon.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,54 @@ | ||
import React from 'react' | ||
import type {Meta, StoryFn} from '@storybook/react' | ||
import CircleOcticon from './CircleOcticon' | ||
import type {CircleOcticonProps} from './CircleOcticon' | ||
import {CheckIcon} from '@primer/octicons-react' | ||
// eslint-disable-next-line import/no-namespace | ||
import * as Icons from '@primer/octicons-react' | ||
|
||
export default { | ||
const meta: Meta<typeof CircleOcticon> = { | ||
title: 'Components/CircleOcticon', | ||
component: CircleOcticon, | ||
} as Meta<typeof CircleOcticon> | ||
} | ||
export default meta | ||
|
||
export const Default = () => ( | ||
<CircleOcticon icon={CheckIcon} size={32} sx={{backgroundColor: 'success.emphasis', color: 'fg.onEmphasis'}} /> | ||
<CircleOcticon | ||
icon={CheckIcon} | ||
size={32} | ||
sx={{backgroundColor: 'success.emphasis', color: 'fg.onEmphasis'}} | ||
aria-label="Changes approved" | ||
/> | ||
) | ||
|
||
export const Playground: StoryFn<typeof CircleOcticon> = args => <CircleOcticon {...args} /> | ||
type PlaygroundTypes = Omit<CircleOcticonProps, 'icon'> & {icon: keyof typeof Icons} | ||
export const Playground: StoryFn<PlaygroundTypes> = ({icon: iconName, 'aria-label': ariaLabel, ...args}) => ( | ||
<CircleOcticon icon={Icons[iconName]} aria-label={ariaLabel ? ariaLabel : undefined} {...args} /> | ||
) | ||
|
||
Playground.args = { | ||
icon: CheckIcon, | ||
size: 32, | ||
icon: 'CheckIcon', | ||
'aria-label': undefined, | ||
sx: {backgroundColor: 'success.emphasis', color: 'fg.onEmphasis'}, | ||
} | ||
|
||
Playground.argTypes = { | ||
icon: { | ||
controls: false, | ||
table: { | ||
disable: true, | ||
}, | ||
}, | ||
size: { | ||
controls: { | ||
type: 'number', | ||
}, | ||
}, | ||
sx: { | ||
controls: false, | ||
table: { | ||
disable: true, | ||
}, | ||
}, | ||
as: { | ||
controls: false, | ||
table: { | ||
disable: true, | ||
icon: { | ||
control: { | ||
type: 'select', | ||
}, | ||
options: Object.keys(Icons), | ||
}, | ||
ref: { | ||
controls: false, | ||
table: { | ||
disable: true, | ||
}, | ||
'aria-label': { | ||
type: 'string', | ||
}, | ||
theme: { | ||
sx: { | ||
controls: false, | ||
table: { | ||
disable: true, | ||
}, | ||
}, | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ export type CircleOcticonProps = { | |
} & BoxProps | ||
|
||
function CircleOcticon(props: CircleOcticonProps) { | ||
const {size = 32, as, icon: IconComponent, bg, ...rest} = props | ||
const {size = 32, as, icon: IconComponent, bg, 'aria-label': ariaLabel, ...rest} = props | ||
return ( | ||
<Box | ||
as={as} | ||
|
@@ -23,7 +23,7 @@ function CircleOcticon(props: CircleOcticonProps) { | |
borderColor="border.default" | ||
> | ||
<Box display="flex" as={as} size={size} {...rest} alignItems="center" justifyContent="center"> | ||
<IconComponent size={size} /> | ||
<IconComponent size={size} aria-label={ariaLabel} /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note for reviewer: Moved aria-label from the container to the icon component |
||
</Box> | ||
</Box> | ||
) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.