diff --git a/.changeset/busy-islands-fail.md b/.changeset/busy-islands-fail.md new file mode 100644 index 00000000000..dd1030b2ad3 --- /dev/null +++ b/.changeset/busy-islands-fail.md @@ -0,0 +1,5 @@ +--- +'@primer/react': minor +--- + +ActionBar: Adds `ActionBar.Group` sub component diff --git a/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-WithGroups-dark-colorblind-linux.png b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-WithGroups-dark-colorblind-linux.png new file mode 100644 index 00000000000..37bfca67378 Binary files /dev/null and b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-WithGroups-dark-colorblind-linux.png differ diff --git a/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-WithGroups-dark-dimmed-linux.png b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-WithGroups-dark-dimmed-linux.png new file mode 100644 index 00000000000..d2b60a8d216 Binary files /dev/null and b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-WithGroups-dark-dimmed-linux.png differ diff --git a/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-WithGroups-dark-high-contrast-linux.png b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-WithGroups-dark-high-contrast-linux.png new file mode 100644 index 00000000000..2b9ffa9ebaf Binary files /dev/null and b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-WithGroups-dark-high-contrast-linux.png differ diff --git a/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-WithGroups-dark-linux.png b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-WithGroups-dark-linux.png new file mode 100644 index 00000000000..37bfca67378 Binary files /dev/null and b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-WithGroups-dark-linux.png differ diff --git a/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-WithGroups-dark-tritanopia-linux.png b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-WithGroups-dark-tritanopia-linux.png new file mode 100644 index 00000000000..37bfca67378 Binary files /dev/null and b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-WithGroups-dark-tritanopia-linux.png differ diff --git a/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-WithGroups-light-colorblind-linux.png b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-WithGroups-light-colorblind-linux.png new file mode 100644 index 00000000000..2c285b197f2 Binary files /dev/null and b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-WithGroups-light-colorblind-linux.png differ diff --git a/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-WithGroups-light-high-contrast-linux.png b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-WithGroups-light-high-contrast-linux.png new file mode 100644 index 00000000000..dd803a03096 Binary files /dev/null and b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-WithGroups-light-high-contrast-linux.png differ diff --git a/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-WithGroups-light-linux.png b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-WithGroups-light-linux.png new file mode 100644 index 00000000000..2c285b197f2 Binary files /dev/null and b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-WithGroups-light-linux.png differ diff --git a/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-WithGroups-light-tritanopia-linux.png b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-WithGroups-light-tritanopia-linux.png new file mode 100644 index 00000000000..2c285b197f2 Binary files /dev/null and b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-WithGroups-light-tritanopia-linux.png differ diff --git a/e2e/components/drafts/ActionBar.test.ts b/e2e/components/drafts/ActionBar.test.ts index 0790444d4ae..c39e4d1a9d0 100644 --- a/e2e/components/drafts/ActionBar.test.ts +++ b/e2e/components/drafts/ActionBar.test.ts @@ -20,6 +20,22 @@ test.describe('ActionBar', () => { } }) + test.describe('Groups', () => { + for (const theme of themes) { + test.describe(theme, () => { + test('default @vrt', async ({page}) => { + await visit(page, { + id: 'experimental-components-actionbar-examples--with-groups', + globals: { + colorScheme: theme, + }, + }) + expect(await page.screenshot()).toMatchSnapshot(`drafts.ActionBar.WithGroups.${theme}.png`) + }) + }) + } + }) + test.describe('ActionBar Interactions', () => { for (const theme of themes) { test.describe(theme, () => { diff --git a/packages/react/src/ActionBar/ActionBar.docs.json b/packages/react/src/ActionBar/ActionBar.docs.json index 79a9c68f9f6..1dc9e2db588 100644 --- a/packages/react/src/ActionBar/ActionBar.docs.json +++ b/packages/react/src/ActionBar/ActionBar.docs.json @@ -82,6 +82,16 @@ { "name": "ActionBar.Divider", "props": [] + }, + { + "name": "ActionBar.Group", + "props": [ + { + "name": "children", + "type": "React.ReactNode", + "defaultValue": "" + } + ] } ] } diff --git a/packages/react/src/ActionBar/ActionBar.examples.stories.tsx b/packages/react/src/ActionBar/ActionBar.examples.stories.tsx index d7c18e79123..ff4f652a64b 100644 --- a/packages/react/src/ActionBar/ActionBar.examples.stories.tsx +++ b/packages/react/src/ActionBar/ActionBar.examples.stories.tsx @@ -28,6 +28,30 @@ export default { title: 'Experimental/Components/ActionBar/Examples', } as Meta +export const WithGroups = () => ( + + + <> + + + + + + + + + + + + + + + + + + +) + export const TextLabels = () => ( diff --git a/packages/react/src/ActionBar/ActionBar.module.css b/packages/react/src/ActionBar/ActionBar.module.css index d795c7b57a8..b18403b5a8f 100644 --- a/packages/react/src/ActionBar/ActionBar.module.css +++ b/packages/react/src/ActionBar/ActionBar.module.css @@ -33,3 +33,8 @@ background: var(--borderColor-muted); } } + +.Group { + display: flex; + gap: inherit; +} diff --git a/packages/react/src/ActionBar/ActionBar.test.tsx b/packages/react/src/ActionBar/ActionBar.test.tsx index 21139a9cb8e..fba187d3f09 100644 --- a/packages/react/src/ActionBar/ActionBar.test.tsx +++ b/packages/react/src/ActionBar/ActionBar.test.tsx @@ -100,6 +100,32 @@ describe('ActionBar Registry System', () => { expect(buttons[2]).toHaveAccessibleName('Third') }) + it('should preserve group order with deep nesting', () => { + render( + +
+ + + +
+ + + +
+ + + +
+
, + ) + + const buttons = screen.getAllByRole('button') + expect(buttons).toHaveLength(3) + expect(buttons[0]).toHaveAccessibleName('First') + expect(buttons[1]).toHaveAccessibleName('Second') + expect(buttons[2]).toHaveAccessibleName('Third') + }) + it('should handle conditional rendering without breaking order', async () => { const ConditionalTest = () => { const [show, setShow] = useState([true, true, true]) @@ -108,7 +134,9 @@ describe('ActionBar Registry System', () => {
{show[0] && } - {show[1] && } + + {show[1] && } + {show[2] && }