2020-08-18 23:26:29 +02:00
|
|
|
import postcss from 'postcss'
|
|
|
|
|
import tailwind from '../../src/index'
|
|
|
|
|
|
|
|
|
|
test('opacity variables are given to colors defined as closures', () => {
|
|
|
|
|
return postcss([
|
|
|
|
|
tailwind({
|
|
|
|
|
theme: {
|
|
|
|
|
colors: {
|
2020-08-19 11:38:22 -04:00
|
|
|
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)`
|
|
|
|
|
},
|
2021-04-30 15:09:58 +02:00
|
|
|
secondary: 'hsl(10, 50%, 50%)',
|
2020-08-19 11:38:22 -04:00
|
|
|
},
|
|
|
|
|
opacity: {
|
2020-10-17 20:34:11 -04:00
|
|
|
50: '0.5',
|
2020-08-18 23:26:29 +02:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
variants: {
|
2020-08-19 11:38:22 -04:00
|
|
|
textColor: [],
|
|
|
|
|
textOpacity: [],
|
2020-08-18 23:26:29 +02:00
|
|
|
gradientColorStops: [],
|
|
|
|
|
},
|
2020-08-19 11:38:22 -04:00
|
|
|
corePlugins: ['textColor', 'textOpacity', 'gradientColorStops'],
|
2020-08-18 23:26:29 +02:00
|
|
|
}),
|
|
|
|
|
])
|
|
|
|
|
.process('@tailwind utilities', { from: undefined })
|
2020-10-16 15:39:44 -04:00
|
|
|
.then((result) => {
|
2020-08-18 23:26:29 +02:00
|
|
|
const expected = `
|
2021-04-30 15:09:58 +02:00
|
|
|
.text-primary {
|
|
|
|
|
--tw-text-opacity: 1;
|
|
|
|
|
color: rgba(31, 31, 31, var(--tw-text-opacity));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.text-secondary {
|
|
|
|
|
--tw-text-opacity: 1;
|
|
|
|
|
color: hsla(10, 50%, 50%, var(--tw-text-opacity));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.text-opacity-50 {
|
|
|
|
|
--tw-text-opacity: 0.5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.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, hsla(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, hsla(10, 50%, 50%, 0));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.to-primary {
|
|
|
|
|
--tw-gradient-to: rgb(31, 31, 31);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.to-secondary {
|
|
|
|
|
--tw-gradient-to: hsl(10, 50%, 50%);
|
|
|
|
|
}
|
2020-08-18 23:26:29 +02:00
|
|
|
`
|
|
|
|
|
|
|
|
|
|
expect(result.css).toMatchCss(expected)
|
|
|
|
|
})
|
|
|
|
|
})
|