-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize filter plugins for JIT + add arbitrary value support
Except for drop-shadow, will add that once we can think it through a bit.
- Loading branch information
1 parent
c750ca0
commit f97a87a
Showing
20 changed files
with
593 additions
and
238 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
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,21 +1,37 @@ | ||
import _ from 'lodash' | ||
import nameClass from '../util/nameClass' | ||
const { asValue, nameClass } = require('../../jit/pluginUtils') | ||
|
||
export default function () { | ||
return function ({ addUtilities, theme, variants }) { | ||
const utilities = _.fromPairs( | ||
_.map(theme('backdropBlur'), (value, modifier) => { | ||
return [ | ||
nameClass('backdrop-blur', modifier), | ||
{ | ||
'--tw-backdrop-blur': Array.isArray(value) | ||
? value.map((v) => `blur(${v})`).join(' ') | ||
: `blur(${value})`, | ||
}, | ||
] | ||
return function ({ config, matchUtilities, addUtilities, theme, variants }) { | ||
if (config('mode') === 'jit') { | ||
matchUtilities({ | ||
'backdrop-blur': (modifier, { theme }) => { | ||
let value = asValue(modifier, theme.backdropBlur) | ||
|
||
if (value === undefined) { | ||
return [] | ||
} | ||
|
||
return { | ||
[nameClass('backdrop-blur', modifier)]: { '--tw-backdrop-blur': `blur(${value})` }, | ||
} | ||
}, | ||
}) | ||
) | ||
} else { | ||
const utilities = _.fromPairs( | ||
_.map(theme('backdropBlur'), (value, modifier) => { | ||
return [ | ||
nameClass('backdrop-blur', modifier), | ||
{ | ||
'--tw-backdrop-blur': Array.isArray(value) | ||
? value.map((v) => `blur(${v})`).join(' ') | ||
: `blur(${value})`, | ||
}, | ||
] | ||
}) | ||
) | ||
|
||
addUtilities(utilities, variants('backdopBlur')) | ||
addUtilities(utilities, variants('backdopBlur')) | ||
} | ||
} | ||
} |
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,21 +1,39 @@ | ||
import _ from 'lodash' | ||
import nameClass from '../util/nameClass' | ||
const { asValue, nameClass } = require('../../jit/pluginUtils') | ||
|
||
export default function () { | ||
return function ({ addUtilities, theme, variants }) { | ||
const utilities = _.fromPairs( | ||
_.map(theme('backdropBrightness'), (value, modifier) => { | ||
return [ | ||
nameClass('backdrop-brightness', modifier), | ||
{ | ||
'--tw-backdrop-brightness': Array.isArray(value) | ||
? value.map((v) => `brightness(${v})`).join(' ') | ||
: `brightness(${value})`, | ||
}, | ||
] | ||
return function ({ config, matchUtilities, addUtilities, theme, variants }) { | ||
if (config('mode') === 'jit') { | ||
matchUtilities({ | ||
'backdrop-brightness': (modifier, { theme }) => { | ||
let value = asValue(modifier, theme.backdropBrightness) | ||
|
||
if (value === undefined) { | ||
return [] | ||
} | ||
|
||
return { | ||
[nameClass('backdrop-brightness', modifier)]: { | ||
'--tw-backdrop-brightness': `brightness(${value})`, | ||
}, | ||
} | ||
}, | ||
}) | ||
) | ||
} else { | ||
const utilities = _.fromPairs( | ||
_.map(theme('backdropBrightness'), (value, modifier) => { | ||
return [ | ||
nameClass('backdrop-brightness', modifier), | ||
{ | ||
'--tw-backdrop-brightness': Array.isArray(value) | ||
? value.map((v) => `brightness(${v})`).join(' ') | ||
: `brightness(${value})`, | ||
}, | ||
] | ||
}) | ||
) | ||
|
||
addUtilities(utilities, variants('backdropBrightness')) | ||
addUtilities(utilities, variants('backdropBrightness')) | ||
} | ||
} | ||
} |
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,21 +1,39 @@ | ||
import _ from 'lodash' | ||
import nameClass from '../util/nameClass' | ||
const { asValue, nameClass } = require('../../jit/pluginUtils') | ||
|
||
export default function () { | ||
return function ({ addUtilities, theme, variants }) { | ||
const utilities = _.fromPairs( | ||
_.map(theme('backdropContrast'), (value, modifier) => { | ||
return [ | ||
nameClass('backdrop-contrast', modifier), | ||
{ | ||
'--tw-backdrop-contrast': Array.isArray(value) | ||
? value.map((v) => `contrast(${v})`).join(' ') | ||
: `contrast(${value})`, | ||
}, | ||
] | ||
return function ({ config, matchUtilities, addUtilities, theme, variants }) { | ||
if (config('mode') === 'jit') { | ||
matchUtilities({ | ||
'backdrop-contrast': (modifier, { theme }) => { | ||
let value = asValue(modifier, theme.backdropContrast) | ||
|
||
if (value === undefined) { | ||
return [] | ||
} | ||
|
||
return { | ||
[nameClass('backdrop-contrast', modifier)]: { | ||
'--tw-backdrop-contrast': `contrast(${value})`, | ||
}, | ||
} | ||
}, | ||
}) | ||
) | ||
} else { | ||
const utilities = _.fromPairs( | ||
_.map(theme('backdropContrast'), (value, modifier) => { | ||
return [ | ||
nameClass('backdrop-contrast', modifier), | ||
{ | ||
'--tw-backdrop-contrast': Array.isArray(value) | ||
? value.map((v) => `contrast(${v})`).join(' ') | ||
: `contrast(${value})`, | ||
}, | ||
] | ||
}) | ||
) | ||
|
||
addUtilities(utilities, variants('backdropContrast')) | ||
addUtilities(utilities, variants('backdropContrast')) | ||
} | ||
} | ||
} |
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,21 +1,39 @@ | ||
import _ from 'lodash' | ||
import nameClass from '../util/nameClass' | ||
const { asValue, nameClass } = require('../../jit/pluginUtils') | ||
|
||
export default function () { | ||
return function ({ addUtilities, theme, variants }) { | ||
const utilities = _.fromPairs( | ||
_.map(theme('backdropGrayscale'), (value, modifier) => { | ||
return [ | ||
nameClass('backdrop-grayscale', modifier), | ||
{ | ||
'--tw-backdrop-grayscale': Array.isArray(value) | ||
? value.map((v) => `grayscale(${v})`).join(' ') | ||
: `grayscale(${value})`, | ||
}, | ||
] | ||
return function ({ config, matchUtilities, addUtilities, theme, variants }) { | ||
if (config('mode') === 'jit') { | ||
matchUtilities({ | ||
'backdrop-grayscale': (modifier, { theme }) => { | ||
let value = asValue(modifier, theme.backdropGrayscale) | ||
|
||
if (value === undefined) { | ||
return [] | ||
} | ||
|
||
return { | ||
[nameClass('backdrop-grayscale', modifier)]: { | ||
'--tw-backdrop-grayscale': `grayscale(${value})`, | ||
}, | ||
} | ||
}, | ||
}) | ||
) | ||
} else { | ||
const utilities = _.fromPairs( | ||
_.map(theme('backdropGrayscale'), (value, modifier) => { | ||
return [ | ||
nameClass('backdrop-grayscale', modifier), | ||
{ | ||
'--tw-backdrop-grayscale': Array.isArray(value) | ||
? value.map((v) => `grayscale(${v})`).join(' ') | ||
: `grayscale(${value})`, | ||
}, | ||
] | ||
}) | ||
) | ||
|
||
addUtilities(utilities, variants('backdropGrayscale')) | ||
addUtilities(utilities, variants('backdropGrayscale')) | ||
} | ||
} | ||
} |
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,21 +1,39 @@ | ||
import _ from 'lodash' | ||
import nameClass from '../util/nameClass' | ||
const { asValue, nameClass } = require('../../jit/pluginUtils') | ||
|
||
export default function () { | ||
return function ({ addUtilities, theme, variants }) { | ||
const utilities = _.fromPairs( | ||
_.map(theme('backdropHueRotate'), (value, modifier) => { | ||
return [ | ||
nameClass('backdrop-hue-rotate', modifier), | ||
{ | ||
'--tw-backdrop-hue-rotate': Array.isArray(value) | ||
? value.map((v) => `hue-rotate(${v})`).join(' ') | ||
: `hue-rotate(${value})`, | ||
}, | ||
] | ||
return function ({ config, matchUtilities, addUtilities, theme, variants }) { | ||
if (config('mode') === 'jit') { | ||
matchUtilities({ | ||
'backdrop-hue-rotate': (modifier, { theme }) => { | ||
let value = asValue(modifier, theme.backdropHueRotate) | ||
|
||
if (value === undefined) { | ||
return [] | ||
} | ||
|
||
return { | ||
[nameClass('backdrop-hue-rotate', modifier)]: { | ||
'--tw-backdrop-hue-rotate': `hue-rotate(${value})`, | ||
}, | ||
} | ||
}, | ||
}) | ||
) | ||
} else { | ||
const utilities = _.fromPairs( | ||
_.map(theme('backdropHueRotate'), (value, modifier) => { | ||
return [ | ||
nameClass('backdrop-hue-rotate', modifier), | ||
{ | ||
'--tw-backdrop-hue-rotate': Array.isArray(value) | ||
? value.map((v) => `hue-rotate(${v})`).join(' ') | ||
: `hue-rotate(${value})`, | ||
}, | ||
] | ||
}) | ||
) | ||
|
||
addUtilities(utilities, variants('backdropHueRotate')) | ||
addUtilities(utilities, variants('backdropHueRotate')) | ||
} | ||
} | ||
} |
Oops, something went wrong.