mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
* Add ring utilities * Remove redundant shadows, add 5% and 95% to opacity scale * Undo changes to build file * Update boxShadow.test.js
38 lines
1.2 KiB
JavaScript
38 lines
1.2 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),
|
|
{
|
|
'--ring-width': value,
|
|
'--ring-color-default': ringColorDefault,
|
|
'box-shadow': [
|
|
`0 0 0 var(--ring-offset-width, 0) var(--ring-offset-color, #fff)`,
|
|
`0 0 0 calc(var(--ring-width) + var(--ring-offset-width, 0px)) var(--ring-color, var(--ring-color-default))`,
|
|
`var(--box-shadow, 0 0 #0000)`,
|
|
].join(', '),
|
|
},
|
|
]
|
|
})
|
|
)
|
|
addUtilities(utilities, variants('ringWidth'))
|
|
}
|
|
}
|