Skip to content
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

refactor(CircleOcticon): Move files to folder, add storybook and e2e tests. #3119

Merged
merged 7 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
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.
2 changes: 1 addition & 1 deletion docs/content/CircleOcticon.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: CircleOcticon
status: Alpha
---

import data from '../../src/CircleOcticon.docs.json'
import data from '../../src/CircleOcticon/CircleOcticon.docs.json'

CircleOcticon renders any Octicon with a circle background. CircleOcticons are most commonly used to represent the status of a pull request in the comment timeline.

Expand Down
61 changes: 61 additions & 0 deletions e2e/components/CircleOcticon.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'

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

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

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'components-circleocticon--default',
globals: {
colorScheme: theme,
},
})
await expect(page).toHaveNoViolations()
})
})
}
})

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

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

test('axe @aat', async ({page}) => {
await visit(page, {
id: 'components-circleocticon--playground',
globals: {
colorScheme: theme,
},
})
await expect(page).toHaveNoViolations()
})
})
}
})
})
53 changes: 29 additions & 24 deletions generated/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,6 @@
],
"subcomponents": []
},
"circle_octicon": {
"id": "circle_octicon",
"name": "CircleOcticon",
"status": "alpha",
"a11yReviewed": false,
"stories": [],
"props": [
{
"name": "icon",
"type": "Octicon"
},
{
"name": "size",
"defaultValue": "32",
"type": "number",
"description": "Set the width and height of the icon in pixels."
},
{
"name": "sx",
"type": "SystemStyleObject"
}
],
"subcomponents": []
},
"dialog": {
"id": "dialog",
"name": "Dialog",
Expand Down Expand Up @@ -1746,6 +1722,35 @@
}
]
},
"circle_octicon": {
"id": "circle_octicon",
"name": "CircleOcticon",
"status": "alpha",
"a11yReviewed": false,
"stories": [
{
"id": "components-circleocticon--default",
"code": "() => (\n <CircleOcticon\n icon={CheckIcon}\n size={32}\n sx={{\n backgroundColor: 'success.fg',\n color: 'fg.onEmphasis',\n }}\n />\n)"
}
],
"props": [
{
"name": "icon",
"type": "Octicon"
},
{
"name": "size",
"defaultValue": "32",
"type": "number",
"description": "Set the width and height of the icon in pixels."
},
{
"name": "sx",
"type": "SystemStyleObject"
}
],
"subcomponents": []
},
"counter_label": {
"id": "counter_label",
"name": "CounterLabel",
Expand Down
15 changes: 15 additions & 0 deletions script/generate-e2e-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,21 @@ const components = new Map([
],
},
],
[
'CircleOcticon',
{
stories: [
{
id: 'components-circleocticon--default',
name: 'Default',
},
{
id: 'components-circleocticon--playground',
name: 'Playground',
},
],
},
],
[
'CircleBadge',
{
Expand Down
59 changes: 59 additions & 0 deletions src/CircleOcticon/CircleOcticon.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React from 'react'
import {Meta, ComponentStory} from '@storybook/react'
import CircleOcticon from './CircleOcticon'
import {CheckIcon} from '@primer/octicons-react'

export default {
title: 'Components/CircleOcticon',
component: CircleOcticon,
} as Meta<typeof CircleOcticon>

export const Default = () => (
<CircleOcticon icon={CheckIcon} size={32} sx={{backgroundColor: 'success.fg', color: 'fg.onEmphasis'}} />
)

export const Playground: ComponentStory<typeof CircleOcticon> = args => <CircleOcticon {...args} />

Playground.args = {
icon: CheckIcon,
size: 32,
sx: {backgroundColor: 'success.fg', 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,
},
},
ref: {
controls: false,
table: {
disable: true,
},
},
theme: {
controls: false,
table: {
disable: true,
},
},
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {IconProps} from '@primer/octicons-react'
import React from 'react'
import Box, {BoxProps} from './Box'
import Box, {BoxProps} from '../Box'

export type CircleOcticonProps = {
as?: React.ElementType
Expand Down
1 change: 1 addition & 0 deletions src/CircleOcticon/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {default, CircleOcticonProps} from './CircleOcticon'