Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
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()
})
})
}
})
})
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',
},
],
},
],
[
'CounterLabel',
{
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'