11import { type Color as CuloriColor , modeLrgb , type Rgb , useMode , wcagLuminance } from "culori/fn" ;
22import { Color , Gradient , Shadow , StyleProperty } from "@adaptive-web/adaptive-ui" ;
33import { AppliedStyleValues , Controller , focusIndicatorNodeName , PluginNode , State , StatesState , STYLE_REMOVE } from "@adaptive-web/adaptive-ui-designer-core" ;
4- import { canHaveChildren , canHaveIndividualStrokes , colorToRgb , colorToRgba , isContainerNode , isInstanceNode , isLineNode , isRectangleNode , isShapeNode , isTextNode , isVectorNode , SOLID_BLACK , SOLID_TRANSPARENT , variantBooleanHelper } from "./utility.js" ;
4+ import { canHaveChildren , canHaveIndividualStrokes , colorToRgb , colorToRgba , isContainerNode , isInstanceNode , isLayoutNode , isLineNode , isRectangleNode , isShapeNode , isTextNode , isVectorNode , SOLID_BLACK , SOLID_TRANSPARENT , variantBooleanHelper } from "./utility.js" ;
55import { gradientToGradientPaint } from "./gradient.js" ;
66import { PluginDataResolver } from "./plugin-data-resolver.js" ;
77
@@ -79,6 +79,7 @@ export class FigmaPluginNode extends PluginNode {
7979 this . _componentAppliedDesignTokens = this . _refNode . appliedDesignTokens ;
8080 }
8181
82+ this . config = JSON . parse ( PluginNode . pluginDataAccessor . getPluginData ( this , "config" ) || "{}" ) ;
8283 this . _localDesignTokens = await PluginNode . pluginDataAccessor . getLocalDesignTokens ( this ) ;
8384 this . _appliedStyleModules = await PluginNode . pluginDataAccessor . getAppliedStyleModules ( this ) ;
8485 this . _appliedDesignTokens = await PluginNode . pluginDataAccessor . getAppliedDesignTokens ( this ) ;
@@ -447,6 +448,14 @@ export class FigmaPluginNode extends PluginNode {
447448 }
448449 }
449450
451+ private handleSize ( values : AppliedStyleValues ) {
452+ if ( isLayoutNode ( this . _node ) ) {
453+ const width = this . safeNumber ( values . get ( StyleProperty . width ) ?. value ) || this . _node . width ;
454+ const height = this . safeNumber ( values . get ( StyleProperty . height ) ?. value ) || this . _node . height ;
455+ ( this . _node ) . resize ( width , height ) ;
456+ }
457+ }
458+
450459 protected safeNumber ( value : string , defaultValue : number = 0 ) {
451460 return value === STYLE_REMOVE ? defaultValue : Number . parseFloat ( value ) ;
452461 }
@@ -457,6 +466,8 @@ export class FigmaPluginNode extends PluginNode {
457466
458467 this . handleStroke ( values ) ;
459468
469+ this . handleSize ( values ) ;
470+
460471 // Paint all applied design tokens on the node
461472 for ( const [ target , styleValue ] of values ) {
462473 // console.log("applied design token eval", target, applied);
@@ -571,6 +582,10 @@ export class FigmaPluginNode extends PluginNode {
571582 ( this . _node as BaseFrameMixin ) . itemSpacing = this . safeNumber ( value ) ; // Removes unit, so assumes px
572583 }
573584 break ;
585+ case StyleProperty . height :
586+ case StyleProperty . width :
587+ // Ignore, handled in handleSize.
588+ break ;
574589 case StyleProperty . shadow :
575590 {
576591 const shadows : Shadow [ ] = Array . isArray ( value ) ? value : [ value ] ;
@@ -592,6 +607,7 @@ export class FigmaPluginNode extends PluginNode {
592607 }
593608 break ;
594609 default :
610+ console . error ( `Applied design token could not be painted for ${ target } :` , JSON . stringify ( value ) , this . debugInfo ) ;
595611 throw new Error ( `Applied design token could not be painted for ${ target } : ${ JSON . stringify ( value ) } ` ) ;
596612 }
597613 }
0 commit comments