Add new ring utilities for custom focus styles and rounded outlines (#2747)
* Add ring utilities * Remove redundant shadows, add 5% and 95% to opacity scale * Undo changes to build file * Update boxShadow.test.js
This commit is contained in:
parent
d39ecc56f1
commit
d4fcd2eb8f
14 changed files with 27032 additions and 1928 deletions
32
src/plugins/ringColor.js
Normal file
32
src/plugins/ringColor.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import _ from 'lodash'
|
||||
import flattenColorPalette from '../util/flattenColorPalette'
|
||||
import nameClass from '../util/nameClass'
|
||||
import { toRgba } from '../util/withAlphaVariable'
|
||||
|
||||
export default function () {
|
||||
return function ({ addUtilities, theme, variants }) {
|
||||
const colors = flattenColorPalette(theme('ringColor'))
|
||||
const utilities = _.fromPairs(
|
||||
_.map(_.omit(colors, 'DEFAULT'), (value, modifier) => {
|
||||
try {
|
||||
const [r, g, b, a] = toRgba(value)
|
||||
return [
|
||||
nameClass('ring', modifier),
|
||||
{
|
||||
'--ring-opacity': a === undefined ? '1' : a,
|
||||
'--ring-color': `rgba(${r}, ${g}, ${b}, var(--ring-opacity))`,
|
||||
},
|
||||
]
|
||||
} catch (_error) {
|
||||
return [
|
||||
nameClass('ring', modifier),
|
||||
{
|
||||
'--ring-color': value,
|
||||
},
|
||||
]
|
||||
}
|
||||
})
|
||||
)
|
||||
addUtilities(utilities, variants('ringColor'))
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue