-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #390 from 10up/feature/339-filename-based-entrypoi…
…nt-for-block-specific-CSS Add logic for block style entry points
- Loading branch information
Showing
21 changed files
with
208 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"10up-toolkit": patch | ||
--- | ||
|
||
Allow block-specific CSS entry points |
1 change: 1 addition & 0 deletions
1
packages/toolkit/__tests__/build-project-block-specific-css/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
./dist |
8 changes: 8 additions & 0 deletions
8
..._tests__/build-project-block-specific-css/__fixtures__/assets/css/blocks/core/heading.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.wp-block-heading { | ||
|
||
@mixin margin-trim; | ||
|
||
@media (--bp-small) { | ||
padding: 40px; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...it/__tests__/build-project-block-specific-css/__fixtures__/assets/css/frontend/styles.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
html { | ||
background: #f5f5f5; | ||
padding: 20px; | ||
|
||
@mixin margin-trim; | ||
|
||
@media (--bp-small) { | ||
padding: 40px; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...ests__/build-project-block-specific-css/__fixtures__/assets/css/globals/media-queries.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Media Queries | ||
*/ | ||
@custom-media --bp-tiny ( min-width: 25em ); /* 400px */ | ||
@custom-media --bp-small ( min-width: 30em ); /* 480px */ | ||
@custom-media --bp-medium ( min-width: 48em ); /* 768px */ | ||
@custom-media --bp-large ( min-width: 64em ); /* 1024px */ | ||
@custom-media --bp-xlarge ( min-width: 80em ); /* 1280px */ | ||
@custom-media --bp-xxlarge ( min-width: 90em ); /* 1440px */ | ||
|
||
/* WP Core Breakpoints (used for the admin bar for example) */ | ||
@custom-media --wp-small ( min-width: 600px ); | ||
@custom-media --wp-medium-max (max-width: 782px); |
15 changes: 15 additions & 0 deletions
15
...__tests__/build-project-block-specific-css/__fixtures__/assets/css/mixins/margin-trim.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
@define-mixin margin-trim { | ||
margin-trim: block; | ||
|
||
/* Fallback for browsers that don't support margin-trim */ | ||
@supports not (margin-trim: block) { | ||
|
||
& > *:first-child { | ||
margin-top: 0; | ||
} | ||
|
||
& > *:last-child { | ||
margin-bottom: 0; | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
packages/toolkit/__tests__/build-project-block-specific-css/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "test-build-project-global-css", | ||
"10up-toolkit": { | ||
"loadBlockSpecificStyles": true, | ||
"paths": { | ||
"srcDir": "./__fixtures__/assets/", | ||
"blocksStyles": "./__fixtures__/assets/css/blocks/", | ||
"cssLoaderPaths": ["./__fixtures__/assets/css", "./includes/blocks"], | ||
"globalStylesDir": "./__fixtures__/assets/css/globals/", | ||
"globalMixinsDir": "./__fixtures__/assets/css/mixins/" | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
packages/toolkit/__tests__/build-project-block-specific-css/test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
import spawn from 'cross-spawn'; | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
|
||
describe('build a project', () => { | ||
it('builds and compiles css with global css', async () => { | ||
spawn.sync('node', ['../../scripts/build'], { | ||
cwd: __dirname, | ||
}); | ||
|
||
const frontendCss = path.join( | ||
__dirname, | ||
'dist', | ||
'blocks', | ||
'autoenqueue', | ||
'core', | ||
'heading.css', | ||
); | ||
|
||
expect(fs.existsSync(frontendCss)).toBeTruthy(); | ||
expect( | ||
fs.existsSync( | ||
path.join(__dirname, 'dist', 'blocks', 'autoenqueue', 'core', 'heading.asset.php'), | ||
), | ||
).toBeTruthy(); | ||
|
||
const compiledCSS = fs.readFileSync(frontendCss).toString(); | ||
|
||
// expect the compiled CSS to contain "min-width: 30em" | ||
expect(compiledCSS).toMatch('min-width: 30em'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
module.exports = { | ||
srcDir: './assets/', | ||
cssLoaderPaths: ['./assets/css', './includes/blocks'], | ||
copyAssetsDir: './assets/', | ||
blocksDir: './includes/blocks/', | ||
globalStylesDir: './assets/css/globals/', | ||
blocksStyles: './assets/css/blocks/', | ||
copyAssetsDir: './assets/', | ||
cssLoaderPaths: ['./assets/css', './includes/blocks'], | ||
globalMixinsDir: './assets/css/mixins/', | ||
globalStylesDir: './assets/css/globals/', | ||
srcDir: './assets/', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.wp-block-paragraph { | ||
background-color: var(--c-black); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.wp-block-tenup-accordion { | ||
border: 1px solid var(--c-black); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.