Skip to content

Commit 82bd051

Browse files
authored
Update do/dont visual style, add indented prop (#376)
* Update do/dont visual style, add `indented` prop * Update do/dont indented colors * Add changeset * Fix changeset package
1 parent e412052 commit 82bd051

File tree

3 files changed

+53
-8
lines changed

3 files changed

+53
-8
lines changed

.changeset/clever-lions-kiss.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/gatsby-theme-doctocat': minor
3+
---
4+
5+
New visual styles for Do/Dont components

docs/content/components/do-dont.mdx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,18 @@ The `DoDontContainer` component also accepts a `stacked` prop to create stacked
4545
</Dont>
4646
</DoDontContainer>
4747
```
48+
49+
### Indented
50+
51+
`Do` and `Dont` components can also be indented to increase the clarity of the example message within the documentation:
52+
53+
```jsx live
54+
<DoDontContainer stacked>
55+
<Do indented>
56+
Place pane regions on the left to display navigation, filtering, or an overview for entities such as users, bots, apps, etc.
57+
</Do>
58+
<Dont indented>
59+
Don't display more than three columns of information on a page.
60+
</Dont>
61+
</DoDontContainer>
62+
```

theme/src/components/do-dont.js

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {Box, StyledOcticon, Text} from '@primer/react'
2-
import {CheckCircleFillIcon, XCircleFillIcon} from '@primer/octicons-react'
32
import React from 'react'
43

54
export function DoDontContainer({stacked, children}) {
@@ -15,22 +14,48 @@ DoDontContainer.defaultProps = {
1514
}
1615

1716
export function Do(props) {
18-
return <DoDontBase {...props} title="Do" icon={CheckCircleFillIcon} iconBg="success.fg" />
17+
return <DoDontBase {...props} title="Do" bg="success.fg" borderColor="success.muted" />
1918
}
2019

2120
export function Dont(props) {
22-
return <DoDontBase {...props} title="Don't" icon={XCircleFillIcon} iconBg="danger.fg" />
21+
return <DoDontBase {...props} title="Dont" bg="danger.fg" borderColor="danger.muted" />
2322
}
2423

25-
function DoDontBase({children, title, icon: Icon, iconBg}) {
24+
function DoDontBase({children, title, bg, borderColor, indented}) {
2625
return (
2726
<Box sx={{display: 'flex', flexDirection: 'column'}}>
28-
<Box sx={{display: 'flex', alignSelf: 'start', flexDirection: 'row', alignItems: 'center', mb: '2'}}>
29-
<StyledOcticon icon={Icon} sx={{color: iconBg}} />
30-
<Text sx={{fontWeight: 'bold', color: 'fg.default', ml: 2}}>{title}</Text>
27+
<Box
28+
sx={{
29+
display: 'flex',
30+
alignSelf: 'start',
31+
flexDirection: 'row',
32+
alignItems: 'center',
33+
mb: '2',
34+
backgroundColor: bg,
35+
borderRadius: '2',
36+
color: 'fg.onEmphasis',
37+
paddingX: '2'
38+
}}
39+
>
40+
<Text sx={{fontWeight: 'bold', fontSize: '1', color: 'fg.onEmphasis'}}>{title}</Text>
3141
</Box>
3242
<Box sx={{'& *:last-child': {mb: 0}, img: {maxWidth: '100%'}, display: 'flex', flexDirection: 'column'}}>
33-
{children}
43+
{indented ? (
44+
<Box
45+
as="blockquote"
46+
sx={{
47+
margin: '0',
48+
borderLeftWidth: '4px',
49+
borderLeftStyle: 'solid',
50+
borderLeftColor: borderColor,
51+
paddingLeft: '3'
52+
}}
53+
>
54+
{children}
55+
</Box>
56+
) : (
57+
children
58+
)}
3459
</Box>
3560
</Box>
3661
)

0 commit comments

Comments
 (0)