mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
* 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>
71 lines
2.0 KiB
JavaScript
71 lines
2.0 KiB
JavaScript
import { run, html, css } from '../util/run'
|
|
|
|
test('opacity variables are given to colors defined as closures', () => {
|
|
let config = {
|
|
content: [
|
|
{
|
|
raw: html`<div
|
|
class="text-primary text-secondary text-opacity-50 from-primary from-secondary via-primary via-secondary to-primary to-secondary"
|
|
></div>`,
|
|
},
|
|
],
|
|
theme: {
|
|
colors: {
|
|
primary: ({ opacityVariable, opacityValue }) => {
|
|
if (opacityValue !== undefined) {
|
|
return `rgba(31,31,31,${opacityValue})`
|
|
}
|
|
|
|
if (opacityVariable !== undefined) {
|
|
return `rgba(31,31,31,var(${opacityVariable},1))`
|
|
}
|
|
|
|
return `rgb(31,31,31)`
|
|
},
|
|
secondary: 'hsl(10, 50%, 50%)',
|
|
},
|
|
opacity: {
|
|
50: '0.5',
|
|
},
|
|
},
|
|
}
|
|
|
|
return run('@tailwind utilities', config).then((result) => {
|
|
expect(result.css).toMatchFormattedCss(css`
|
|
.from-primary {
|
|
--tw-gradient-from: rgb(31, 31, 31);
|
|
--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgba(31, 31, 31, 0));
|
|
}
|
|
.from-secondary {
|
|
--tw-gradient-from: hsl(10, 50%, 50%);
|
|
--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, hsl(10 50% 50% / 0));
|
|
}
|
|
.via-primary {
|
|
--tw-gradient-stops: var(--tw-gradient-from), rgb(31, 31, 31),
|
|
var(--tw-gradient-to, rgba(31, 31, 31, 0));
|
|
}
|
|
.via-secondary {
|
|
--tw-gradient-stops: var(--tw-gradient-from), hsl(10, 50%, 50%),
|
|
var(--tw-gradient-to, hsl(10 50% 50% / 0));
|
|
}
|
|
.to-primary {
|
|
--tw-gradient-to: rgb(31, 31, 31);
|
|
}
|
|
.to-secondary {
|
|
--tw-gradient-to: hsl(10, 50%, 50%);
|
|
}
|
|
.text-primary {
|
|
--tw-text-opacity: 1;
|
|
color: rgba(31, 31, 31, var(--tw-text-opacity));
|
|
}
|
|
.text-secondary {
|
|
--tw-text-opacity: 1;
|
|
color: hsl(10 50% 50% / var(--tw-text-opacity));
|
|
}
|
|
.text-opacity-50 {
|
|
--tw-text-opacity: 0.5;
|
|
}
|
|
`)
|
|
})
|
|
})
|