mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
fix stroke utility generation
This commit is contained in:
parent
06fbc2a0c8
commit
12afd6e8a1
74
__tests__/plugins/stroke.test.js
Normal file
74
__tests__/plugins/stroke.test.js
Normal file
@ -0,0 +1,74 @@
|
||||
import _ from 'lodash'
|
||||
import escapeClassName from '../../src/util/escapeClassName'
|
||||
import plugin from '../../src/plugins/stroke'
|
||||
|
||||
test('colors can be a nested object', () => {
|
||||
const addedUtilities = []
|
||||
|
||||
const config = {
|
||||
theme: {
|
||||
stroke: {
|
||||
purple: 'purple',
|
||||
white: {
|
||||
25: 'rgba(255,255,255,.25)',
|
||||
50: 'rgba(255,255,255,.5)',
|
||||
75: 'rgba(255,255,255,.75)',
|
||||
default: '#fff',
|
||||
},
|
||||
red: {
|
||||
1: 'rgb(33,0,0)',
|
||||
2: 'rgb(67,0,0)',
|
||||
3: 'rgb(100,0,0)',
|
||||
},
|
||||
green: {
|
||||
1: 'rgb(0,33,0)',
|
||||
2: 'rgb(0,67,0)',
|
||||
3: 'rgb(0,100,0)',
|
||||
},
|
||||
blue: {
|
||||
1: 'rgb(0,0,33)',
|
||||
2: 'rgb(0,0,67)',
|
||||
3: 'rgb(0,0,100)',
|
||||
},
|
||||
},
|
||||
},
|
||||
variants: {
|
||||
stroke: ['responsive'],
|
||||
},
|
||||
}
|
||||
|
||||
const pluginApi = {
|
||||
config: (key, defaultValue) => _.get(config, key, defaultValue),
|
||||
e: escapeClassName,
|
||||
addUtilities(utilities, variants) {
|
||||
addedUtilities.push({
|
||||
utilities,
|
||||
variants,
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
plugin()(pluginApi)
|
||||
|
||||
expect(addedUtilities).toEqual([
|
||||
{
|
||||
utilities: {
|
||||
'.stroke-purple': { stroke: 'purple' },
|
||||
'.stroke-white-25': { stroke: 'rgba(255,255,255,.25)' },
|
||||
'.stroke-white-50': { stroke: 'rgba(255,255,255,.5)' },
|
||||
'.stroke-white-75': { stroke: 'rgba(255,255,255,.75)' },
|
||||
'.stroke-white': { stroke: '#fff' },
|
||||
'.stroke-red-1': { stroke: 'rgb(33,0,0)' },
|
||||
'.stroke-red-2': { stroke: 'rgb(67,0,0)' },
|
||||
'.stroke-red-3': { stroke: 'rgb(100,0,0)' },
|
||||
'.stroke-green-1': { stroke: 'rgb(0,33,0)' },
|
||||
'.stroke-green-2': { stroke: 'rgb(0,67,0)' },
|
||||
'.stroke-green-3': { stroke: 'rgb(0,100,0)' },
|
||||
'.stroke-blue-1': { stroke: 'rgb(0,0,33)' },
|
||||
'.stroke-blue-2': { stroke: 'rgb(0,0,67)' },
|
||||
'.stroke-blue-3': { stroke: 'rgb(0,0,100)' },
|
||||
},
|
||||
variants: ['responsive'],
|
||||
},
|
||||
])
|
||||
})
|
||||
@ -1,9 +1,10 @@
|
||||
import _ from 'lodash'
|
||||
import flattenColorPalette from '../util/flattenColorPalette'
|
||||
|
||||
export default function() {
|
||||
return function({ addUtilities, e, config }) {
|
||||
const utilities = _.fromPairs(
|
||||
_.map(config('theme.stroke'), (value, modifier) => {
|
||||
_.map(flattenColorPalette(config('theme.stroke')), (value, modifier) => {
|
||||
return [
|
||||
`.${e(`stroke-${modifier}`)}`,
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user