GithubHelp home page GithubHelp logo

lukasoppermann / design-token-transformer Goto Github PK

View Code? Open in Web Editor NEW
150.0 150.0 216.0 2.51 MB

Base repo to transform json design tokens from the figma design token plugin via amazon style dictionary.

License: MIT License

TypeScript 41.12% JavaScript 35.49% CSS 6.53% Swift 1.64% Objective-C 2.75% Less 6.23% SCSS 6.23%

design-token-transformer's Issues

build directory less and scss builds contain multiple [object object] lines

I'm new to Design Token and Amazon Style Dictionary so I may be pointing out something known but the less and scss builds in the build directory contains multiple [object object] entries, for example:

$spacing-10: [object Object];
$spacing-mixed: [object Object];
$spacing-top: [object Object];
$borders-single: [object Object];
$borders-dashed-outside: [object Object];
$borders-single-style: [object Object];

I have seen this issue mentioned over the last couple of days while reading documentation, I think it relates to Style Dictionary. There is an issue here in which the post by jam-awake appears to identify the cause and solution in case it helps.

Unable to receive the commit message in GitHub's pull request.

I have forked this repository for my use.
I want to receive the commit message in GitHub's pull request.

Although I have commit messages, the commit message in GitHub's pull request always appears as "Tokens updated."
I understand the cause. refer: https://github.com/lukasoppermann/design-token-transformer/blob/main/.github/workflows/transform-tokens.yml#L46

I would like to set the commit message in the following section if a commit message is received through the request body.
Like this.

commit-message: ${{ github.event.client_payload.commitMessage || 'Tokens updated' }}

The setting

スクリーンショット 2023-08-18 11 28 03

Support nested variable transformation ([object Object])

First and foremost, thanks for building this great tool!

I recognized that with the the exported text and effect styles as objects, the css variable generation is kinda broken or doesn't resolve properly wit nested key-value pairs because the nested properties aren't recognized and transformed to it's own value.

For example:

--font-headline-2x-large: [object Object];
--font-headline-x-large: [object Object];
--font-headline-large: [object Object];
--font-headline-medium: [object Object];
--font-headline-small: [object Object];
--font-headline-x-small: [object Object];
--font-copy-large: [object Object];
--font-copy-medium: [object Object];
--font-copy-x-small: [object Object];
--font-copy-small: [object Object];
--font-label-medium: [object Object];
--font-label-small: [object Object];
--font-button-medium: [object Object];
--font-button-small: [object Object];
--effect-focus-inner-default-0: [object Object];
--effect-focus-inner-default-1: [object Object];
--effect-focus-outside-default-0: [object Object];
--effect-focus-outside-default-1: [object Object];
--effect-focus-outside-input: [object Object];
--effect-shadow-bottom-400: [object Object];
--effect-shadow-bottom-800: [object Object];
--effect-shadow-right-400: [object Object];

The solution:
Having the text style for example --font-headline-2x-large as prefix and add the nested property fontSize as font-size or something similar to generate also the nested key value pairs as variables as --font-headline-2x-large-font-size. Same would work for the other generated tokens such as less and scss.

What do you think bout this improvement? Is this possible to implement as the standard configuration?
Thanks for your effort! :)

npm run transform-tokens cant find "global" form figma plugin export

"Reference doesn't exist: global.color.primary-base.value tries to reference brand.accenture.primary-base, which is not defined"

Once the figma Plugin creates this "Global" key, the token-transformer can't find it, I'm including it manually

image

to this:

image

{
  "global": {
    "brand": {
      "accenture": {
        "primary-base": {
          "value": "#A100FF",
          "type": "color",
          "description": "Base Accenture Color"
        },
        "secondary": {
          "value": "#0041F0",
          "type": "color"
        }
      }
    },
    "color": {
      "primary-base": {
        "value": "{brand.accenture.primary-base}",
        "type": "color"
      }
    },
    "black": {
      "12": {
        "value": "rgba(0,0,0,0.12)",
        "type": "color"
      },
      "25": {
        "value": "rgba(0,0,0,0.25)",
        "type": "color"
      },
      "50": {
        "value": "rgba(0,0,0,0.5)",
        "type": "color"
      },
      "85": {
        "value": "rgba(0,0,0,0.85)",
        "type": "color"
      },
      "100": {
        "value": "#000",
        "type": "color"
      }
    }
  },
  "font": {},
  "$themes": [],
  "$metadata": {
    "tokenSetOrder": [
      "global",
      "font"
    ]
  }
}

No android output for this file

Using this file as input, I expect to see an Android build output with colors for Android, like there is for ios and ios-swift.
Ideally I would like Android Jetpack Compose compatible files, but xml is fine, too.

But no android folder is created when following the readme.

  • Export my colors from figma
  • place the file in ./token/, overwriting the sample file
  • npm run transform-tokens

When I then run the android task, it says it cannot find inputs for colors

 node ./examples/android/build.js

android
No properties for values/font_styles.xml. File not created.
No properties for values/dimens.xml. File not created.
No properties for values/colors.xml. File not created.
No properties for values-night/colors.xml. File not created.
Copying ./examples/android/filesToCopy/font_family.xml to ./examples/build/android/font/font_family.xml

Now the android folder is created, but as the cli output hints at, its only the template font file that gets created

File used:

design-tokens.tokens.json

rgba values becomes #0000000

When I run with values like the image:

image

The output json becomes like this:

image

Is this a known issue? Any ideas on how to fix?

Resolve References using Style Dictionary

Hello there, Thanks for this Great Library

Please any idea of how to resolve references ?

{
    "global": {
      "hello-pink": {
        "50": {
          "value": "#fge7ee",
          "type": "color"
        },
      },
      "white": {
        "value": "#ffffff",
        "type": "color"
      }
    },
    "Light": {
      "bg": {
        "default": {
          "value": "{white}",
          "type": "color",
          "description": "Default background color for the whole app."
        },
      },
      }
    }
  }

Here is the error i get

scss

Property Reference Errors:
Reference doesn't exist: Light.bg.default.value tries to reference white, which is not defined

Style Dictionary 4

Hi Lukas, just wondering if you aware that the folks from Figma have seemed to join forces with Danny Banks to work on v4. Looks like some good progress is being made. Anyway, if you are not involved, thought you might be interested. It seems to me that some of your work with your transformer could be used in the W3C compatibility aspects that they plan to bake in. Here are some links:

[Question]: Figma local variables

Hey,
I'm playing with your plugin and realised that there is no output for local variables from transformer.
Do you have such support? Maybe I'm doing something wrong

JSON file from plugin:

  "color": {
    "u-p1": {
      "263238": {
        "description": "\"Black\"",
        "type": "color",
        "value": "#263238ff",
        "blendMode": "normal",
        "extensions": {
          "org.lukasoppermann.figmaDesignTokens": {
            "styleId": "S:8534522e8bed2ead25c21d3ac971217b6e92c40b,",
            "exportKey": "color"
          }
        }
      }
    }
  },
  "primitives": {
    "color": {
      "type": "color",
      "value": "#ffffff"
      "grayscale-01": {
        "type": "color",
        "value": "#fafafaff",
        "blendMode": "normal",
        "extensions": {
          "org.lukasoppermann.figmaDesignTokens": {
            "mode": "Mode 1",
            "collection": "Primitives",
            "scopes": ["ALL_SCOPES"],
            "variableId": "VariableID:15:146",
            "exportKey": "variables"
          }
        }
      },
      "type": "color",
      "value": "#ffffffff",
      "blendMode": "normal",
      "extensions": {
        "org.lukasoppermann.figmaDesignTokens": {
          "mode": "Mode 1",
          "collection": "Primitives",
          "scopes": ["ALL_SCOPES"],
          "variableId": "VariableID:2024:149",
          "exportKey": "variables"
        }
      }
    }
  }
}

Output from transformer:

:root {
  --color-u-p1-263238: rgb(38, 50, 56);
}

Plugin is great! Any help is welcomed.
Thanks!

Question - How to produce fontFamilies?

Hi, just a question:
Seeing that the webFont.js file seems to recognized that there could be plural fontFamilies. But how does one get this out of figma and the Design Tokens plugin? I can only get the singular form.

Thanks!

422 Error sending tokens to url

I want to use the "Send design tokens to url" feature to export the variables, color, text styles and effects from my figma file. When I check "variables" I get a 422 error:
image 1
image
If I uncheck the "variables (beta)" option everything works fine. The JSON file download works fine too, only issue is when I try to export it. I have recreated a separate figma file with similar variable config and to my surprise the "Send design tokens to url" feature works fine. I suspect there is some issue with my file or variables that I have in this file.
design-tokensjson.txt

I am attaching the downloaded json.

Any idea how I can begin to debug this ? "the console doesn't provide any useful info to begin debugging this" failed to load resource: the server responded with a status of 422 ()

Flutter support

Hi,

First, thanks a lot for these great tools!

I just wanted to share a set of custom transformers I did for my own needs with Flutter, which could be interesting to improve your official transformer package.

Everything is available here : style-dictionary-figma-flutter.

It basically outputs tokens as a Flutter theme widget with a few helpers.

I also added a custom-icon type to export vector paths from Figma too (I made a custom plugin that clones my icon frames, flattens them as a single path, and then exports it as json).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.