Skip to content

Commit 1c0ca36

Browse files
authored
Remove deprecated components (#361)
* Flex -> Box * Grid -> Box * Position -> Box * Absolute -> Box * Fixed -> Box * Sticky -> Box * Relative -> Box * Update imports * BorderBox -> Box * Remove sass dependency * Use sx prop instead of system props * Update theme/src/components/header.js * Update theme/src/components/header.js * Update theme/src/components/table-of-contents.js * Create large-rabbits-enjoy.md
1 parent ac6de57 commit 1c0ca36

32 files changed

+320
-563
lines changed

.changeset/large-rabbits-enjoy.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": patch
3+
---
4+
5+
Refactor internals to not use deprecated Primer React components

docs/content/components/caption.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ The caption component can be used to append a caption to images used in document
1414
## Example
1515

1616
```jsx live
17-
<Flex alignItems="center" flexDirection="column">
17+
<Box display="flex" alignItems="center" flexDirection="column">
1818
<img
1919
alt=""
2020
src="https://s3.us-west-2.amazonaws.com/photos.puppyspot.com/breeds/245/card/500000291_medium.jpg"
2121
/>
2222
<Caption>A beautiful husky puppy.</Caption>
23-
</Flex>
23+
</Box>
2424
```
2525

2626
<Note variant="warning">

docs/content/usage/customization.mdx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Customization
33
description: Here are a few ways you can customize your Doctocat site.
44
---
55

6-
import {BorderBox} from '@primer/react'
6+
import {Box} from '@primer/react'
77
import {Contributors} from '@primer/gatsby-theme-doctocat'
88

99
## Site metadata
@@ -98,7 +98,14 @@ module.exports = {
9898

9999
If you have the `repository` in `package.json` and `repoRootPath` in `gatsby-config.js` set up correctly (as described [above](#edit-on-github-link)), Doctocat will automatically display contributors on the bottom of every page, like so:
100100

101-
<BorderBox p={4} mb={3}>
101+
<Box
102+
borderWidth="1px"
103+
borderStyle="solid"
104+
borderColor="border.default"
105+
borderRadius={2}
106+
p={4}
107+
mb={3}
108+
>
102109
<Contributors
103110
contributors={[
104111
{
@@ -117,7 +124,7 @@ If you have the `repository` in `package.json` and `repoRootPath` in `gatsby-con
117124
},
118125
]}
119126
/>
120-
</BorderBox>
127+
</Box>
121128

122129
These contributors are determined by commits. However, we know that commits aren't the only way to contribute. You can use [front matter](/usage/front-matter#additional-contributors) to give credit to people who aren't listed in the commit history but still contributed.
123130

docs/content/usage/front-matter.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Front matter
33
---
44

5-
import {BorderBox} from '@primer/react'
5+
import {Box} from '@primer/react'
66
import {StatusLabel} from '@primer/gatsby-theme-doctocat'
77
import StorybookLink from '@primer/gatsby-theme-doctocat/src/components/storybook-link'
88
import SourceLink from '@primer/gatsby-theme-doctocat/src/components/source-link'
@@ -80,9 +80,9 @@ source: https://github.com/path/to/code
8080

8181
If the `source` front matter variable is defined, Doctocat will add a source code link to the top of the page, like this:
8282

83-
<BorderBox p={4} mb={3}>
83+
<Box borderWidth="1px" borderStyle="solid" borderColor="border.default" borderRadius={2} p={4} mb={3}>
8484
<SourceLink href="#" />
85-
</BorderBox>
85+
</Box>
8686

8787
<Note>
8888

@@ -103,9 +103,9 @@ storybook: https://primer.style/view-components/stories/?path=/story/primer-avat
103103

104104
If the `storybook` front matter variable is defined, Doctocat will add a storybook link to the top of the page, like this:
105105

106-
<BorderBox p={4} mb={3}>
106+
<Box borderWidth="1px" borderStyle="solid" borderColor="border.default" borderRadius={2} p={4} mb={3}>
107107
<StorybookLink href="#" />
108-
</BorderBox>
108+
</Box>
109109

110110

111111
## Additional contributors

docs/gatsby-config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@ module.exports = {
1313
},
1414
},
1515
],
16-
plugins: ['gatsby-plugin-sass'],
1716
}

docs/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
"@primer/gatsby-theme-doctocat": "*",
1313
"@primer/react": "^34.5.0",
1414
"gatsby": "^2.24.52",
15-
"gatsby-plugin-sass": "^2.1.0",
16-
"node-sass": "^4.12.0",
1715
"react": "^16.13.1",
1816
"react-dom": "^16.13.1"
1917
},

theme/.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"react/prop-types": "off",
2121
"react/display-name": "off",
2222
"eslint-comments/no-use": "off",
23-
"no-shadow": "off"
23+
"no-shadow": "off",
24+
"primer-react/no-system-props": ["warn", {"includeUtilityComponents": true}]
2425
}
2526
}

theme/src/components/caption.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {Text} from '@primer/react'
22
import React from 'react'
33

44
function Caption(props) {
5-
return <Text as="p" mt={2} mb={3} fontSize={1} color="gray.5" {...props} />
5+
return <Text as="p" {...props} sx={{mt: 2, mb: 3, fontSize: 1, color: 'gray.5'}} />
66
}
77

88
export default Caption

theme/src/components/code.js

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import {Absolute, Box, Relative, Text} from '@primer/react'
1+
import {Box, Text} from '@primer/react'
22
import Highlight, {defaultProps} from 'prism-react-renderer'
3-
import Prism from '../prism'
4-
import githubTheme from '../github'
53
import React from 'react'
4+
import githubTheme from '../github'
5+
import Prism from '../prism'
66
import ClipboardCopy from './clipboard-copy'
77
import LiveCode from './live-code'
88

@@ -15,41 +15,38 @@ function Code({className, children, live, noinline, metastring}) {
1515
}
1616

1717
return (
18-
<Relative
18+
<Box
1919
sx={{
2020
// Make <pre> adjust to the width of the container
2121
// https://stackoverflow.com/a/14406386
2222
display: 'table',
2323
tableLayout: 'fixed',
24-
width: '100%'
24+
width: '100%',
25+
position: 'relative'
2526
}}
2627
>
27-
<Absolute sx={{top: 0, right: 0, p: 2}}>
28+
<Box sx={{top: 0, right: 0, p: 2, position: 'absolute'}}>
2829
<ClipboardCopy value={code} />
29-
</Absolute>
30+
</Box>
3031
<Highlight {...defaultProps} Prism={Prism} code={code} language={language} theme={githubTheme}>
3132
{({className, style, tokens, getLineProps, getTokenProps}) => (
3233
<Box
3334
as="pre"
3435
className={className}
35-
mt={0}
36-
mb={3}
37-
p={3}
38-
border={0}
3936
style={{...style, overflow: 'auto'}}
40-
sx={{borderRadius: 2}}
37+
sx={{borderRadius: 2, mt: 0, mb: 3, p: 3, border: 0}}
4138
>
4239
{tokens.map((line, i) => (
4340
<div key={i} {...getLineProps({line, key: i})}>
4441
{line.map((token, key) => (
45-
<Text key={key} fontFamily="mono" fontSize={1} {...getTokenProps({token, key})} />
42+
<Text key={key} {...getTokenProps({token, key})} sx={{fontFamily: 'mono', fontSize: 1}} />
4643
))}
4744
</div>
4845
))}
4946
</Box>
5047
)}
5148
</Highlight>
52-
</Relative>
49+
</Box>
5350
)
5451
}
5552

theme/src/components/container.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from 'react'
33

44
function Container({children}) {
55
return (
6-
<Box id="skip-nav" width="100%" maxWidth={960} p={5} mx="auto">
6+
<Box id="skip-nav" sx={{width: '100%', maxWidth: 960, p: 5, mx: 'auto'}}>
77
{children}
88
</Box>
99
)

0 commit comments

Comments
 (0)