Git Product home page Git Product logo

design-tokens-cli's People

Contributors

heydon avatar robphoenix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

design-tokens-cli's Issues

Changed ordering of output values from input

My input is a design.tokens.json file:

{   "tiny": { "$value": "8px" },
    "small": { "$value": "16px" },
    "medium": { "$value": "24px" },
    "large": { "$value": "32px" },
    "xlarge": { "$value": "40px" },
    "error": { "$value": "red" },
    "success": { "$value": "green" },
    "warning": { "$value": "yellow" },
    "radius": { "$value": "3px" }
}

The CSS output is:

:root {
 	--error: red;
 	--large: 32px;
 	--medium: 24px;
 	--radius: 3px;
 	--small: 16px;
 	--success: green;
 	--tiny: 8px;
 	--warning: yellow;
 	--xlarge: 40px;
}

The CSS variables are no longer in a logical order: colors are not shown together and the spacings are no longer sequential. This makes it harder to read through and make sense of the variables in the output file.

Configurability of prefixes

It would be nice if it was possible to control the prefixes that get added to the output variables. I am grouping my tokens primarily because I don't want to add a $type to every individual property so instead do it at the group level:

{   "colors": {
    "$description": "Color palette",
    "$type": "color",
    "error": { "$value": "red" },
    "success": { "$value": "green" },
    "warning": { "$value": "yellow" } 
},
    "sizes": {
        "$type": "dimension",
        "radius": { "$value": "3px" },
        "tiny": { "$value": "8px" },
        "small": { "$value": "16px" },
        "medium": { "$value": "24px" },
        "large": { "$value": "32px" },
        "xlarge": { "$value": "40px" }
    }
}

However, I do not want the output variables to have any prefixes. I prefer to use a terse variable name in my code e.g. var(--small) over var(--sizes-small). Most of the names are descriptive enough by themselves e.g. var(--red) is obviously a color. I don't see much point in the extra verbiage.

globalPrefix undefined

Hi! I came across this repository today and I'm tinkering around with it and it's pretty awesome!

I've found one small issue so far:
If no globalPrefix is added to the config, tokens are generated with undefined- ahead of them.

Support references

  • Will probably need to combine all transformations into one flattened JSON file first
  • Then will need to convert the reference into the transformed key/name and use it like tokens[converted reference]
  • Will need to handle the fact that some references might be b.c whereas the token name is a.b.c (more specific)

Keeping references

Currently, references are resolved by finding and applying the true value.

{
  "token-1": "#fff",
  "token-2": "{ token.1 }"
}

...results in this Sass:

$token-1: #fff;
$token-2: #fff;

But it should be possible to just convert the reference:

$token-1: #fff;
$token-2: $token-1;

The difficulty comes in working out when the order needs changing and how. For CSS custom properties, this isn't an issue because of hoisting. But the following...

{
  "token-1": "{ token.2 }"
  "token-2": "#fff",
}

would break the Sass output (Error: undefined variable):

$token-1: $token-2;
$token-2: #fff;

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.