Skip to content

Commit dc78902

Browse files
authored
Bump @primer/primitives to v5 (#1514)
* Install latest primitives and eslint plugin * Configure eslint plugin to check all strings for deprecated colors * Fix lint errors * Update tests * Remove auto colors from Dialog * Update storybook preview * Don't use fade variables * Bump eslint plugin * Update snapshots * Create violet-cougars-yawn.md * Update violet-cougars-yawn.md * Update colors in storybook preview * Update more color variables * Update more color variables
1 parent 2454919 commit dc78902

33 files changed

+151
-166
lines changed

.changeset/violet-cougars-yawn.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@primer/components": major
3+
---
4+
5+
Remove deprecated color variables by upgrading to @primer/primitives [v5](https://github.com/primer/primitives/pull/251)
6+
7+
**Note:** Install [`eslint-plugin-primer-react`](https://primer.style/react/linting) to ensure that you're not using any deprecated or removed color variables.

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
{
5656
"allow": ["dark_dimmed"]
5757
}
58-
]
58+
],
59+
"primer-react/no-deprecated-colors": ["warn", {"checkAllStrings": true}]
5960
},
6061
"overrides": [
6162
// rules which apply only to JS

.storybook/preview.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import styled, {createGlobalStyle} from 'styled-components'
55
// set global theme styles for each story
66
const GlobalStyle = createGlobalStyle`
77
body {
8-
background-color: ${themeGet('colors.bg.primary')};
9-
color: ${themeGet('colors.text.primary')};
8+
background-color: ${themeGet('colors.canvas.default')};
9+
color: ${themeGet('colors.fg.default')};
1010
}
1111
`
1212

@@ -26,8 +26,8 @@ const Wrapper = styled.div`
2626

2727
// instead of global theme, only theme wrapper for each story
2828
const ThemedSectionStyle = styled.div`
29-
background-color: ${themeGet('colors.bg.primary')};
30-
color: ${themeGet('colors.text.primary')};
29+
background-color: ${themeGet('colors.canvas.default')};
30+
color: ${themeGet('colors.fg.default')};
3131
padding: 1rem;
3232
`
3333

codemods/deprecateUtilityComponents.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ module.exports = (file, api) => {
5050
attributes: {
5151
borderWidth: '1px',
5252
borderStyle: 'solid',
53-
borderColor: 'border.primary',
53+
borderColor: 'border.default',
5454
borderRadius: 2
5555
}
5656
}

docs/content/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ import {BaseStyles, Box, Heading} from '@primer/components'
9090
export default () => (
9191
<BaseStyles>
9292
<Box m={4}>
93-
<Heading mb={2}>Hello, world!</Heading>
93+
<Heading sx={{mb: 2}}>Hello, world!</Heading>
9494
<p>This will get Primer text styles.</p>
9595
</Box>
9696
</BaseStyles>

docs/content/overriding-styles.mdx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ This example demonstrates applying a bottom border to `Heading`, a component tha
2525
pb={2}
2626
sx={{
2727
borderBottomWidth: 1,
28-
borderBottomColor: 'border.primary',
28+
borderBottomColor: 'border.default',
2929
borderBottomStyle: 'solid'
30-
}}>
31-
Heading with bottom border
30+
}}
31+
>
32+
Heading with bottom border
3233
</Heading>
3334
</>
3435
```
@@ -45,7 +46,7 @@ Just like [values passed to system props](https://styled-system.com/responsive-s
4546
borderRadius={2}
4647
p={2}
4748
sx={{
48-
bg: ['bg.primary', 'bg.info', 'bg.success', 'bg.warning', 'bg.danger']
49+
bg: ['neutral.subtle', 'accent.subtle', 'success.subtle', 'attention.subtle', 'danger.subtle']
4950
}}
5051
>
5152
Responsive background color
@@ -61,15 +62,15 @@ The `sx` prop also allows for declaring styles based on media queries, psueudo-c
6162
sx={{
6263
'> *': {
6364
borderWidth: 1,
64-
borderColor: "border.default",
65+
borderColor: 'border.default',
6566
borderStyle: 'solid',
6667
borderBottomWidth: 0,
6768
padding: 2,
6869
':last-child': {
6970
borderBottomWidth: 1
7071
},
7172
':hover': {
72-
bg: "neutral.muted"
73+
bg: 'neutral.muted'
7374
}
7475
}
7576
}}

docs/content/theming.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ Some [system props](/system-props) and [`sx` prop](/overriding-styles) keys are
5757
```jsx
5858
const theme = {
5959
colors: {
60-
bg: {
61-
primary: '#fff'
60+
canvas: {
61+
default: '#fff'
6262
}
6363
}
6464
}
@@ -67,7 +67,7 @@ function App() {
6767
return (
6868
<ThemeProvider theme={theme}>
6969
<Box bg="canvas.default"></Box>
70-
<Box sx={{bg: "canvas.default"}}></Box>
70+
<Box sx={{bg: 'canvas.default'}}></Box>
7171
</ThemeProvider>
7272
)
7373
}
@@ -84,7 +84,7 @@ import {themeGet} from '@primer/components'
8484
import styled from 'styled-components'
8585

8686
const Example = styled.div`
87-
background-color: ${themeGet("colors.canvas.default")};
87+
background-color: ${themeGet('colors.canvas.default')};
8888
`
8989
```
9090

@@ -97,7 +97,7 @@ import {ThemeProvider, useTheme} from '@primer/components'
9797

9898
function Example() {
9999
const {theme} = useTheme()
100-
// theme.colors.bg.primary
100+
// theme.colors.canvas.default
101101
}
102102

103103
function App() {

package-lock.json

Lines changed: 11 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"license": "MIT",
4545
"dependencies": {
4646
"@primer/octicons-react": "^13.0.0",
47-
"@primer/primitives": "4.8.1",
47+
"@primer/primitives": "5.1.0",
4848
"@radix-ui/react-polymorphic": "0.0.14",
4949
"@react-aria/ssr": "3.1.0",
5050
"@styled-system/css": "5.1.5",
@@ -113,7 +113,7 @@
113113
"eslint-plugin-jsx-a11y": "6.4.1",
114114
"eslint-plugin-mdx": "1.15.1",
115115
"eslint-plugin-prettier": "3.4.0",
116-
"eslint-plugin-primer-react": "0.5.0",
116+
"eslint-plugin-primer-react": "0.6.1",
117117
"eslint-plugin-react": "7.24.0",
118118
"eslint-plugin-react-hooks": "4.2.0",
119119
"jest": "27.0.4",

src/ActionList/Item.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ export const Item = React.forwardRef((itemProps, ref) => {
432432
/>
433433
</>
434434
) : (
435-
selected && <CheckIcon fill={theme?.colors.text.primary} />
435+
selected && <CheckIcon fill={theme?.colors.fg.default} />
436436
)}
437437
</BaseVisualContainer>
438438
)}

src/BaseStyles.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function BaseStyles(props: BaseStylesProps) {
4545
}
4646

4747
BaseStyles.defaultProps = {
48-
color: 'text.primary',
48+
color: 'fg.default',
4949
fontFamily: 'normal',
5050
lineHeight: 'default'
5151
}

src/BorderBox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const BorderBox = styled(Box)``
1111
BorderBox.defaultProps = {
1212
borderWidth: '1px',
1313
borderStyle: 'solid',
14-
borderColor: 'border.primary',
14+
borderColor: 'border.default',
1515
borderRadius: 2
1616
}
1717

src/Caret.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ Caret.locations = [
125125
]
126126

127127
Caret.defaultProps = {
128-
bg: 'bg.canvas',
129-
borderColor: 'border.primary',
128+
bg: 'canvas.default',
129+
borderColor: 'border.default',
130130
borderWidth: 1
131131
}
132132

src/Dialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ const Dialog = forwardRef<HTMLDivElement, InternalDialogProps>(
135135
)
136136

137137
DialogHeader.defaultProps = {
138-
backgroundColor: 'bg.tertiary'
138+
backgroundColor: 'canvas.subtle'
139139
}
140140

141141
DialogHeader.propTypes = {

src/Flash.tsx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,35 @@ import {ComponentProps} from './utils/types'
77
const variants = variant({
88
variants: {
99
default: {
10-
color: 'alert.info.text',
11-
backgroundColor: 'alert.info.bg',
12-
borderColor: 'alert.info.border',
10+
color: 'fg.default',
11+
backgroundColor: 'accent.subtle',
12+
borderColor: 'accent.muted',
1313
svg: {
14-
color: 'alert.info.icon'
14+
color: 'accent.fg'
1515
}
1616
},
1717
success: {
18-
color: 'alert.success.text',
19-
backgroundColor: 'alert.success.bg',
20-
borderColor: 'alert.success.border',
18+
color: 'fg.default',
19+
backgroundColor: 'success.subtle',
20+
borderColor: 'success.muted',
2121
svg: {
22-
color: 'alert.success.icon'
22+
color: 'success.fg'
2323
}
2424
},
2525
danger: {
26-
color: 'alert.error.text',
27-
backgroundColor: 'alert.error.bg',
28-
borderColor: 'alert.error.border',
26+
color: 'fg.default',
27+
backgroundColor: 'danger.subtle',
28+
borderColor: 'danger.muted',
2929
svg: {
30-
color: 'alert.error.icon'
30+
color: 'danger.fg'
3131
}
3232
},
3333
warning: {
34-
color: 'alert.warn.text',
35-
backgroundColor: 'alert.warn.bg',
36-
borderColor: 'alert.warn.border',
34+
color: 'fg.default',
35+
backgroundColor: 'attention.subtle',
36+
borderColor: 'attention.muted',
3737
svg: {
38-
color: 'alert.warn.icon'
38+
color: 'attention.fg'
3939
}
4040
}
4141
}

src/Label.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const Label = styled.span<
6767
`
6868

6969
Label.defaultProps = {
70-
bg: 'label.primary.border',
70+
bg: 'neutral.emphasis',
7171
variant: 'medium'
7272
}
7373

src/ProgressBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function ProgressBar({progress, bg, theme, ...rest}: ProgressBarProps) {
4545
}
4646

4747
ProgressBar.defaultProps = {
48-
bg: 'bg.successInverse',
48+
bg: 'success.emphasis',
4949
barSize: 'default'
5050
}
5151

src/StateLabel.tsx

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,28 @@ const colorVariants = variant({
2020
prop: 'status',
2121
variants: {
2222
issueClosed: {
23-
backgroundColor: 'prState.closed.bg',
24-
color: 'prState.closed.text',
25-
borderColor: 'prState.closed.border'
23+
backgroundColor: 'danger.emphasis',
24+
color: 'fg.onEmphasis'
2625
},
2726
pullClosed: {
28-
backgroundColor: 'prState.closed.bg',
29-
color: 'prState.closed.text',
30-
borderColor: 'prState.closed.border'
27+
backgroundColor: 'danger.emphasis',
28+
color: 'fg.onEmphasis'
3129
},
3230
pullMerged: {
33-
backgroundColor: 'prState.merged.bg',
34-
color: 'prState.merged.text',
35-
borderColor: 'prState.merged.border'
31+
backgroundColor: 'done.emphasis',
32+
color: 'fg.onEmphasis'
3633
},
3734
issueOpened: {
38-
backgroundColor: 'prState.open.bg',
39-
color: 'prState.open.text',
40-
borderColor: 'prState.open.border'
35+
backgroundColor: 'success.emphasis',
36+
color: 'fg.onEmphasis'
4137
},
4238
pullOpened: {
43-
backgroundColor: 'prState.open.bg',
44-
color: 'prState.open.text',
45-
borderColor: 'prState.open.border'
39+
backgroundColor: 'success.emphasis',
40+
color: 'fg.onEmphasis'
4641
},
4742
draft: {
48-
backgroundColor: 'prState.draft.bg',
49-
color: 'prState.draft.text',
50-
borderColor: 'prState.draft.border'
43+
backgroundColor: 'neutral.emphasis',
44+
color: 'fg.onEmphasis'
5145
}
5246
}
5347
})
@@ -82,8 +76,6 @@ const StateLabelBase = styled.span<StyledStateLabelBaseProps>`
8276
color: ${get('colors.canvas.default')};
8377
text-align: center;
8478
border-radius: ${get('radii.3')};
85-
border-width: 1px;
86-
border-style: solid;
8779
${colorVariants};
8880
${sizeVariants};
8981
${COMMON};

src/Token/_RemoveTokenButton.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,13 @@ const StyledTokenButton = styled.span<TokenButtonProps & SxProp>`
5757
5858
&:hover,
5959
&:focus {
60-
background-color: ${get('colors.fade.fg10')};
60+
// TODO: choose a better functional color variable for this
61+
background-color: ${get('colors.neutral.muted')};
6162
}
6263
6364
&:active {
64-
background-color: ${get('colors.fade.fg15')};
65+
// TODO: choose a better functional color variable for this
66+
background-color: ${get('colors.neutral.subtle')};
6567
}
6668
6769
${variants}

src/__tests__/BorderBox.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('BorderBox', () => {
2424
it('renders borders', () => {
2525
expect(render(<BorderBox borderColor="success.emphasis" />)).toHaveStyleRule(
2626
'border-color',
27-
theme.colorSchemes.light.colors.border?.success
27+
theme.colorSchemes.light.colors.success?.emphasis
2828
)
2929
expect(render(<BorderBox borderBottom={0} />)).toHaveStyleRule('border-bottom', '0')
3030
})

0 commit comments

Comments
 (0)