mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
Add support for negative calc values
This commit is contained in:
parent
03b73b135d
commit
d3675ebd23
@ -1141,6 +1141,7 @@ test('custom properties are multiplied by -1 for negative values', () => {
|
||||
'4': '4px',
|
||||
foo: 'var(--foo)',
|
||||
bar: 'var(--bar, 500px)',
|
||||
baz: 'calc(50% - 10px)',
|
||||
},
|
||||
margin: (theme, { negative }) => ({
|
||||
...theme('spacing'),
|
||||
@ -1171,6 +1172,7 @@ test('custom properties are multiplied by -1 for negative values', () => {
|
||||
'4': '4px',
|
||||
foo: 'var(--foo)',
|
||||
bar: 'var(--bar, 500px)',
|
||||
baz: 'calc(50% - 10px)',
|
||||
},
|
||||
margin: {
|
||||
'1': '1px',
|
||||
@ -1179,12 +1181,14 @@ test('custom properties are multiplied by -1 for negative values', () => {
|
||||
'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: {},
|
||||
|
||||
@ -12,7 +12,7 @@ const configUtils = {
|
||||
.reduce(
|
||||
(negativeScale, key) => ({
|
||||
...negativeScale,
|
||||
[`-${key}`]: startsWith(scale[key], 'var(')
|
||||
[`-${key}`]: ['var(', 'calc('].some(prefix => startsWith(scale[key], prefix))
|
||||
? `calc(${scale[key]} * -1)`
|
||||
: `-${scale[key]}`,
|
||||
}),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user