@@ -52,42 +52,41 @@ impl BoxShadow {
52
52
53
53
impl ToExpr for BoxShadow {
54
54
fn to_expr ( & self ) -> PropertyTuple {
55
+
56
+ let mut props = vec ! [ ] ;
57
+
58
+ if let Some ( offset_x) = & self . offset_x {
59
+ props. push ( ( "offsetX" . to_string ( ) , generate_expr_by_length ! ( offset_x, Platform :: Harmony ) ) ) ;
60
+ }
61
+ if let Some ( offset_y) = & self . offset_y {
62
+ props. push ( ( "offsetY" . to_string ( ) , generate_expr_by_length ! ( offset_y, Platform :: Harmony ) ) ) ;
63
+ }
64
+ if let Some ( blur_radius) = & self . blur_radius {
65
+ props. push ( ( "radius" . to_string ( ) , generate_expr_by_length ! ( blur_radius, Platform :: Harmony ) ) ) ;
66
+ }
67
+ if let Some ( color) = & self . color {
68
+ props. push ( ( "color" . to_string ( ) , generate_string_by_css_color ! ( color) ) ) ;
69
+ }
70
+ if let Some ( inset) = & self . inset {
71
+ props. push ( ( "fill" . to_string ( ) , generate_expr_lit_bool ! ( * inset) ) ) ;
72
+ }
73
+
74
+ let object_list_props = props. into_iter ( ) . map ( |( a, b) | {
75
+ PropOrSpread :: Prop ( Box :: new ( Prop :: KeyValue (
76
+ KeyValueProp {
77
+ key : generate_prop_name ! ( a) ,
78
+ value : Box :: new ( b) ,
79
+ }
80
+ ) ) )
81
+ } ) . collect :: < Vec < PropOrSpread > > ( ) ;
82
+
83
+
84
+
55
85
PropertyTuple :: One (
56
86
"boxShadow" . to_string ( ) ,
57
87
Expr :: Object ( ObjectLit {
58
88
span : DUMMY_SP ,
59
- props : vec ! [
60
- PropOrSpread :: Prop ( Box :: new( Prop :: KeyValue (
61
- KeyValueProp {
62
- key: generate_prop_name!( "radius" ) ,
63
- value: Box :: new( generate_expr_by_length!( self . offset_x. as_ref( ) . unwrap( ) , Platform :: Harmony ) ) ,
64
- }
65
- ) ) ) ,
66
- PropOrSpread :: Prop ( Box :: new( Prop :: KeyValue (
67
- KeyValueProp {
68
- key: generate_prop_name!( "color" ) ,
69
- value: Box :: new( generate_string_by_css_color!( self . color. as_ref( ) . unwrap( ) ) ) ,
70
- }
71
- ) ) ) ,
72
- PropOrSpread :: Prop ( Box :: new( Prop :: KeyValue (
73
- KeyValueProp {
74
- key: generate_prop_name!( "offsetX" ) ,
75
- value: Box :: new( generate_expr_by_length!( self . offset_x. as_ref( ) . unwrap( ) , Platform :: Harmony ) ) ,
76
- }
77
- ) ) ) ,
78
- PropOrSpread :: Prop ( Box :: new( Prop :: KeyValue (
79
- KeyValueProp {
80
- key: generate_prop_name!( "offsetY" ) ,
81
- value: Box :: new( generate_expr_by_length!( self . offset_y. as_ref( ) . unwrap( ) , Platform :: Harmony ) ) ,
82
- }
83
- ) ) ) ,
84
- PropOrSpread :: Prop ( Box :: new( Prop :: KeyValue (
85
- KeyValueProp {
86
- key: generate_prop_name!( "fill" ) ,
87
- value: Box :: new( generate_expr_lit_bool!( self . inset. unwrap( ) ) ) ,
88
- }
89
- ) ) ) ,
90
- ]
89
+ props : object_list_props
91
90
} )
92
91
)
93
92
}
0 commit comments