-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from primer/new-css-vars-docs
Add docs for `new-css-color-vars` linter
- Loading branch information
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
## Upgrade legacy color CSS variables to Primitives v8 in sx prop | ||
|
||
CSS variables are allowed within the `sx` prop in Primer React components. However, the legacy color CSS variables are deprecated in favor of the new CSS variables introduced in Primitives v8. This rule will warn you if you are using the deprecated color CSS variables in the `sx` prop, and autofix it including a fallback to the old value. | ||
|
||
## Rule Details | ||
|
||
This rule looks inside the `sx` prop for the following properties: | ||
|
||
``` | ||
'bg', | ||
'backgroundColor', | ||
'color', | ||
'borderColor', | ||
'borderTopColor', | ||
'borderRightColor', | ||
'borderBottomColor', | ||
'borderLeftColor', | ||
'border', | ||
'boxShadow', | ||
'caretColor' | ||
``` | ||
|
||
The rule references a static JSON file called `css-variable-map.json` that matches the old color CSS variables to a new one based on the property. We only check `sx` because `stylelint` is used to lint other forms of CSS-in-JS. | ||
|
||
👎 Examples of **incorrect** code for this rule | ||
|
||
```jsx | ||
<Button sx={{color: 'var(--color-fg-muted)'}}>Test</Button> | ||
``` | ||
|
||
👍 Examples of **correct** code for this rule: | ||
|
||
```jsx | ||
<Button sx={{color: 'var(--fgColor-muted, var(--color-fg-muted))'}}>Test</Button> | ||
``` |