* prefix custom properties with tw- * prefix custom properties with tw- in tests * prefix gradient values in the defaultConfig * inline gradient-via-color * simplify --tw-tailwind-empty to --tw-empty * replace the long --tw-font-variant-numeric-... to the way shorter --tw-fvn-... * Rename --tw-box-shadow to --tw-shadow To match class name. * Rename font-variant-numeric variables * Remove 'transform' from transform variables * Shorten gradient variables * Fix style Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
51 lines
1.6 KiB
JavaScript
51 lines
1.6 KiB
JavaScript
import _ from 'lodash'
|
|
import nameClass from '../util/nameClass'
|
|
import { toRgba } from '../util/withAlphaVariable'
|
|
|
|
export default function () {
|
|
return function ({ addUtilities, theme, variants }) {
|
|
function safeCall(callback, defaultValue) {
|
|
try {
|
|
return callback()
|
|
} catch (_error) {
|
|
return defaultValue
|
|
}
|
|
}
|
|
|
|
const ringColorDefault = (([r, g, b]) => {
|
|
return `rgba(${r}, ${g}, ${b}, ${theme('ringOpacity.DEFAULT', '0.5')})`
|
|
})(safeCall(() => toRgba(theme('ringColor.DEFAULT')), ['147', '197', '253']))
|
|
|
|
const utilities = _.fromPairs(
|
|
_.map(theme('ringWidth'), (value, modifier) => {
|
|
return [
|
|
nameClass('ring', modifier),
|
|
{
|
|
'--tw-ring-inset': 'var(--tw-empty,/*!*/ /*!*/)',
|
|
'--tw-ring-offset-width': '0px',
|
|
'--tw-ring-offset-color': '#fff',
|
|
'--tw-ring-color': ringColorDefault,
|
|
'--tw-ring-offset-shadow': `var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)`,
|
|
'--tw-ring-shadow': `var(--tw-ring-inset) 0 0 0 calc(${value} + var(--tw-ring-offset-width)) var(--tw-ring-color)`,
|
|
'box-shadow': [
|
|
`var(--tw-ring-offset-shadow)`,
|
|
`var(--tw-ring-shadow)`,
|
|
`var(--tw-shadow, 0 0 #0000)`,
|
|
].join(', '),
|
|
},
|
|
]
|
|
})
|
|
)
|
|
addUtilities(
|
|
[
|
|
utilities,
|
|
{
|
|
'.ring-inset': {
|
|
'--tw-ring-inset': 'inset',
|
|
},
|
|
},
|
|
],
|
|
variants('ringWidth')
|
|
)
|
|
}
|
|
}
|