diff --git a/.changeset/seven-ears-know.md b/.changeset/seven-ears-know.md new file mode 100644 index 00000000000..0b130b45e38 --- /dev/null +++ b/.changeset/seven-ears-know.md @@ -0,0 +1,5 @@ +--- +'@primer/react': minor +--- + +Hidden: rename prop 'on' -> 'when' diff --git a/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-medium-dark-colorblind-linux.png b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-medium-dark-colorblind-linux.png new file mode 100644 index 00000000000..a3d97b9a42f Binary files /dev/null and b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-medium-dark-colorblind-linux.png differ diff --git a/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-medium-dark-dimmed-linux.png b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-medium-dark-dimmed-linux.png new file mode 100644 index 00000000000..15aa45e00eb Binary files /dev/null and b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-medium-dark-dimmed-linux.png differ diff --git a/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-medium-dark-high-contrast-linux.png b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-medium-dark-high-contrast-linux.png new file mode 100644 index 00000000000..f4c26b11a71 Binary files /dev/null and b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-medium-dark-high-contrast-linux.png differ diff --git a/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-medium-dark-linux.png b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-medium-dark-linux.png new file mode 100644 index 00000000000..a3d97b9a42f Binary files /dev/null and b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-medium-dark-linux.png differ diff --git a/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-medium-dark-tritanopia-linux.png b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-medium-dark-tritanopia-linux.png new file mode 100644 index 00000000000..a3d97b9a42f Binary files /dev/null and b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-medium-dark-tritanopia-linux.png differ diff --git a/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-medium-light-colorblind-linux.png b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-medium-light-colorblind-linux.png new file mode 100644 index 00000000000..7cecc35151c Binary files /dev/null and b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-medium-light-colorblind-linux.png differ diff --git a/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-medium-light-high-contrast-linux.png b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-medium-light-high-contrast-linux.png new file mode 100644 index 00000000000..2f53a562c7d Binary files /dev/null and b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-medium-light-high-contrast-linux.png differ diff --git a/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-medium-light-linux.png b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-medium-light-linux.png new file mode 100644 index 00000000000..7cecc35151c Binary files /dev/null and b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-medium-light-linux.png differ diff --git a/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-medium-light-tritanopia-linux.png b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-medium-light-tritanopia-linux.png new file mode 100644 index 00000000000..7cecc35151c Binary files /dev/null and b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-medium-light-tritanopia-linux.png differ diff --git a/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-narrow-dark-colorblind-linux.png b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-narrow-dark-colorblind-linux.png new file mode 100644 index 00000000000..0c18cbe9054 Binary files /dev/null and b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-narrow-dark-colorblind-linux.png differ diff --git a/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-narrow-dark-dimmed-linux.png b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-narrow-dark-dimmed-linux.png new file mode 100644 index 00000000000..1c5ec1373bb Binary files /dev/null and b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-narrow-dark-dimmed-linux.png differ diff --git a/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-narrow-dark-high-contrast-linux.png b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-narrow-dark-high-contrast-linux.png new file mode 100644 index 00000000000..a6ae22946f7 Binary files /dev/null and b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-narrow-dark-high-contrast-linux.png differ diff --git a/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-narrow-dark-linux.png b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-narrow-dark-linux.png new file mode 100644 index 00000000000..0c18cbe9054 Binary files /dev/null and b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-narrow-dark-linux.png differ diff --git a/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-narrow-dark-tritanopia-linux.png b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-narrow-dark-tritanopia-linux.png new file mode 100644 index 00000000000..0c18cbe9054 Binary files /dev/null and b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-narrow-dark-tritanopia-linux.png differ diff --git a/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-narrow-light-colorblind-linux.png b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-narrow-light-colorblind-linux.png new file mode 100644 index 00000000000..a11f89bd814 Binary files /dev/null and b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-narrow-light-colorblind-linux.png differ diff --git a/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-narrow-light-high-contrast-linux.png b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-narrow-light-high-contrast-linux.png new file mode 100644 index 00000000000..ef1a0d170d1 Binary files /dev/null and b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-narrow-light-high-contrast-linux.png differ diff --git a/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-narrow-light-linux.png b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-narrow-light-linux.png new file mode 100644 index 00000000000..a11f89bd814 Binary files /dev/null and b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-narrow-light-linux.png differ diff --git a/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-narrow-light-tritanopia-linux.png b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-narrow-light-tritanopia-linux.png new file mode 100644 index 00000000000..a11f89bd814 Binary files /dev/null and b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-narrow-light-tritanopia-linux.png differ diff --git a/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-wide-dark-colorblind-linux.png b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-wide-dark-colorblind-linux.png new file mode 100644 index 00000000000..b752096b903 Binary files /dev/null and b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-wide-dark-colorblind-linux.png differ diff --git a/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-wide-dark-dimmed-linux.png b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-wide-dark-dimmed-linux.png new file mode 100644 index 00000000000..a52285f0308 Binary files /dev/null and b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-wide-dark-dimmed-linux.png differ diff --git a/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-wide-dark-high-contrast-linux.png b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-wide-dark-high-contrast-linux.png new file mode 100644 index 00000000000..3477284b8ac Binary files /dev/null and b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-wide-dark-high-contrast-linux.png differ diff --git a/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-wide-dark-linux.png b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-wide-dark-linux.png new file mode 100644 index 00000000000..b752096b903 Binary files /dev/null and b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-wide-dark-linux.png differ diff --git a/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-wide-dark-tritanopia-linux.png b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-wide-dark-tritanopia-linux.png new file mode 100644 index 00000000000..b752096b903 Binary files /dev/null and b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-wide-dark-tritanopia-linux.png differ diff --git a/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-wide-light-colorblind-linux.png b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-wide-light-colorblind-linux.png new file mode 100644 index 00000000000..2b4fe4b4b98 Binary files /dev/null and b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-wide-light-colorblind-linux.png differ diff --git a/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-wide-light-high-contrast-linux.png b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-wide-light-high-contrast-linux.png new file mode 100644 index 00000000000..7551f90759b Binary files /dev/null and b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-wide-light-high-contrast-linux.png differ diff --git a/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-wide-light-linux.png b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-wide-light-linux.png new file mode 100644 index 00000000000..2b4fe4b4b98 Binary files /dev/null and b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-wide-light-linux.png differ diff --git a/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-wide-light-tritanopia-linux.png b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-wide-light-tritanopia-linux.png new file mode 100644 index 00000000000..2b4fe4b4b98 Binary files /dev/null and b/.playwright/snapshots/components/Hidden.test.ts-snapshots/Hidden-Default-wide-light-tritanopia-linux.png differ diff --git a/docs/content/drafts/Hidden.mdx b/docs/content/drafts/Hidden.mdx index 2090bdde820..a7e6ee93adc 100644 --- a/docs/content/drafts/Hidden.mdx +++ b/docs/content/drafts/Hidden.mdx @@ -18,7 +18,7 @@ The `Hidden` component is a utility component that will help you hide or show co ### Single viewport value provided ```jsx live drafts - + ``` @@ -26,7 +26,7 @@ The `Hidden` component is a utility component that will help you hide or show co ### Multiple viewport values provided ```jsx live drafts - + ``` diff --git a/docs/content/drafts/PageHeader.mdx b/docs/content/drafts/PageHeader.mdx index 07eab16538f..44f751767bd 100644 --- a/docs/content/drafts/PageHeader.mdx +++ b/docs/content/drafts/PageHeader.mdx @@ -293,10 +293,10 @@ import {PageHeader} from '@primer/react/drafts' Webhooks - + - + diff --git a/e2e/components/Hidden.test.ts b/e2e/components/Hidden.test.ts new file mode 100644 index 00000000000..3bc87d1cd3e --- /dev/null +++ b/e2e/components/Hidden.test.ts @@ -0,0 +1,50 @@ +import {test, expect} from '@playwright/test' +import {visit} from '../test-helpers/storybook' +import {themes} from '../test-helpers/themes' +import {viewports} from '../test-helpers/viewports' + +test.describe('Hidden', () => { + test.describe('Default', () => { + for (const theme of themes) { + test.describe(theme, () => { + test('default @vrt', async ({page}) => { + await visit(page, { + id: 'drafts-components-hidden--default', + globals: { + colorScheme: theme, + }, + }) + + // Regular size viewport + await page.setViewportSize({width: viewports['primer.breakpoint.md'], height: 768}) + await page + .getByText('The below content is visible when the viewport is regular or wide but hidden when narrow:') + .waitFor() + expect(await page.screenshot()).toMatchSnapshot(`Hidden.Default.medium.${theme}.png`) + // Wide size viewport + await page.setViewportSize({width: viewports['primer.breakpoint.lg'], height: 768}) + await page + .getByText('The below content is visible when the viewport is regular or wide but hidden when narrow:') + .waitFor() + expect(await page.screenshot()).toMatchSnapshot(`Hidden.Default.wide.${theme}.png`) + // Narrow size viewport + await page.setViewportSize({width: viewports['primer.breakpoint.xs'], height: 768}) + await page + .getByText('The below content is visible when the viewport is regular or wide but hidden when narrow:') + .waitFor() + expect(await page.screenshot()).toMatchSnapshot(`Hidden.Default.narrow.${theme}.png`) + }) + + test('axe @aat', async ({page}) => { + await visit(page, { + id: 'drafts-components-hidden--default', + globals: { + colorScheme: theme, + }, + }) + await expect(page).toHaveNoViolations() + }) + }) + } + }) +}) diff --git a/generated/components.json b/generated/components.json index cb5135fa7e3..e76592ba65a 100644 --- a/generated/components.json +++ b/generated/components.json @@ -2268,10 +2268,15 @@ "name": "Hidden", "status": "draft", "a11yReviewed": false, - "stories": [], + "stories": [ + { + "id": "components-hidden--default", + "code": "() => (\n <>\n \n The below content is visible when the viewport is regular or wide but\n hidden when narrow:\n \n \n This is the said content and it is visible when the viewport is regular or\n wide but hidden when narrow\n \n \n)" + } + ], "props": [ { - "name": "on", + "name": "when", "type": "'narrow' | 'wide' | 'regular' | Array<'narrow' | 'regular' | 'wide'>", "defaultValue": "", "description": "In which viewport(s) the children are going to be hidden" diff --git a/script/generate-e2e-tests.js b/script/generate-e2e-tests.js index 0d030a15766..4b1921969d2 100644 --- a/script/generate-e2e-tests.js +++ b/script/generate-e2e-tests.js @@ -374,6 +374,17 @@ const components = new Map([ ], }, ], + [ + 'Hidden', + { + stories: [ + { + id: 'drafts-components-hidden--default', + name: 'Default', + }, + ], + }, + ], [ 'IconButton', { diff --git a/src/Hidden/Hidden.docs.json b/src/Hidden/Hidden.docs.json index 3816f52e391..0c4b3a0d3e0 100644 --- a/src/Hidden/Hidden.docs.json +++ b/src/Hidden/Hidden.docs.json @@ -6,7 +6,7 @@ "stories": [], "props": [ { - "name": "on", + "name": "when", "type": "'narrow' | 'wide' | 'regular' | Array<'narrow' | 'regular' | 'wide'>", "defaultValue": "", "description": "In which viewport(s) the children are going to be hidden" diff --git a/src/Hidden/examples.stories.tsx b/src/Hidden/Hidden.examples.stories.tsx similarity index 93% rename from src/Hidden/examples.stories.tsx rename to src/Hidden/Hidden.examples.stories.tsx index b6d9b62ef92..39a1fcef230 100644 --- a/src/Hidden/examples.stories.tsx +++ b/src/Hidden/Hidden.examples.stories.tsx @@ -4,7 +4,7 @@ import {Button, Link, Text, StateLabel, BranchName, Box} from '..' import {ArrowRightIcon} from '@primer/octicons-react' import {PageHeader} from '../PageHeader' -import Hidden from '../Hidden' +import Hidden from '.' export default { title: 'Drafts/Components/Hidden/Examples', @@ -30,11 +30,11 @@ export const Webhooks = () => ( Webhooks - + - + @@ -60,7 +60,7 @@ export const PullRequestPage = () => ( Open - + broccolinisoup @@ -69,7 +69,7 @@ export const PullRequestPage = () => ( broccolinisoup/add-hidden-component - + main diff --git a/src/Hidden/Hidden.features.stories.tsx b/src/Hidden/Hidden.features.stories.tsx new file mode 100644 index 00000000000..f6cbcaf8752 --- /dev/null +++ b/src/Hidden/Hidden.features.stories.tsx @@ -0,0 +1,29 @@ +import {ComponentMeta} from '@storybook/react' +import React from 'react' +import {Hidden} from './Hidden' +import {Box, Button} from '..' + +export default { + title: 'Drafts/Components/Hidden/Features', + component: Hidden, +} as ComponentMeta