New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Figma Props --> React Prop Mapping based on a condition NOT working #40
Comments
Hi! Code Connect files are not executed. While they're written using real components from your codebase the Figma CLI essentially treats code snippets as strings. This means that code snippets can display, for example, hooks without needing to mock data. However, this also means that logical operators such as ternaries or conditionals will be output verbatim in your example code rather than executed to show the result. For your use case you could do something like props: {
itemlabel: figma.string("Item label"),
checked: figma.boolean("Checked"),
inValid: figma.enum("State", { "Item Error": true }),
disabled: figma.enum("State", { Disabled: true }),
validationMessage: figma.enum("State", { "Item Error": figma.string("Item error Text") }),
},
<CustomCheckBox
checked={props.checked}
label={props.itemlabel}
inValid={props.inValid}
validationMessage={props.validationMessage}
disabled={props.disabled}
/> Let me know if that helps! |
Thanks for the information. This suggestion works perfect!!! I have another situation that to pass the Figma value in to HTML attribut prop as JSON values. For Ex: The Required boolean from the figma should go part of React HTML prop value. props: { <CustomCheckBox The direct properties mapped the values correctly but the JSON property shows like below. ( required: __ PROP __("required"), <CustomCheckBox Please advice on this use case too as we have many use-case of prop mapping to HTML Attribute JSON props in React. |
Hey @vchandran8! You're right, this isn't supported right now, only the prop value itself can reference |
This will be fixed in the next release @vchandran8 |
This should be fixed in the latest release (0.1.2). Please reopen this issue if the problem persist. |
Hello Team,
Thanks for the excellent tool deployed. It is really helpful.
In our react components, We have use-case where we need to map BOOLEAN or TEXT properly based on FIGMA ENUM Property value conditionally. I see Figma-CodeConnect able to do the mapping one to one for same data type but NOT working conditional mapping.
In the below example, We have certain React component properties (inValid,Validation message,disabled) based on the value from Figma state ENUM property value.
For this code, the Figma Code Connect shows like the below. It has mapped correctly for checked,label property as it is ONE to ONE. But other conditional based mapping not working.
The text was updated successfully, but these errors were encountered: