Skip to content

Commit

Permalink
Keep the default CSS variables for npm consumers (#24890)
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad authored Aug 28, 2020
1 parent 6e459ea commit e215c80
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
7 changes: 6 additions & 1 deletion bin/packages/build-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ const BUILD_TASK_BY_EXTENSION = {
makeDir( path.dirname( outputFile ) ),
readFile( file, 'utf8' ),
] );

const builtSass = await renderSass( {
file,
includePaths: [ path.join( PACKAGES_DIR, 'base-styles' ) ],
Expand All @@ -109,6 +108,12 @@ const BUILD_TASK_BY_EXTENSION = {
'animations',
'z-index',
]
// Editor styles should be excluded from the default CSS vars output.
.concat(
file.includes( 'editor-styles.scss' )
? []
: [ 'default-custom-properties' ]
)
.map( ( imported ) => `@import "${ imported }";` )
.join( ' ' ) + contents,
} );
Expand Down
7 changes: 7 additions & 0 deletions packages/base-styles/_default-custom-properties.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

// It is important to include these styles in all built stylesheets.
// This allows to CSS variables post CSS plugin to generate fallbacks.
// It also provides default CSS variables for npm package consumers.
:root {
@include admin-scheme(#007cba);
}
12 changes: 1 addition & 11 deletions packages/postcss-plugins-preset/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
module.exports = [
require( 'postcss-custom-properties' )( {
importFrom: [
{
customProperties: {
'--wp-admin-theme-color': '#007cba',
'--wp-admin-theme-color-darker-10': '#006ba1',
'--wp-admin-theme-color-darker-20': '#005a87',
},
},
],
} ),
require( 'postcss-custom-properties' )(),
require( 'autoprefixer' )( { grid: true } ),
];

0 comments on commit e215c80

Please sign in to comment.