mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
* implement matchUtilities2 * ensure animation names without keyframes are not prefixed * remove matchBase * call addUtilities for each group individually * WIP: Write plugins using matchUtilities2 * MORE * Fix arbitrary value support for fontSize * Fixes, update fixtures * Rebuild fixtures * Don't generate `divide` class with no modifier * Fixes, rebuild fixtures * Rename matchUtilities2 to matchUtilities * Delete bad tests * Remove temp files GROSS * Clean stuff up * Support no return in matchUtilities Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
55 lines
1.4 KiB
JavaScript
55 lines
1.4 KiB
JavaScript
import flattenColorPalette from '../util/flattenColorPalette'
|
|
import toColorValue from '../util/toColorValue'
|
|
import { withAlphaValue } from '../util/withAlphaVariable'
|
|
|
|
function transparentTo(value) {
|
|
return withAlphaValue(value, 0, 'rgba(255, 255, 255, 0)')
|
|
}
|
|
|
|
export default function () {
|
|
return function ({ matchUtilities, theme, variants }) {
|
|
let options = {
|
|
values: flattenColorPalette(theme('gradientColorStops')),
|
|
variants: variants('gradientColorStops'),
|
|
type: 'any',
|
|
}
|
|
|
|
matchUtilities(
|
|
{
|
|
from: (value) => {
|
|
let transparentToValue = transparentTo(value)
|
|
|
|
return {
|
|
'--tw-gradient-from': toColorValue(value, 'from'),
|
|
'--tw-gradient-stops': `var(--tw-gradient-from), var(--tw-gradient-to, ${transparentToValue})`,
|
|
}
|
|
},
|
|
},
|
|
options
|
|
)
|
|
matchUtilities(
|
|
{
|
|
via: (value) => {
|
|
let transparentToValue = transparentTo(value)
|
|
|
|
return {
|
|
'--tw-gradient-stops': `var(--tw-gradient-from), ${toColorValue(
|
|
value,
|
|
'via'
|
|
)}, var(--tw-gradient-to, ${transparentToValue})`,
|
|
}
|
|
},
|
|
},
|
|
options
|
|
)
|
|
matchUtilities(
|
|
{
|
|
to: (value) => {
|
|
return { '--tw-gradient-to': toColorValue(value, 'to') }
|
|
},
|
|
},
|
|
options
|
|
)
|
|
}
|
|
}
|