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 66 UNSUPPORTED_LENGTH_UNIT ,
77 WORD ,
88} from '../tokenTypes'
9+ import aspectRatio from './aspectRatio'
910import border from './border'
1011import boxShadow from './boxShadow'
1112import flex from './flex'
@@ -51,6 +52,7 @@ const textShadowOffset = tokenStream => ({
5152} )
5253
5354export default {
55+ aspectRatio,
5456 background,
5557 border,
5658 borderColor,
You can’t perform that action at this time.
0 commit comments