File tree Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ import transformCss from '..'
2
+
3
+ it ( 'handles regular aspect ratio values' , ( ) => {
4
+ expect ( transformCss ( [ [ 'aspect-ratio' , '1.5' ] ] ) ) . toEqual ( {
5
+ aspectRatio : 1.5 ,
6
+ } )
7
+ } )
8
+
9
+ it ( 'handles CSS-style aspect ratios' , ( ) => {
10
+ expect ( transformCss ( [ [ 'aspect-ratio' , '3 / 2' ] ] ) ) . toEqual ( {
11
+ aspectRatio : 1.5 ,
12
+ } )
13
+ } )
14
+
15
+ it ( 'handles CSS-style aspect ratios without spaces' , ( ) => {
16
+ expect ( transformCss ( [ [ 'aspect-ratio' , '3/2' ] ] ) ) . toEqual ( {
17
+ aspectRatio : 1.5 ,
18
+ } )
19
+ } )
20
+
21
+ it ( 'throws when omitting second value after slash' , ( ) => {
22
+ expect ( ( ) => transformCss ( [ [ 'aspect-ratio' , '3/' ] ] ) ) . toThrow ( )
23
+ } )
Original file line number Diff line number Diff line change
1
+ import { NUMBER , SLASH } from '../tokenTypes'
2
+
3
+ export default tokenStream => {
4
+ let aspectRatio = tokenStream . expect ( NUMBER )
5
+
6
+ if ( tokenStream . hasTokens ( ) ) {
7
+ tokenStream . expect ( SLASH )
8
+ aspectRatio /= tokenStream . expect ( NUMBER )
9
+ }
10
+
11
+ return { aspectRatio }
12
+ }
Original file line number Diff line number Diff line change 7
7
PERCENT ,
8
8
AUTO ,
9
9
} from '../tokenTypes'
10
+ import aspectRatio from './aspectRatio'
10
11
import border from './border'
11
12
import boxShadow from './boxShadow'
12
13
import flex from './flex'
@@ -53,6 +54,7 @@ const textShadowOffset = tokenStream => ({
53
54
} )
54
55
55
56
export default {
57
+ aspectRatio,
56
58
background,
57
59
border,
58
60
borderColor,
You can’t perform that action at this time.
0 commit comments