@@ -124,37 +124,41 @@ pub struct BackgroundPosition {
124124
125125impl ToExpr for BackgroundPosition {
126126 fn to_expr ( & self ) -> PropertyTuple {
127- let expr = match self . value . get ( 0 ) . unwrap ( ) {
128- ImagePosition :: ImagePositionXY ( x, y) => Expr :: Object ( ObjectLit {
129- span : DUMMY_SP ,
130- props : vec ! [
131- PropOrSpread :: Prop ( Box :: new( Prop :: KeyValue ( KeyValueProp {
132- key: PropName :: Ident ( Ident :: new( "x" . into( ) , DUMMY_SP ) ) ,
133- value: generate_expr_with_css_input( x. to_string( ) , Platform :: Harmony ) . into( ) ,
134- } ) ) ) ,
135- PropOrSpread :: Prop ( Box :: new( Prop :: KeyValue ( KeyValueProp {
136- key: PropName :: Ident ( Ident :: new( "y" . into( ) , DUMMY_SP ) ) ,
137- value: generate_expr_with_css_input( y. to_string( ) , Platform :: Harmony ) . into( ) ,
138- } ) ) ) ,
139- ]
140- . into ( ) ,
141- } )
142- . into ( ) ,
143- ImagePosition :: TopStart => generate_expr_enum ! ( style_property_enum:: ArkUI_Alignment :: ARKUI_ALIGNMENT_TOP_START ) ,
144- ImagePosition :: Top => generate_expr_enum ! ( style_property_enum:: ArkUI_Alignment :: ARKUI_ALIGNMENT_TOP ) ,
145- ImagePosition :: TopEnd => generate_expr_enum ! ( style_property_enum:: ArkUI_Alignment :: ARKUI_ALIGNMENT_TOP_END ) ,
146- ImagePosition :: Start => generate_expr_enum ! ( style_property_enum:: ArkUI_Alignment :: ARKUI_ALIGNMENT_START ) ,
147- ImagePosition :: Center => generate_expr_enum ! ( style_property_enum:: ArkUI_Alignment :: ARKUI_ALIGNMENT_CENTER ) ,
148- ImagePosition :: End => generate_expr_enum ! ( style_property_enum:: ArkUI_Alignment :: ARKUI_ALIGNMENT_END ) ,
149- ImagePosition :: BottomStart => generate_expr_enum ! ( style_property_enum:: ArkUI_Alignment :: ARKUI_ALIGNMENT_BOTTOM_START ) ,
150- ImagePosition :: Bottom => generate_expr_enum ! ( style_property_enum:: ArkUI_Alignment :: ARKUI_ALIGNMENT_BOTTOM ) ,
151- ImagePosition :: BottomEnd => generate_expr_enum ! ( style_property_enum:: ArkUI_Alignment :: ARKUI_ALIGNMENT_BOTTOM_END ) ,
127+ let property_tuple = match self . value . get ( 0 ) . unwrap ( ) {
128+ ImagePosition :: ImagePositionXY ( x, y) => {
129+ PropertyTuple :: Array ( vec ! [
130+ ( CSSPropertyType :: BackgroundPositionX , generate_expr_with_css_input( x. to_string( ) , Platform :: Harmony ) . into( ) ) ,
131+ ( CSSPropertyType :: BackgroundPositionY , generate_expr_with_css_input( y. to_string( ) , Platform :: Harmony ) . into( ) )
132+ ] )
133+ } ,
134+ position => {
135+ let expr = match position {
136+ ImagePosition :: TopStart => generate_expr_enum ! ( style_property_enum:: ArkUI_Alignment :: ARKUI_ALIGNMENT_TOP_START ) ,
137+ ImagePosition :: Top => generate_expr_enum ! ( style_property_enum:: ArkUI_Alignment :: ARKUI_ALIGNMENT_TOP ) ,
138+ ImagePosition :: TopEnd => generate_expr_enum ! ( style_property_enum:: ArkUI_Alignment :: ARKUI_ALIGNMENT_TOP_END ) ,
139+ ImagePosition :: Start => generate_expr_enum ! ( style_property_enum:: ArkUI_Alignment :: ARKUI_ALIGNMENT_START ) ,
140+ ImagePosition :: Center => generate_expr_enum ! ( style_property_enum:: ArkUI_Alignment :: ARKUI_ALIGNMENT_CENTER ) ,
141+ ImagePosition :: End => generate_expr_enum ! ( style_property_enum:: ArkUI_Alignment :: ARKUI_ALIGNMENT_END ) ,
142+ ImagePosition :: BottomStart => generate_expr_enum ! ( style_property_enum:: ArkUI_Alignment :: ARKUI_ALIGNMENT_BOTTOM_START ) ,
143+ ImagePosition :: Bottom => generate_expr_enum ! ( style_property_enum:: ArkUI_Alignment :: ARKUI_ALIGNMENT_BOTTOM ) ,
144+ ImagePosition :: BottomEnd => generate_expr_enum ! ( style_property_enum:: ArkUI_Alignment :: ARKUI_ALIGNMENT_BOTTOM_END ) ,
145+ _ => unreachable ! ( ) ,
146+ } ;
147+
148+ PropertyTuple :: One (
149+ CSSPropertyType :: BackgroundPosition ,
150+ expr
151+ )
152+ } ,
153+
152154 } ;
153155
154- PropertyTuple :: One (
155- CSSPropertyType :: BackgroundPosition ,
156- expr
157- )
156+ property_tuple
157+
158+ // PropertyTuple::One(
159+ // CSSPropertyType::BackgroundPosition,
160+ // expr
161+ // )
158162 }
159163
160164}
0 commit comments