@@ -13,22 +13,39 @@ export const tailwindColorFromFills = (
1313
1414 const fill = retrieveTopFill ( fills ) ;
1515 if ( fill && fill . type === "SOLID" ) {
16- return tailwindSolidColor ( fill , kind ) ;
16+ return tailwindSolidColor ( fill . color , fill . opacity , kind ) ;
17+ } else if (
18+ fill &&
19+ ( fill . type === "GRADIENT_LINEAR" ||
20+ fill . type === "GRADIENT_ANGULAR" ||
21+ fill . type === "GRADIENT_RADIAL" ||
22+ fill . type === "GRADIENT_DIAMOND" )
23+ ) {
24+ if ( fill . gradientStops . length > 0 ) {
25+ return tailwindSolidColor (
26+ fill . gradientStops [ 0 ] . color ,
27+ fill . opacity ,
28+ kind
29+ ) ;
30+ }
1731 }
18-
1932 return "" ;
2033} ;
2134
22- export const tailwindSolidColor = ( fill : SolidPaint , kind : string ) : string => {
23- const opacity = fill . opacity ?? 1.0 ;
24-
35+ export const tailwindSolidColor = (
36+ color : RGB ,
37+ opacity : number | undefined ,
38+ kind : string
39+ ) : string => {
2540 // example: text-opacity-50
2641 // ignore the 100. If opacity was changed, let it be visible.
2742 const opacityProp =
28- opacity !== 1.0 ? `${ kind } -opacity-${ nearestOpacity ( opacity ) } ` : null ;
43+ opacity !== 1.0
44+ ? `${ kind } -opacity-${ nearestOpacity ( opacity ?? 1.0 ) } `
45+ : null ;
2946
3047 // example: text-red-500
31- const colorProp = `${ kind } -${ getTailwindFromFigmaRGB ( fill . color ) } ` ;
48+ const colorProp = `${ kind } -${ getTailwindFromFigmaRGB ( color ) } ` ;
3249
3350 // if fill isn't visible, it shouldn't be painted.
3451 return [ colorProp , opacityProp ] . filter ( ( d ) => d ) . join ( " " ) ;
0 commit comments