mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
Merge branch 'master' of git://github.com/Acidic9/tailwindcss into Acidic9-master
This commit is contained in:
commit
4695f536c7
@ -1130,3 +1130,67 @@ test('the original theme is not mutated', () => {
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
test('custom properties are multiplied by -1 for negative values', () => {
|
||||
const userConfig = {
|
||||
theme: {
|
||||
spacing: {
|
||||
'1': '1px',
|
||||
'2': '2px',
|
||||
'3': '3px',
|
||||
'4': '4px',
|
||||
foo: 'var(--foo)',
|
||||
bar: 'var(--bar, 500px)',
|
||||
baz: 'calc(50% - 10px)',
|
||||
},
|
||||
margin: (theme, { negative }) => ({
|
||||
...theme('spacing'),
|
||||
...negative(theme('spacing')),
|
||||
}),
|
||||
},
|
||||
}
|
||||
|
||||
const defaultConfig = {
|
||||
prefix: '-',
|
||||
important: false,
|
||||
separator: ':',
|
||||
theme: {},
|
||||
variants: {},
|
||||
}
|
||||
|
||||
const result = resolveConfig([userConfig, defaultConfig])
|
||||
|
||||
expect(result).toEqual({
|
||||
prefix: '-',
|
||||
important: false,
|
||||
separator: ':',
|
||||
theme: {
|
||||
spacing: {
|
||||
'1': '1px',
|
||||
'2': '2px',
|
||||
'3': '3px',
|
||||
'4': '4px',
|
||||
foo: 'var(--foo)',
|
||||
bar: 'var(--bar, 500px)',
|
||||
baz: 'calc(50% - 10px)',
|
||||
},
|
||||
margin: {
|
||||
'1': '1px',
|
||||
'2': '2px',
|
||||
'3': '3px',
|
||||
'4': '4px',
|
||||
foo: 'var(--foo)',
|
||||
bar: 'var(--bar, 500px)',
|
||||
baz: 'calc(50% - 10px)',
|
||||
'-1': '-1px',
|
||||
'-2': '-2px',
|
||||
'-3': '-3px',
|
||||
'-4': '-4px',
|
||||
'-foo': 'calc(var(--foo) * -1)',
|
||||
'-bar': 'calc(var(--bar, 500px) * -1)',
|
||||
'-baz': 'calc(calc(50% - 10px) * -1)',
|
||||
},
|
||||
},
|
||||
variants: {},
|
||||
})
|
||||
})
|
||||
|
||||
@ -3,6 +3,7 @@ import isFunction from 'lodash/isFunction'
|
||||
import defaults from 'lodash/defaults'
|
||||
import map from 'lodash/map'
|
||||
import toPath from 'lodash/toPath'
|
||||
import startsWith from 'lodash/startsWith'
|
||||
|
||||
const configUtils = {
|
||||
negative(scale) {
|
||||
@ -11,7 +12,9 @@ const configUtils = {
|
||||
.reduce(
|
||||
(negativeScale, key) => ({
|
||||
...negativeScale,
|
||||
[`-${key}`]: `-${scale[key]}`,
|
||||
[`-${key}`]: ['var(', 'calc('].some(prefix => startsWith(scale[key], prefix))
|
||||
? `calc(${scale[key]} * -1)`
|
||||
: `-${scale[key]}`,
|
||||
}),
|
||||
{}
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user