Update color parsing and formatting (#5442)
* Replace `culori` with simple color parser * Use space-separated color syntax * Update default color values to use space-separated syntax * Update separator regex * Fix tests * add tests for the new `color` util Also slightly modified the `color` util itself to take `transparent` into account and also format every value as a string for consistency. Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
This commit is contained in:
parent
12fa78b9ca
commit
4919cbfbb8
25 changed files with 409 additions and 302 deletions
|
|
@ -1,9 +1,9 @@
|
|||
import selectorParser from 'postcss-selector-parser'
|
||||
import postcss from 'postcss'
|
||||
import * as culori from 'culori'
|
||||
import escapeCommas from './escapeCommas'
|
||||
import { withAlphaValue } from './withAlphaVariable'
|
||||
import isKeyframeRule from './isKeyframeRule'
|
||||
import { parseColor } from './color'
|
||||
|
||||
export function applyPseudoToMarker(selector, marker, state, join) {
|
||||
let states = [state]
|
||||
|
|
@ -221,10 +221,6 @@ function splitAlpha(modifier) {
|
|||
return [modifier.slice(0, slashIdx), modifier.slice(slashIdx + 1)]
|
||||
}
|
||||
|
||||
function isColor(value) {
|
||||
return culori.parse(value) !== undefined
|
||||
}
|
||||
|
||||
export function asColor(modifier, lookup = {}, tailwindConfig = {}) {
|
||||
if (lookup[modifier] !== undefined) {
|
||||
return lookup[modifier]
|
||||
|
|
@ -245,7 +241,7 @@ export function asColor(modifier, lookup = {}, tailwindConfig = {}) {
|
|||
}
|
||||
|
||||
return asValue(modifier, lookup, {
|
||||
validate: isColor,
|
||||
validate: (value) => parseColor(value) !== null,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue