-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e5578b
commit 5aef3a2
Showing
13 changed files
with
102 additions
and
15 deletions.
There are no files selected for viewing
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 |
9 changes: 9 additions & 0 deletions
9
..._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,9 @@ | ||
.wp-block-heading { | ||
background-color: red; | ||
|
||
@mixins 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.wp-block-paragraph { | ||
background-color: blue; | ||
} |
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 green; | ||
} |
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