Skip to content

Commit

Permalink
Merge branch 'main' into revert-4464-revert-3582
Browse files Browse the repository at this point in the history
  • Loading branch information
mperrotti committed Jul 25, 2024
2 parents 691bb7a + 8574027 commit 85c68a6
Show file tree
Hide file tree
Showing 17 changed files with 124 additions and 34 deletions.
5 changes: 5 additions & 0 deletions .changeset/curvy-shrimps-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

Prevents inactive indicator icon/tooltip from appearing in ActionMenu items
5 changes: 5 additions & 0 deletions .changeset/wild-actors-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": patch
---

StateLabel: Differentiate issue and pull request labels for screen readers
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions packages/react/src/ActionList/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ export const Item = React.forwardRef<HTMLLIElement, ActionListItemProps>(
<ItemWrapper {...wrapperProps}>
<Selection selected={selected} />
<VisualOrIndicator
inactiveText={inactiveText}
inactiveText={showInactiveIndicator ? inactiveText : undefined}
itemHasLeadingVisual={Boolean(slots.leadingVisual)}
labelId={labelId}
loading={loading}
Expand Down Expand Up @@ -386,7 +386,7 @@ export const Item = React.forwardRef<HTMLLIElement, ActionListItemProps>(
{slots.inlineDescription}
</ConditionalWrapper>
<VisualOrIndicator
inactiveText={inactiveText}
inactiveText={showInactiveIndicator ? inactiveText : undefined}
itemHasLeadingVisual={Boolean(slots.leadingVisual)}
labelId={labelId}
loading={loading}
Expand Down
86 changes: 63 additions & 23 deletions packages/react/src/Avatar/Avatar.features.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,76 @@ export default {
component: Avatar,
} as Meta<typeof Avatar>

export const Square = () => <Avatar square src="https://github.com/avatars/primer" />
export const Square = () => <Avatar square alt="primer" src="https://github.com/avatars/primer" />

export const Size = () => (
<div>
<Avatar size={4} src="https://github.com/avatars/u/92997159?v=4" />
<Avatar size={8} src="https://github.com/avatars/u/92997159?v=4" />
<Avatar size={12} src="https://github.com/avatars/u/92997159?v=4" />
<Avatar size={16} src="https://github.com/avatars/u/92997159?v=4" />
<Avatar size={20} src="https://github.com/avatars/u/92997159?v=4" />
<Avatar size={24} src="https://github.com/avatars/u/92997159?v=4" />
<Avatar size={28} src="https://github.com/avatars/u/92997159?v=4" />
<Avatar size={32} src="https://github.com/avatars/u/92997159?v=4" />
<Avatar size={40} src="https://github.com/avatars/u/92997159?v=4" />
<Avatar size={48} src="https://github.com/avatars/u/92997159?v=4" />
<Avatar size={56} src="https://github.com/avatars/u/92997159?v=4" />
<Avatar size={64} src="https://github.com/avatars/u/92997159?v=4" />
<Avatar size={4} alt="mona" src="https://github.com/avatars/u/92997159?v=4" />
<Avatar size={8} alt="mona" src="https://github.com/avatars/u/92997159?v=4" />
<Avatar size={12} alt="mona" src="https://github.com/avatars/u/92997159?v=4" />
<Avatar size={16} alt="mona" src="https://github.com/avatars/u/92997159?v=4" />
<Avatar size={20} alt="mona" src="https://github.com/avatars/u/92997159?v=4" />
<Avatar size={24} alt="mona" src="https://github.com/avatars/u/92997159?v=4" />
<Avatar size={28} alt="mona" src="https://github.com/avatars/u/92997159?v=4" />
<Avatar size={32} alt="mona" src="https://github.com/avatars/u/92997159?v=4" />
<Avatar size={40} alt="mona" src="https://github.com/avatars/u/92997159?v=4" />
<Avatar size={48} alt="mona" src="https://github.com/avatars/u/92997159?v=4" />
<Avatar size={56} alt="mona" src="https://github.com/avatars/u/92997159?v=4" />
<Avatar size={64} alt="mona" src="https://github.com/avatars/u/92997159?v=4" />
</div>
)

export const SizeResponsive = () => (
<div>
<Avatar size={{narrow: 4, regular: 8, wide: 12}} src="https://github.com/avatars/u/92997159?v=4" />
<Avatar size={{narrow: 8, regular: 12, wide: 16}} src="https://github.com/avatars/u/92997159?v=4" />
<Avatar size={{narrow: 12, regular: 16, wide: 20}} src="https://github.com/avatars/u/92997159?v=4" />
<Avatar size={{narrow: 16, regular: 20, wide: 24}} src="https://github.com/avatars/u/92997159?v=4" />
<Avatar size={{narrow: 20, regular: 24, wide: 28}} src="https://github.com/avatars/u/92997159?v=4" />
<Avatar size={{narrow: 24, regular: 28, wide: 32}} src="https://github.com/avatars/u/92997159?v=4" />
<Avatar size={{narrow: 28, regular: 32, wide: 40}} src="https://github.com/avatars/u/92997159?v=4" />
<Avatar size={{narrow: 32, regular: 40, wide: 48}} src="https://github.com/avatars/u/92997159?v=4" />
<Avatar size={{narrow: 40, regular: 48, wide: 56}} src="https://github.com/avatars/u/92997159?v=4" />
<Avatar size={{narrow: 48, regular: 56, wide: 64}} src="https://github.com/avatars/u/92997159?v=4" />
<Avatar
size={{narrow: 4, regular: 8, wide: 12}}
alt="mona"
src="https://github.com/avatars/u/92997159?v=4"
/>
<Avatar
size={{narrow: 8, regular: 12, wide: 16}}
alt="mona"
src="https://github.com/avatars/u/92997159?v=4"
/>
<Avatar
size={{narrow: 12, regular: 16, wide: 20}}
alt="mona"
src="https://github.com/avatars/u/92997159?v=4"
/>
<Avatar
size={{narrow: 16, regular: 20, wide: 24}}
alt="mona"
src="https://github.com/avatars/u/92997159?v=4"
/>
<Avatar
size={{narrow: 20, regular: 24, wide: 28}}
alt="mona"
src="https://github.com/avatars/u/92997159?v=4"
/>
<Avatar
size={{narrow: 24, regular: 28, wide: 32}}
alt="mona"
src="https://github.com/avatars/u/92997159?v=4"
/>
<Avatar
size={{narrow: 28, regular: 32, wide: 40}}
alt="mona"
src="https://github.com/avatars/u/92997159?v=4"
/>
<Avatar
size={{narrow: 32, regular: 40, wide: 48}}
alt="mona"
src="https://github.com/avatars/u/92997159?v=4"
/>
<Avatar
size={{narrow: 40, regular: 48, wide: 56}}
alt="mona"
src="https://github.com/avatars/u/92997159?v=4"
/>
<Avatar
size={{narrow: 48, regular: 56, wide: 64}}
alt="mona"
src="https://github.com/avatars/u/92997159?v=4"
/>
</div>
)
1 change: 1 addition & 0 deletions packages/react/src/Avatar/Avatar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const Playground: StoryFn<Args> = args => {
size={parseSizeFromArgs(args)}
square={args.square}
src="https://github.com/avatars/u/92997159?v=4"
alt="mona"
/>
)
}
Expand Down
23 changes: 22 additions & 1 deletion packages/react/src/StateLabel/StateLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ const octiconMap = {
unavailable: AlertIcon,
}

const labelMap: Record<keyof typeof octiconMap, 'Issue' | 'Issue, not planned' | 'Pull request' | ''> = {
issueOpened: 'Issue',
pullOpened: 'Pull request',
issueClosed: 'Issue',
issueClosedNotPlanned: 'Issue, not planned',
pullClosed: 'Pull request',
pullMerged: 'Pull request',
draft: 'Pull request',
issueDraft: 'Issue',
pullQueued: 'Pull request',
unavailable: '',
}

const colorVariants = variant({
prop: 'status',
variants: {
Expand Down Expand Up @@ -120,7 +133,15 @@ function StateLabel({children, status, variant: variantProp = 'normal', ...rest}
return (
<StateLabelBase {...rest} variant={variantProp} status={status}>
{/* eslint-disable-next-line @typescript-eslint/no-unnecessary-condition */}
{status && <Octicon {...octiconProps} icon={octiconMap[status] || QuestionIcon} sx={{mr: 1}} />}
{status && (
<Octicon
{...octiconProps}
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
icon={octiconMap[status] || QuestionIcon}
aria-label={labelMap[status]}
sx={{mr: 1}}
/>
)}
{children}
</StateLabelBase>
)
Expand Down
10 changes: 10 additions & 0 deletions packages/react/src/StateLabel/__tests__/StateLabel.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,14 @@ describe('StateLabel', () => {
it('renders children', () => {
expect(render(<StateLabel status="issueOpened">hi</StateLabel>)).toMatchSnapshot()
})

it('adds label to icon', () => {
const screen1 = HTMLRender(<StateLabel status="issueOpened">Open</StateLabel>)
expect(screen1.getByLabelText('Issue')).toBeInTheDocument() // svg
expect(screen1.getByText('Open')).toBeInTheDocument() // text

const screen2 = HTMLRender(<StateLabel status="pullMerged">Merged</StateLabel>)
expect(screen2.getByLabelText('Pull request')).toBeInTheDocument() // svg
expect(screen2.getByText('Merged')).toBeInTheDocument() // text
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ exports[`StateLabel renders children 1`] = `
className="c0"
>
<svg
aria-hidden="true"
aria-label="Issue"
className="c1"
fill="currentColor"
focusable="false"
height={16}
role="img"
style={
{
"display": "inline-block",
Expand Down Expand Up @@ -91,11 +92,12 @@ exports[`StateLabel respects the status prop 1`] = `
className="c0"
>
<svg
aria-hidden="true"
aria-label="Issue"
className="c1"
fill="currentColor"
focusable="false"
height={16}
role="img"
style={
{
"display": "inline-block",
Expand Down Expand Up @@ -149,11 +151,12 @@ exports[`StateLabel respects the status prop 2`] = `
className="c0"
>
<svg
aria-hidden="true"
aria-label="Issue"
className="c1"
fill="currentColor"
focusable="false"
height={16}
role="img"
style={
{
"display": "inline-block",
Expand Down Expand Up @@ -207,11 +210,12 @@ exports[`StateLabel respects the status prop 3`] = `
className="c0"
>
<svg
aria-hidden="true"
aria-label="Issue, not planned"
className="c1"
fill="currentColor"
focusable="false"
height={16}
role="img"
style={
{
"display": "inline-block",
Expand Down Expand Up @@ -262,11 +266,12 @@ exports[`StateLabel respects the status prop 4`] = `
className="c0"
>
<svg
aria-hidden="true"
aria-label="Pull request"
className="c1"
fill="currentColor"
focusable="false"
height={16}
role="img"
style={
{
"display": "inline-block",
Expand Down Expand Up @@ -317,11 +322,12 @@ exports[`StateLabel respects the status prop 5`] = `
className="c0"
>
<svg
aria-hidden="true"
aria-label="Pull request"
className="c1"
fill="currentColor"
focusable="false"
height={16}
role="img"
style={
{
"display": "inline-block",
Expand Down Expand Up @@ -372,11 +378,12 @@ exports[`StateLabel respects the variant prop 1`] = `
className="c0"
>
<svg
aria-hidden="true"
aria-label="Issue"
className="c1"
fill="currentColor"
focusable="false"
height={16}
role="img"
style={
{
"display": "inline-block",
Expand Down Expand Up @@ -430,11 +437,12 @@ exports[`StateLabel respects the variant prop 2`] = `
className="c0"
>
<svg
aria-hidden="true"
aria-label="Issue"
className="c1"
fill="currentColor"
focusable="false"
height={16}
role="img"
style={
{
"display": "inline-block",
Expand Down

0 comments on commit 85c68a6

Please sign in to comment.