Skip to content

Commit 1cb060d

Browse files
adamwathanneupauer
andauthored
Add mix-blend-mode and background-blend-mode utilities (#3920)
* Add mix-blend-mode utilities * Rename mix-blend-mode utilities to `mix-blend-*` Co-Authored-By: Peter Neupauer <[email protected]> * Add `background-blend-mode` utilities Co-Authored-By: Peter Neupauer <[email protected]> Co-authored-by: Peter Neupauer <[email protected]>
1 parent 21a96af commit 1cb060d

14 files changed

+3146
-0
lines changed

__tests__/fixtures/tailwind-output-flagged.css

+768
Large diffs are not rendered by default.

__tests__/fixtures/tailwind-output-important.css

+768
Large diffs are not rendered by default.

__tests__/fixtures/tailwind-output-no-color-opacity.css

+768
Large diffs are not rendered by default.

__tests__/fixtures/tailwind-output.css

+768
Large diffs are not rendered by default.
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('../../lib/plugins/backgroundBlendMode').default()

jit/corePlugins/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,8 @@ module.exports = {
282282
placeholderOpacity: require('./placeholderOpacity'),
283283

284284
opacity: require('./opacity'),
285+
backgroundBlendMode: require('./backgroundBlendMode'),
286+
mixBlendMode: require('./mixBlendMode'),
285287
boxShadow: require('./boxShadow'),
286288
outline: require('./outline'),
287289
ringWidth: require('./ringWidth'),

jit/corePlugins/mixBlendMode.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('../../lib/plugins/mixBlendMode').default()

jit/tests/basic-usage.test.css

+12
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,18 @@
576576
.opacity-90 {
577577
opacity: 0.9;
578578
}
579+
.bg-blend-darken {
580+
background-blend-mode: darken;
581+
}
582+
.bg-blend-difference {
583+
background-blend-mode: difference;
584+
}
585+
.mix-blend-multiply {
586+
mix-blend-mode: multiply;
587+
}
588+
.mix-blend-saturation {
589+
mix-blend-mode: saturation;
590+
}
579591
.shadow-md {
580592
--tw-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
581593
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000),

jit/tests/basic-usage.test.html

+2
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@
8888
<div class="object-cover"></div>
8989
<div class="object-bottom"></div>
9090
<div class="opacity-90"></div>
91+
<div class="bg-blend-darken bg-blend-difference"></div>
92+
<div class="mix-blend-multiply mix-blend-saturation"></div>
9193
<div class="order-last order-2"></div>
9294
<div class="outline-none outline-black"></div>
9395
<div class="overflow-hidden"></div>

src/corePluginList.js

+2
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,6 @@ export const corePluginList = [
120120
'transitionDuration',
121121
'transitionDelay',
122122
'animation',
123+
'mixBlendMode',
124+
'backgroundBlendMode',
123125
]

src/plugins/backgroundBlendMode.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export default function () {
2+
return function ({ addUtilities, variants }) {
3+
addUtilities(
4+
{
5+
'.bg-blend-normal': { 'background-blend-mode': 'normal' },
6+
'.bg-blend-multiply': { 'background-blend-mode': 'multiply' },
7+
'.bg-blend-screen': { 'background-blend-mode': 'screen' },
8+
'.bg-blend-overlay': { 'background-blend-mode': 'overlay' },
9+
'.bg-blend-darken': { 'background-blend-mode': 'darken' },
10+
'.bg-blend-lighten': { 'background-blend-mode': 'lighten' },
11+
'.bg-blend-color-dodge': { 'background-blend-mode': 'color-dodge' },
12+
'.bg-blend-color-burn': { 'background-blend-mode': 'color-burn' },
13+
'.bg-blend-hard-light': { 'background-blend-mode': 'hard-light' },
14+
'.bg-blend-soft-light': { 'background-blend-mode': 'soft-light' },
15+
'.bg-blend-difference': { 'background-blend-mode': 'difference' },
16+
'.bg-blend-exclusion': { 'background-blend-mode': 'exclusion' },
17+
'.bg-blend-hue': { 'background-blend-mode': 'hue' },
18+
'.bg-blend-saturation': { 'background-blend-mode': 'saturation' },
19+
'.bg-blend-color': { 'background-blend-mode': 'color' },
20+
'.bg-blend-luminosity': { 'background-blend-mode': 'luminosity' },
21+
},
22+
variants('backgroundBlendMode')
23+
)
24+
}
25+
}

src/plugins/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export { default as alignSelf } from './alignSelf'
55
export { default as animation } from './animation'
66
export { default as appearance } from './appearance'
77
export { default as backgroundAttachment } from './backgroundAttachment'
8+
export { default as backgroundBlendMode } from './backgroundBlendMode'
89
export { default as backgroundClip } from './backgroundClip'
910
export { default as backgroundColor } from './backgroundColor'
1011
export { default as backgroundImage } from './backgroundImage'
@@ -70,6 +71,7 @@ export { default as maxHeight } from './maxHeight'
7071
export { default as maxWidth } from './maxWidth'
7172
export { default as minHeight } from './minHeight'
7273
export { default as minWidth } from './minWidth'
74+
export { default as mixBlendMode } from './mixBlendMode'
7375
export { default as objectFit } from './objectFit'
7476
export { default as objectPosition } from './objectPosition'
7577
export { default as opacity } from './opacity'

src/plugins/mixBlendMode.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export default function () {
2+
return function ({ addUtilities, variants }) {
3+
addUtilities(
4+
{
5+
'.mix-blend-normal': { 'mix-blend-mode': 'normal' },
6+
'.mix-blend-multiply': { 'mix-blend-mode': 'multiply' },
7+
'.mix-blend-screen': { 'mix-blend-mode': 'screen' },
8+
'.mix-blend-overlay': { 'mix-blend-mode': 'overlay' },
9+
'.mix-blend-darken': { 'mix-blend-mode': 'darken' },
10+
'.mix-blend-lighten': { 'mix-blend-mode': 'lighten' },
11+
'.mix-blend-color-dodge': { 'mix-blend-mode': 'color-dodge' },
12+
'.mix-blend-color-burn': { 'mix-blend-mode': 'color-burn' },
13+
'.mix-blend-hard-light': { 'mix-blend-mode': 'hard-light' },
14+
'.mix-blend-soft-light': { 'mix-blend-mode': 'soft-light' },
15+
'.mix-blend-difference': { 'mix-blend-mode': 'difference' },
16+
'.mix-blend-exclusion': { 'mix-blend-mode': 'exclusion' },
17+
'.mix-blend-hue': { 'mix-blend-mode': 'hue' },
18+
'.mix-blend-saturation': { 'mix-blend-mode': 'saturation' },
19+
'.mix-blend-color': { 'mix-blend-mode': 'color' },
20+
'.mix-blend-luminosity': { 'mix-blend-mode': 'luminosity' },
21+
},
22+
variants('mixBlendMode')
23+
)
24+
}
25+
}

stubs/defaultConfig.stub.js

+2
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,7 @@ module.exports = {
740740
animation: ['responsive'],
741741
appearance: ['responsive'],
742742
backgroundAttachment: ['responsive'],
743+
backgroundBlendMode: ['responsive'],
743744
backgroundClip: ['responsive'],
744745
backgroundColor: ['responsive', 'dark', 'group-hover', 'focus-within', 'hover', 'focus'],
745746
backgroundImage: ['responsive'],
@@ -805,6 +806,7 @@ module.exports = {
805806
maxWidth: ['responsive'],
806807
minHeight: ['responsive'],
807808
minWidth: ['responsive'],
809+
mixBlendMode: ['responsive'],
808810
objectFit: ['responsive'],
809811
objectPosition: ['responsive'],
810812
opacity: ['responsive', 'group-hover', 'focus-within', 'hover', 'focus'],

0 commit comments

Comments
 (0)