code-connect icon indicating copy to clipboard operation
code-connect copied to clipboard

Unable to negate figma.boolean

Open cadamsdev opened this issue 11 months ago • 2 comments

figma cli version: 1.3.1

example

figma.connect("<DS_LIST_ROW>", {
  props: {
    removeChevron: figma.boolean("Chevron") === false,
  },
  variant: { Type: 'Chevron' },
  example: ({ removeChevron }) =>
    html`
    <ds-list-row>
      <ds-list-row-chevron
        slot="template"
        remove-chevron=${removeChevron}
      >
      </ds-list-row-chevron>
    </ds-list-row> `,
});

output

        <ds-list-row
            
        >
            <ds-list-row-chevron
                slot="template"
                
                
                heading="Label"
                
                
                
                remove-chevron="figma.boolean(\"Chevron\") === false"
            >
            </ds-list-row-chevron>
        </ds-list-row>

also tried

figma.connect("<DS_LIST_ROW>", {
  props: {
    removeChevron: !figma.boolean("Chevron"),
  },
  variant: { Type: 'Chevron' },
  example: ({ removeChevron }) =>
    html`
    <ds-list-row>
      <ds-list-row-chevron
        slot="template"
        remove-chevron=${removeChevron}
      >
      </ds-list-row-chevron>
    </ds-list-row> `,
});

output

        <ds-list-row
            
        >
            <ds-list-row-chevron
                slot="template"
                
                
                heading="Label"
                
                
                
                remove-chevron="!figma.boolean(\"Chevron\")"
            >
            </ds-list-row-chevron>
        </ds-list-row>

expected output

    <ds-list-row>
      <ds-list-row-chevron
        slot="template"
        remove-chevron
      >
      </ds-list-row-chevron>
    </ds-list-row> 

Is this the correct usage? Or is there a way to negate the boolean?

cadamsdev avatar Mar 04 '25 02:03 cadamsdev

We have a few similar cases in our project. There is the option to map booleans to different types/values:

props: {
  hideIcon: figma.boolean('Icon', {
    false: true,
    true: false,
  }),
}

It reads a bit funny but should lead to your expected snippet output. ☺

lucoel avatar Mar 06 '25 17:03 lucoel

We have a few similar cases in our project. There is the option to map booleans to different types/values:

props: { hideIcon: figma.boolean('Icon', { false: true, true: false, }), } It reads a bit funny but should lead to your expected snippet output. ☺

Perfect thanks! Yeah, that doesn't seem very intuitive.

cadamsdev avatar Mar 08 '25 04:03 cadamsdev