77 htmlBlendMode ,
88} from "./builderImpl/htmlBlend" ;
99import {
10+ buildBackgroundValues ,
1011 htmlColorFromFills ,
11- htmlGradientFromFills ,
1212} from "./builderImpl/htmlColor" ;
1313import { htmlPadding } from "./builderImpl/htmlPadding" ;
1414import { htmlSizePartial } from "./builderImpl/htmlSize" ;
@@ -31,7 +31,6 @@ import { HTMLSettings } from "types";
3131import {
3232 cssCollection ,
3333 generateUniqueClassName ,
34- getSvelteClassName ,
3534 stylesToCSS ,
3635} from "./htmlMain" ;
3736
@@ -122,12 +121,6 @@ export class HtmlDefaultBuilder {
122121 this . autoLayoutPadding ( ) ;
123122 this . position ( ) ;
124123 this . blend ( ) ;
125-
126- // Add z-index if we have a custom value from the itemReverseZIndex handling
127- if ( ( this . node as any ) . customZIndex !== undefined ) {
128- this . addStyles ( `z-index: ${ ( this . node as any ) . customZIndex } ` ) ;
129- }
130-
131124 return this ;
132125 }
133126
@@ -229,8 +222,11 @@ export class HtmlDefaultBuilder {
229222
230223 position ( ) : this {
231224 const { node, optimizeLayout, isJSX } = this ;
232- if ( commonIsAbsolutePosition ( node , optimizeLayout ) ) {
225+ const isAbsolutePosition = commonIsAbsolutePosition ( node , optimizeLayout ) ;
226+ console . log ( "isAbsolutePosition" , isAbsolutePosition , "for node" , node ) ;
227+ if ( isAbsolutePosition ) {
233228 const { x, y } = getCommonPositionValue ( node ) ;
229+ console . log ( "x, y, are" , x , y ) ;
234230
235231 this . addStyles (
236232 formatWithJSX ( "left" , isJSX , x ) ,
@@ -267,44 +263,39 @@ export class HtmlDefaultBuilder {
267263 return this ;
268264 }
269265
270- const backgroundValues = this . buildBackgroundValues ( paintArray ) ;
266+ const backgroundValues = buildBackgroundValues ( paintArray , this . settings ) ;
271267 if ( backgroundValues ) {
272268 this . addStyles ( formatWithJSX ( "background" , this . isJSX , backgroundValues ) ) ;
269+
270+ // Add blend mode property if multiple fills exist with different blend modes
271+ if ( paintArray !== figma . mixed ) {
272+ const blendModes = this . buildBackgroundBlendModes ( paintArray ) ;
273+ if ( blendModes ) {
274+ this . addStyles (
275+ formatWithJSX ( "background-blend-mode" , this . isJSX , blendModes ) ,
276+ ) ;
277+ }
278+ }
273279 }
274280
275281 return this ;
276282 }
277283
278- buildBackgroundValues (
279- paintArray : ReadonlyArray < Paint > | PluginAPI [ "mixed" ] ,
280- ) : string {
281- if ( paintArray === figma . mixed ) {
284+ buildBackgroundBlendModes ( paintArray : ReadonlyArray < Paint > ) : string {
285+ if ( paintArray . length === 0 ) {
282286 return "" ;
283287 }
284288
285- // If one fill and it's a solid, return the solid RGB color
286- if ( paintArray . length === 1 && paintArray [ 0 ] . type === "SOLID" ) {
287- return htmlColorFromFills ( paintArray , this . settings ) ;
288- }
289-
290- // If multiple fills, deal with gradients and convert solid colors to a "dumb" linear-gradient
291- const styles = paintArray . map ( ( paint ) => {
292- if ( paint . type === "SOLID" ) {
293- const color = htmlColorFromFills ( [ paint ] , this . settings ) ;
294- return `linear-gradient(0deg, ${ color } 0%, ${ color } 100%)` ;
295- } else if (
296- paint . type === "GRADIENT_LINEAR" ||
297- paint . type === "GRADIENT_RADIAL" ||
298- paint . type === "GRADIENT_ANGULAR" ||
299- paint . type === "GRADIENT_DIAMOND"
300- ) {
301- return htmlGradientFromFills ( paint ) ;
289+ // Reverse the array to match the background order
290+ const blendModes = [ ...paintArray ] . reverse ( ) . map ( ( paint ) => {
291+ if ( paint . blendMode === "PASS_THROUGH" ) {
292+ return "normal" ;
302293 }
303294
304- return "" ; // Handle other paint types safely
295+ return paint . blendMode ?. toLowerCase ( ) ;
305296 } ) ;
306297
307- return styles . filter ( ( value ) => value !== "" ) . join ( ", " ) ;
298+ return blendModes . join ( ", " ) ;
308299 }
309300
310301 shadow ( ) : this {
@@ -374,7 +365,7 @@ export class HtmlDefaultBuilder {
374365 formatWithJSX (
375366 "filter" ,
376367 this . isJSX ,
377- `blur(${ numberToFixedString ( blur . radius ) } px)` ,
368+ `blur(${ numberToFixedString ( blur . radius / 2 ) } px)` ,
378369 ) ,
379370 ) ;
380371 }
@@ -387,7 +378,7 @@ export class HtmlDefaultBuilder {
387378 formatWithJSX (
388379 "backdrop-filter" ,
389380 this . isJSX ,
390- `blur(${ numberToFixedString ( backgroundBlur . radius ) } px)` ,
381+ `blur(${ numberToFixedString ( backgroundBlur . radius / 2 ) } px)` ,
391382 ) ,
392383 ) ;
393384 }
0 commit comments