-
Notifications
You must be signed in to change notification settings - Fork 648
Add PostCSS color var fallback for upcoming CSS work #3278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
9930201
360c705
f136578
db6c2df
f9be480
1f04825
3e02a7a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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('./node_modules/@primer/primitives/tokens-next-private/fallbacks/color-fallbacks.json') | ||
|
|
||
| const input = new Set([ | ||
| // "exports" | ||
|
|
@@ -116,6 +118,13 @@ const baseConfig = { | |
| extract: 'components.css', | ||
| autoModules: false, | ||
| modules: {generateScopedName: 'prc_[local]-[hash:base64:5]'}, | ||
| plugins: [ | ||
| postcssCustomPropertiesFallback({ | ||
| importFrom: { | ||
| customProperties: importedJSONFromPrimitives, | ||
| }, | ||
| }), | ||
| ], | ||
|
Comment on lines
+122
to
+127
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these fallbacks for a "default" theme? Would it be possible to have these fallbacks be dynamic for whatever the product specifies as the default theme? e.g. in Sass this might look like: // Exporting tokens in package
@use 'theme';
$bgColor-default: var(--bgColor-default, theme.get('bgColor-default'));
// Product usage
@use '@primer/styles/scss/themes';
@use '@primer/styles/scss/theme' with (
$theme: themes.$dark,
);
@use '@primer/styles/scss/tokens' as *;
.my-selector {
background: $bgColor-default;
}
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its passing a CSS var as a fallback, so it does respect theme. In this case it will look like
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm realizing fallback is kind of generic here. This is like a special snowflake fallback that's temporary so we can test the new color vars against the old ones. |
||
| }), | ||
| ], | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.