figma / code-snippet-editor-plugin

Translate component variants, properties, and more into dynamic code snippets for your design system.
https://www.figma.com/community/plugin/1311777988952403297/code-snippet-editor
MIT License
126 stars 11 forks source link

Textbox height/width, hug/fill inside frames/components #52

Closed mikeysouthwell closed 3 months ago

mikeysouthwell commented 3 months ago

Hi Jake,

How do I get it so that my textbox parameters show up for textboxes that are inside frames/components?

Currently I have this as a separate field:


"TEXT": [
      {
        "title": "MAUI",
        "language": "JAVASCRIPT",
        "code": "<Typography\\\nvariant=\"{{node.textStyle}}\"\\\n{{!node.textStyle}}variant=\"unknown\"\\\n\\>{{node.characters|raw}}</Typography>"
      }
    ]
jake-figma commented 3 months ago

maybe i am misunderstanding, but if youre trying to see the text node code when you select a parent, the parent templates need to do figma.children like we've been discussing elsewhere (#50) with the same title, language. the parent component needs a template that specifies where children should render. if the text node is a grandchild youll have to do what is discussed in #50 and have the child node also have a template on it.

if youre trying to refer to child properties on the parent template (or vice versa, parent properties in the child template), that isnt supported.

mikeysouthwell commented 3 months ago

I tried adding this same code to my frame and component types to show the text of the children, but it didn't work. Is it working for you?

mikeysouthwell commented 3 months ago

I think I managed to get it to work now. This is what I ended up with so far:


"TEXT": [
          {
            "title": "MAUI",
            "language": "JAVASCRIPT",
            "code": "<Label\nStyle=\"{StaticResource {{node.textStyle}}}\"\nTextColor=\"{StaticResource {{variables.fills}}}\"\nHorizontalTextAlignment=\"{{css.textAlign|pascal}}\"\n{{?css.flex=1 0 0}}HorizontalOptions=\"Fill\"\nText=\"{{node.characters|raw}}\"></Label>"
          }
        ]
mikeysouthwell commented 3 months ago

This gives me something like this:


<Label
Style="{StaticResource inter-16-inter-semibold-16-l-s160}"
TextColor="{StaticResource text-button-white}"
HorizontalOptions="Fill"
Text="Continue with Email"></Label>