tailwindcss/src/plugins/boxShadow.js

51 lines
1.3 KiB
JavaScript
Raw Normal View History

import transformThemeValue from '../util/transformThemeValue'
2019-01-09 13:17:49 -05:00
let transformValue = transformThemeValue('boxShadow')
let defaultBoxShadow = [
`var(--tw-ring-offset-shadow, 0 0 #0000)`,
`var(--tw-ring-shadow, 0 0 #0000)`,
`var(--tw-shadow)`,
].join(', ')
2020-10-16 13:30:06 -04:00
export default function () {
return function ({ config, matchUtilities, addBase, addUtilities, theme, variants }) {
if (config('mode') === 'jit') {
2021-06-30 19:11:10 +02:00
addBase({
2021-06-30 22:49:33 +02:00
'@defaults --tw-shadow': {
'--tw-ring-offset-shadow': '0 0 #0000',
'--tw-ring-shadow': '0 0 #0000',
2021-06-30 19:11:10 +02:00
'--tw-shadow': '0 0 #0000',
},
})
} else {
2021-06-30 19:11:10 +02:00
addUtilities(
{
'*, ::before, ::after': {
'--tw-shadow': '0 0 #0000',
},
},
{ respectImportant: false }
)
}
matchUtilities(
{
shadow: (value) => {
value = transformValue(value)
2019-01-09 13:17:49 -05:00
return {
2021-06-30 22:49:33 +02:00
...(config('mode') === 'jit' ? { '@defaults --tw-shadow': {} } : {}),
'--tw-shadow': value === 'none' ? '0 0 #0000' : value,
'box-shadow': defaultBoxShadow,
}
},
},
{
values: theme('boxShadow'),
variants: variants('boxShadow'),
type: 'lookup',
}
)
2019-01-09 13:17:49 -05:00
}
}