Skip to content

Commit

Permalink
Add PostCSS color var fallback for upcoming CSS work (#3278)
Browse files Browse the repository at this point in the history
* add fallback plugin

* Update rollup.config.js

Co-authored-by: Josh Black <joshblack@github.com>

* remove fallbacks from source

* add back conflict free package-lock

* use lockfileVersion 3

---------

Co-authored-by: Josh Black <joshblack@github.com>
Co-authored-by: Siddharth Kshetrapal <siddharthkp@github.com>
  • Loading branch information
3 people authored May 26, 2023
1 parent e865e3e commit 60ebd51
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 3 deletions.
55 changes: 55 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@
"mdast-util-to-string": "3.1.1",
"micromark-extension-frontmatter": "1.0.0",
"micromark-extension-mdxjs": "1.0.0",
"postcss-custom-properties-fallback": "^1.0.2",
"prettier": "2.8.1",
"react": "18.2.0",
"react-dnd": "14.0.4",
Expand Down
9 changes: 9 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import glob from 'fast-glob'
import {visualizer} from 'rollup-plugin-visualizer'
import postcss from 'rollup-plugin-postcss'
import packageJson from './package.json'
import postcssCustomPropertiesFallback from 'postcss-custom-properties-fallback'
const importedJSONFromPrimitives = require('@primer/primitives/tokens-next-private/fallbacks/color-fallbacks.json')

const input = new Set([
// "exports"
Expand Down Expand Up @@ -116,6 +118,13 @@ const baseConfig = {
extract: 'components.css',
autoModules: false,
modules: {generateScopedName: 'prc_[local]-[hash:base64:5]'},
plugins: [
postcssCustomPropertiesFallback({
importFrom: {
customProperties: importedJSONFromPrimitives,
},
}),
],
}),
],
}
Expand Down
6 changes: 3 additions & 3 deletions src/drafts/CSSComponent/component.module.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.component {
background-color: var(--bgColor-default, var(--color-canvas-default));
color: var(--fgColor-muted, var(--color-fg-muted));
border: 1px solid var(--borderColor-default, var(--color-border-default));
background-color: var(--bgColor-default);
color: var(--fgColor-muted);
border: 1px solid var(--borderColor-default);
width: fit-content;
padding: var(--control-xsmall-paddingBlock) var(--control-xsmall-paddingInline-normal);
}

0 comments on commit 60ebd51

Please sign in to comment.