Skip to content

Commit 60ebd51

Browse files
langermankjoshblacksiddharthkp
authored
Add PostCSS color var fallback for upcoming CSS work (#3278)
* 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>
1 parent e865e3e commit 60ebd51

File tree

4 files changed

+68
-3
lines changed

4 files changed

+68
-3
lines changed

package-lock.json

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

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@
228228
"mdast-util-to-string": "3.1.1",
229229
"micromark-extension-frontmatter": "1.0.0",
230230
"micromark-extension-mdxjs": "1.0.0",
231+
"postcss-custom-properties-fallback": "^1.0.2",
231232
"prettier": "2.8.1",
232233
"react": "18.2.0",
233234
"react-dnd": "14.0.4",

rollup.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import glob from 'fast-glob'
77
import {visualizer} from 'rollup-plugin-visualizer'
88
import postcss from 'rollup-plugin-postcss'
99
import packageJson from './package.json'
10+
import postcssCustomPropertiesFallback from 'postcss-custom-properties-fallback'
11+
const importedJSONFromPrimitives = require('@primer/primitives/tokens-next-private/fallbacks/color-fallbacks.json')
1012

1113
const input = new Set([
1214
// "exports"
@@ -116,6 +118,13 @@ const baseConfig = {
116118
extract: 'components.css',
117119
autoModules: false,
118120
modules: {generateScopedName: 'prc_[local]-[hash:base64:5]'},
121+
plugins: [
122+
postcssCustomPropertiesFallback({
123+
importFrom: {
124+
customProperties: importedJSONFromPrimitives,
125+
},
126+
}),
127+
],
119128
}),
120129
],
121130
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.component {
2-
background-color: var(--bgColor-default, var(--color-canvas-default));
3-
color: var(--fgColor-muted, var(--color-fg-muted));
4-
border: 1px solid var(--borderColor-default, var(--color-border-default));
2+
background-color: var(--bgColor-default);
3+
color: var(--fgColor-muted);
4+
border: 1px solid var(--borderColor-default);
55
width: fit-content;
66
padding: var(--control-xsmall-paddingBlock) var(--control-xsmall-paddingInline-normal);
77
}

0 commit comments

Comments
 (0)