Skip to content

Commit

Permalink
Add support for local keyframes through a PostCSS plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniGuardiola committed Jun 11, 2024
1 parent 2d34e2a commit e79a8c2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
7 changes: 4 additions & 3 deletions bin/packages/build-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,10 @@ async function buildCSS( file ) {
data: ''.concat( '@use "sass:math";', importLists, contents ),
} );

const result = await postcss(
require( '@wordpress/postcss-plugins-preset' )
).process( builtSass.css, {
const result = await postcss( [
require( 'postcss-local-keyframes' ),
...require( '@wordpress/postcss-plugins-preset' ),
] ).process( builtSass.css, {
from: 'src/app.css',
to: 'dest/app.css',
} );
Expand Down
19 changes: 18 additions & 1 deletion package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@
"@wordpress/warning": "file:packages/warning",
"@wordpress/widgets": "file:packages/widgets",
"@wordpress/wordcount": "file:packages/wordcount",
"es-module-shims": "^1.8.2"
"es-module-shims": "^1.8.2",
"postcss-local-keyframes": "^0.0.2"
},
"devDependencies": {
"@actions/core": "1.9.1",
Expand Down
8 changes: 4 additions & 4 deletions packages/edit-site/src/components/sidebar/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
overflow-y: auto;
}

@keyframes slide-from-right {
@keyframes local--slide-from-right {
from {
transform: translateX(50px);
opacity: 0;
Expand All @@ -14,7 +14,7 @@
}
}

@keyframes slide-from-left {
@keyframes local--slide-from-left {
from {
transform: translateX(-50px);
opacity: 0;
Expand Down Expand Up @@ -47,11 +47,11 @@
}

&.slide-from-left {
animation-name: slide-from-left;
animation-name: local--slide-from-left;
}

&.slide-from-right {
animation-name: slide-from-right;
animation-name: local--slide-from-right;
}

}

0 comments on commit e79a8c2

Please sign in to comment.