MattOndo / figma-tailwindcss-config-generator

Export variables & styles to TailwindCSS 3 or 4 configurations
https://www.figma.com/community/plugin/1372697425539501289/tailwindcss-config-generator-for-flowbite
MIT License
1 stars 1 forks source link

Colors are only NaN #1

Open bodograumann opened 5 months ago

bodograumann commented 5 months ago

Description

I am looking into a way to export Design Tokens from Figma to a tailwind css config. This plugin looks really cool already, but unfortunately it fails to export colors correctly.

Steps to reproduce

Now all the colors are filled with NaN, e.g.:

theme: {
  colors: {
    "bg": {
      01/container: "#NANNANNAN",

Additional context

Another small thing I noticed, not sure if it warrants a separate ticket: Special characters in keys are not replaced / escaped. Same example, the 01/container should be put in quotes and I think the / needs to be replaced with some other character.

Figma Version

Web 2024-05-27

Plugin Version

Latest as of 2024-05-27

Design or Dev Mode?

Both

Please confirm that you have searched existing issues in the repo.

bodograumann commented 5 months ago

I think I have found the cause for issue. When using variables of type COLOR, those might still be aliases. So then .r, .g and .b don't exist. Can we add a dereferencing step?

while (colorStyle.type === 'VARIABLE_ALIAS') {
  colorStyle = figma.variables.getVariableById(colorStyle.id)
}