Skip to content

Commit

Permalink
Merge 8b9c328 into c860b70
Browse files Browse the repository at this point in the history
  • Loading branch information
mperrotti committed May 3, 2024
2 parents c860b70 + 8b9c328 commit e55aba5
Show file tree
Hide file tree
Showing 17 changed files with 1,074 additions and 188 deletions.
7 changes: 7 additions & 0 deletions .changeset/rotten-apples-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@primer/react': minor
---

Adds UnderlinePanels component. It's like UnderlineNav, but for rendering semantic tabs instead of links.

<!-- Changed components: UnderilnePanels -->
245 changes: 245 additions & 0 deletions e2e/components/UnderlinePanels.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'

test.describe('UnderlinePanels', () => {
test.describe('Default', () => {
for (const theme of themes) {
test.describe(theme, () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'drafts-components-underlinepanels--default',
globals: {
colorScheme: theme,
},
})

// Default state
expect(await page.screenshot()).toMatchSnapshot(`UnderlineNav.Default.${theme}.png`)
})

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'drafts-components-underlinepanels--default',
globals: {
colorScheme: theme,
},
})
await expect(page).toHaveNoViolations({
rules: {
'color-contrast': {
enabled: theme !== 'dark_dimmed',
},
},
})
})
})
}
})

test.describe('Labelled By External Element', () => {
for (const theme of themes) {
test.describe(theme, () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'drafts-components-underlinepanels-features--labelled-by-external-element',
globals: {
colorScheme: theme,
},
})

// Default state
expect(await page.screenshot()).toMatchSnapshot(`UnderlineNav.Labelled By External Element.${theme}.png`)
})

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'drafts-components-underlinepanels-features--labelled-by-external-element',
globals: {
colorScheme: theme,
},
})
await expect(page).toHaveNoViolations({
rules: {
'color-contrast': {
enabled: theme !== 'dark_dimmed',
},
},
})
})
})
}
})

test.describe('Selected Tab', () => {
for (const theme of themes) {
test.describe(theme, () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'drafts-components-underlinepanels-features--selected-tab',
globals: {
colorScheme: theme,
},
})

// Default state
expect(await page.screenshot()).toMatchSnapshot(`UnderlineNav.Selected Tab.${theme}.png`)
})

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'drafts-components-underlinepanels-features--selected-tab',
globals: {
colorScheme: theme,
},
})
await expect(page).toHaveNoViolations({
rules: {
'color-contrast': {
enabled: theme !== 'dark_dimmed',
},
},
})
})
})
}
})

test.describe('With Counters', () => {
for (const theme of themes) {
test.describe(theme, () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'drafts-components-underlinepanels-features--with-counters',
globals: {
colorScheme: theme,
},
})

// Default state
expect(await page.screenshot()).toMatchSnapshot(`UnderlineNav.With Counters.${theme}.png`)
})

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'drafts-components-underlinepanels-features--with-counters',
globals: {
colorScheme: theme,
},
})
await expect(page).toHaveNoViolations({
rules: {
'color-contrast': {
enabled: theme !== 'dark_dimmed',
},
},
})
})
})
}
})

test.describe('With Counters In Loading State', () => {
for (const theme of themes) {
test.describe(theme, () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'drafts-components-underlinepanels-features--with-counters-in-loading-state',
globals: {
colorScheme: theme,
},
})

// Default state
expect(await page.screenshot()).toMatchSnapshot(`UnderlineNav.With Counters In Loading State.${theme}.png`)
})

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'drafts-components-underlinepanels-features--with-counters-in-loading-state',
globals: {
colorScheme: theme,
},
})
await expect(page).toHaveNoViolations({
rules: {
'color-contrast': {
enabled: theme !== 'dark_dimmed',
},
},
})
})
})
}
})

test.describe('With Icons', () => {
for (const theme of themes) {
test.describe(theme, () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'drafts-components-underlinepanels-features--with-icons',
globals: {
colorScheme: theme,
},
})

// Default state
expect(await page.screenshot()).toMatchSnapshot(`UnderlineNav.With Icons.${theme}.png`)
})

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'drafts-components-underlinepanels-features--with-icons',
globals: {
colorScheme: theme,
},
})
await expect(page).toHaveNoViolations({
rules: {
'color-contrast': {
enabled: theme !== 'dark_dimmed',
},
},
})
})
})
}
})

test.describe('With Icons Hidden On Narrow Screen', () => {
for (const theme of themes) {
test.describe(theme, () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'drafts-components-underlinepanels-features--with-icons-hidden-on-narrow-screen',
globals: {
colorScheme: theme,
},
})

// Default state
expect(await page.screenshot()).toMatchSnapshot(
`UnderlineNav.With Icons Hidden On Narrow Screen.${theme}.png`,
)
})

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'drafts-components-underlinepanels-features--with-icons-hidden-on-narrow-screen',
globals: {
colorScheme: theme,
},
})
await expect(page).toHaveNoViolations({
rules: {
'color-contrast': {
enabled: theme !== 'dark_dimmed',
},
},
})
})
})
}
})
})
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"@github/markdown-toolbar-element": "^2.1.0",
"@github/paste-markdown": "^1.4.0",
"@github/relative-time-element": "^4.1.2",
"@github/tab-container-element": "4.5.0",
"@github/tab-container-element": "4.7.0",
"@lit-labs/react": "1.2.1",
"@oddbird/popover-polyfill": "^0.3.1",
"@primer/behaviors": "^1.5.1",
Expand Down
17 changes: 0 additions & 17 deletions packages/react/src/UnderlineNav/LoadingCounter.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions packages/react/src/UnderlineNav/UnderlineNav.docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"importPath": "@primer/react",
"props": [
{
"name": "afterSelect",
"name": "onSelect",
"type": "(event) => void",
"defaultValue": "",
"description": "The handler that gets called when a nav link child is selected"
Expand Down Expand Up @@ -48,7 +48,7 @@
},
{
"name": "counter",
"type": "number",
"type": "number | string",
"defaultValue": "",
"description": "The number to display in the counter label."
},
Expand Down
Loading

0 comments on commit e55aba5

Please sign in to comment.