forked from tailwindlabs/tailwindcss
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ignore values not parseable by reduce-css-calc
- Loading branch information
1 parent
f5fe518
commit b91f0ef
Showing
3 changed files
with
25 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import negateValue from '../src/util/negateValue' | ||
|
||
test('it negates numeric CSS values', () => { | ||
expect(negateValue('5')).toEqual('-5') | ||
expect(negateValue('10px')).toEqual('-10px') | ||
expect(negateValue('18rem')).toEqual('-18rem') | ||
expect(negateValue('-10')).toEqual('10') | ||
expect(negateValue('-7ch')).toEqual('7ch') | ||
}) | ||
|
||
test('it leaves keywords untouched', () => { | ||
expect(negateValue('auto')).toEqual('auto') | ||
expect(negateValue('cover')).toEqual('cover') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import reduceCalc from 'reduce-css-calc' | ||
|
||
export default function(value) { | ||
try { | ||
return reduceCalc(`calc(${value} * -1)`) | ||
} catch (e) { | ||
return value | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters