tailwindcss/src/plugins/grayscale.js
Adam Wathan 04d66b0f47 WIP
Still gotta do shadows + backdrop filter
2021-06-24 17:01:36 -04:00

41 lines
1,018 B
JavaScript

import { addBaseSelector } from './filter'
export default function () {
return function ({ config, matchUtilities, theme, variants, memory }) {
if (config('mode') === 'jit') {
matchUtilities(
{
grayscale: (value, { selector }) => {
addBaseSelector(memory, selector)
return {
'--tw-grayscale': `grayscale(${value})`,
filter: 'var(--tw-filter)',
}
},
},
{
values: theme('grayscale'),
variants: variants('grayscale'),
type: 'any',
}
)
} else {
matchUtilities(
{
grayscale: (value) => {
return {
'--tw-grayscale': `grayscale(${value})`,
...(config('mode') === 'jit' ? { filter: 'var(--tw-filter)' } : {}),
}
},
},
{
values: theme('grayscale'),
variants: variants('grayscale'),
type: 'any',
}
)
}
}
}