File tree Expand file tree Collapse file tree 2 files changed +59
-14
lines changed Expand file tree Collapse file tree 2 files changed +59
-14
lines changed Original file line number Diff line number Diff line change @@ -63,3 +63,35 @@ it('transforms border shorthand missing color & style', () => {
63
63
borderStyle : 'solid' ,
64
64
} )
65
65
} )
66
+
67
+ it ( 'transforms bottom direction border shorthand' , ( ) => {
68
+ expect ( transformCss ( [ [ 'border-bottom' , '2px dashed #f00' ] ] ) ) . toEqual ( {
69
+ borderBottomWidth : 2 ,
70
+ borderBottomColor : '#f00' ,
71
+ borderBottomStyle : 'dashed' ,
72
+ } )
73
+ } )
74
+
75
+ it ( 'transforms left direction border shorthand' , ( ) => {
76
+ expect ( transformCss ( [ [ 'border-left' , '2px dashed #f00' ] ] ) ) . toEqual ( {
77
+ borderLeftWidth : 2 ,
78
+ borderLeftColor : '#f00' ,
79
+ borderLeftStyle : 'dashed' ,
80
+ } )
81
+ } )
82
+
83
+ it ( 'transforms right direction border shorthand' , ( ) => {
84
+ expect ( transformCss ( [ [ 'border-right' , '2px dashed #f00' ] ] ) ) . toEqual ( {
85
+ borderRightWidth : 2 ,
86
+ borderRightColor : '#f00' ,
87
+ borderRightStyle : 'dashed' ,
88
+ } )
89
+ } )
90
+
91
+ it ( 'transforms top direction border shorthand' , ( ) => {
92
+ expect ( transformCss ( [ [ 'border-top' , '2px dashed #f00' ] ] ) ) . toEqual ( {
93
+ borderTopWidth : 2 ,
94
+ borderTopColor : '#f00' ,
95
+ borderTopStyle : 'dashed' ,
96
+ } )
97
+ } )
Original file line number Diff line number Diff line change @@ -22,20 +22,29 @@ const {
22
22
const background = tokenStream => ( {
23
23
$merge : { backgroundColor : tokenStream . expect ( COLOR ) } ,
24
24
} )
25
- const border = anyOrderFactory ( {
26
- borderWidth : {
27
- tokens : [ LENGTH , UNSUPPORTED_LENGTH_UNIT ] ,
28
- default : 1 ,
29
- } ,
30
- borderColor : {
31
- tokens : [ COLOR ] ,
32
- default : 'black' ,
33
- } ,
34
- borderStyle : {
35
- tokens : [ regExpToken ( / ^ ( s o l i d | d a s h e d | d o t t e d ) $ / ) ] ,
36
- default : 'solid' ,
37
- } ,
38
- } )
25
+
26
+ const createBorderFactory = ( direction = '' ) =>
27
+ anyOrderFactory ( {
28
+ [ `border${ direction } Width` ] : {
29
+ tokens : [ LENGTH , UNSUPPORTED_LENGTH_UNIT ] ,
30
+ default : 1 ,
31
+ } ,
32
+ [ `border${ direction } Color` ] : {
33
+ tokens : [ COLOR ] ,
34
+ default : 'black' ,
35
+ } ,
36
+ [ `border${ direction } Style` ] : {
37
+ tokens : [ regExpToken ( / ^ ( s o l i d | d a s h e d | d o t t e d ) $ / ) ] ,
38
+ default : 'solid' ,
39
+ } ,
40
+ } )
41
+
42
+ const border = createBorderFactory ( )
43
+ const borderTop = createBorderFactory ( 'Top' )
44
+ const borderBottom = createBorderFactory ( 'Bottom' )
45
+ const borderLeft = createBorderFactory ( 'Left' )
46
+ const borderRight = createBorderFactory ( 'Right' )
47
+
39
48
const borderColor = directionFactory ( {
40
49
types : [ WORD ] ,
41
50
prefix : 'border' ,
@@ -70,6 +79,10 @@ const textShadowOffset = shadowOffsetFactory()
70
79
export default {
71
80
background,
72
81
border,
82
+ borderTop,
83
+ borderBottom,
84
+ borderLeft,
85
+ borderRight,
73
86
borderColor,
74
87
borderRadius,
75
88
borderWidth,
You can’t perform that action at this time.
0 commit comments