Skip to content
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

feat(atomizer): Add blend modes #422

Merged
merged 11 commits into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ The website files are located in a few directories:
- `app/` - The "References" page which uses React on the client to dynamically filter Atomizer classes
- `docs/` - The main Jekyll site that contains all the markdown files for the website

### Testing new rules
Add new rules in `src/rules.js` create a new example file in `examples/html` eg `sample-2.html` then run `./node_modules/.bin/atomizer examples/html/sample-2.html`. You could also copy the output and paste into the PR to be extra nice :)

### Quick CSS Glossary

```text
Expand Down Expand Up @@ -147,7 +150,6 @@ Examples:
Example: https://github.com/yahoo/atomizer/blob/master/examples/example-config.js

[BSD license]: https://github.com/acss-io/atomizer/blob/master/LICENSE.md
[CLA]: https://yahoocla.herokuapp.com/
[monorepo]: https://en.wikipedia.org/wiki/Monorepo
[Support]: https://acss.io/support.html
[workspaces]: https://docs.npmjs.com/cli/v8/using-npm/workspaces
2 changes: 2 additions & 0 deletions examples/html/sample-2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<div class="Bgbm(n) Mbm(pl)">Test Blend modes</div>
<div class="foo_Bgbm(h) bar_Mbm(s)">Test parent Blend modes</div>
18 changes: 18 additions & 0 deletions packages/atomizer/src/blendmodes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
redonkulus marked this conversation as resolved.
Show resolved Hide resolved
'c': 'color',
'cb': 'color-burn',
'cd': 'color-dodge',
'd': 'darken',
'di': 'difference',
'e': 'exclusion',
'h': 'hue',
'hl': 'hard-light',
'l': 'lighten',
'lu': 'luminosity',
'm': 'multiply',
'n': 'normal',
'o': 'overlay',
's': 'saturation',
'sc': 'screen',
'sl': 'soft-light'
};
30 changes: 29 additions & 1 deletion packages/atomizer/src/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
* "start" and "end".
* - Rules is written as an array because ORDER is important for the CSS generation.
**/

const blendModes = require('./blendmodes');
const mixBlendModes = Object.assign(blendModes, {'pd': 'plus-darker', 'pl': 'plus-lighter'});
const colors = require('./colors');

module.exports = [
Expand Down Expand Up @@ -648,6 +649,17 @@ module.exports = [
't': 'transparent'
}]
},
// background-blend-mode
{
'type': 'pattern',
'name': 'Background blend mode',
'matcher': 'Bgbm',
'allowParamToValue': false,
'styles': {
'background-blend-mode': '$0'
},
'arguments': [blendModes]
},
// background-image
{
'type': 'pattern',
Expand Down Expand Up @@ -2058,6 +2070,21 @@ module.exports = [
},
/**
==================================================================
MIX BLEND MODE
==================================================================
*/
{
'type': 'pattern',
'name': 'Mix blend mode',
'matcher': 'Mbm',
'allowParamToValue': false,
'styles': {
'mix-blend-mode': '$0'
},
'arguments': [mixBlendModes]
},
/**
==================================================================
OBJECTS
==================================================================
*/
Expand Down Expand Up @@ -3139,6 +3166,7 @@ module.exports = [
/**
==================================================================
SVG
note: 'i': 'inherit' has been left for backwards compat, `inh`: 'inherit' is the global that should be used
==================================================================
*/
{
Expand Down