Skip to content

Commit 44fb2a3

Browse files
authored
Update component docs (CircleBadge, Flash) (#1717)
* Update circlebadge docs * Update flash docs * Update props table logic * Add component ids
1 parent 45f38e0 commit 44fb2a3

File tree

5 files changed

+176
-76
lines changed

5 files changed

+176
-76
lines changed

docs/content/CircleBadge.md

Lines changed: 0 additions & 37 deletions
This file was deleted.

docs/content/CircleBadge.mdx

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
componentId: circle_badge
3+
title: CircleBadge
4+
status: Alpha
5+
source: https://github.com/primer/react/blob/main/src/CircleBadge.tsx
6+
---
7+
8+
```js
9+
import {CircleBadge} from '@primer/react'
10+
```
11+
12+
Use CircleBadge to visually connect logos of third party services like in marketplace. Use CircleBadge.Icon to add an Octicon to the CircleBadge.
13+
14+
## Examples
15+
16+
```jsx live
17+
<CircleBadge>
18+
<CircleBadge.Icon icon={ZapIcon} />
19+
</CircleBadge>
20+
```
21+
22+
## Props
23+
24+
### CircleBadge
25+
26+
<PropsTable>
27+
<PropsTableRow
28+
name="variant"
29+
type="'small' | 'medium' | 'large'"
30+
defaultValue="'medium'"
31+
description={
32+
<>
33+
Creates a smaller or larger badge. Has no effect if the <InlineCode>size</InlineCode> prop is set
34+
</>
35+
}
36+
/>
37+
<PropsTableRow
38+
name="size"
39+
type="number"
40+
description={
41+
<>
42+
Sets the size of the badge in pixels. Overrides the <InlineCode>variant</InlineCode> prop when set
43+
</>
44+
}
45+
/>
46+
<PropsTableRow
47+
name="inline"
48+
type="boolean"
49+
defaultValue="false"
50+
description={
51+
<>
52+
Styles the badge to <InlineCode>display: inline</InlineCode>
53+
</>
54+
}
55+
/>
56+
<PropsTableBasePropRows elementType="div" isPolymorphic refType="HTMLDivElement" />
57+
</PropsTable>
58+
59+
### CircleBadge.Icon
60+
61+
<PropsTable>
62+
<PropsTableAsRow defaultElementType="StyledOcticon" />
63+
<PropsTablePassthroughPropsRow
64+
elementName="StyledOcticon"
65+
isPolymorphic
66+
passthroughPropsLink={
67+
<>
68+
the <Link href="/StyledOcticon">StyledOcticon docs</Link>
69+
</>
70+
}
71+
/>
72+
</PropsTable>
73+
74+
## Status
75+
76+
<ComponentChecklist
77+
items={{
78+
propsDocumented: true,
79+
noUnnecessaryDeps: true,
80+
adaptsToThemes: false,
81+
adaptsToScreenSizes: true,
82+
fullTestCoverage: false,
83+
usedInProduction: false,
84+
usageExamplesDocumented: true,
85+
hasStorybookStories: false,
86+
designReviewed: false,
87+
a11yReviewed: false,
88+
stableApi: false,
89+
addressedApiFeedback: false,
90+
hasDesignGuidelines: false,
91+
hasFigmaComponent: false
92+
}}
93+
/>

docs/content/Flash.md

Lines changed: 0 additions & 37 deletions
This file was deleted.

docs/content/Flash.mdx

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
componentId: flash
3+
title: Flash
4+
status: Alpha
5+
source: https://github.com/primer/react/blob/main/src/Flash.tsx
6+
---
7+
8+
```js
9+
import {Flash} from '@primer/react'
10+
```
11+
12+
The Flash component informs users of successful or pending actions.
13+
14+
## Examples
15+
16+
### Default
17+
18+
```jsx live
19+
<>
20+
<Flash>Default Flash</Flash>
21+
<Flash variant="success">Success Flash</Flash>
22+
<Flash variant="warning">Warning Flash</Flash>
23+
<Flash variant="danger">Danger Flash</Flash>
24+
</>
25+
```
26+
27+
### With an icon
28+
29+
Flash components with icons inside of them will automatically set the correct color for the icon depending on the type of Flash, as well as applying the correct right margin.
30+
31+
```jsx live
32+
<Flash variant="success">
33+
<StyledOcticon icon={CheckIcon} />
34+
Success!
35+
</Flash>
36+
```
37+
38+
## Props
39+
40+
### Flash
41+
42+
<PropsTable>
43+
<PropsTableRow name="full" type="boolean" defaultValue="false" description="Creates a full width Flash component" />
44+
<PropsTableRow
45+
name="variant"
46+
type="'default' | 'success' | 'warning' | 'danger'"
47+
defaultValue="'default'"
48+
description="Sets the background color and border"
49+
/>
50+
<PropsTableBasePropRows
51+
elementType="div"
52+
isPolymorphic
53+
refType="HTMLDivElement"
54+
passthroughPropsLink={
55+
<Link href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/div#Attributes">MDN</Link>
56+
}
57+
/>
58+
</PropsTable>
59+
60+
## Status
61+
62+
<ComponentChecklist
63+
items={{
64+
propsDocumented: true,
65+
noUnnecessaryDeps: true,
66+
adaptsToThemes: true,
67+
adaptsToScreenSizes: false,
68+
fullTestCoverage: false,
69+
usedInProduction: false,
70+
usageExamplesDocumented: true,
71+
hasStorybookStories: false,
72+
designReviewed: false,
73+
a11yReviewed: false,
74+
stableApi: false,
75+
addressedApiFeedback: false,
76+
hasDesignGuidelines: false,
77+
hasFigmaComponent: false
78+
}}
79+
/>

docs/src/props-table.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function BasePropRows({passthroughPropsLink, elementType, isPolymorphic, refType
7878
<>
7979
<SxRow />
8080
{isPolymorphic && <AsRow defaultElementType={elementType} />}
81-
<RefRow refType={refType} isPolymorphic={isPolymorphic} />
81+
{refType && <RefRow refType={refType} isPolymorphic={isPolymorphic} />}
8282
<PassthroughPropsRow
8383
passthroughPropsLink={passthroughPropsLink}
8484
elementName={elementType}
@@ -107,10 +107,12 @@ function PassthroughPropsRow({elementName, isPolymorphic, passthroughPropsLink})
107107
}
108108

109109
function AsRow({defaultElementType}) {
110+
// Element is a component if the first letter is uppercase (e.g. Button)
111+
const isComponent = defaultElementType[0].toUpperCase() === defaultElementType[0]
110112
return (
111113
<Row
112114
name="as"
113-
defaultValue={`"${defaultElementType}"`}
115+
defaultValue={isComponent ? defaultElementType : `"${defaultElementType}"`}
114116
type={
115117
<Link href="https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts#L73">
116118
React.ElementType

0 commit comments

Comments
 (0)