Style-dictionary: Feature Request / new formats: unitless line-heights, css/var-deep

Created on 7 Mar 2020  路  5Comments  路  Source: amzn/style-dictionary

I know you're trying to limit new formats, so you can stop here and close the issue if you don't want them...

I wrote a few quick formats for myself that I thought would be useful to share if people want them. If wanted I can work on an MR to pass them along.

Unitless Line Heights (when both values are provided from design in absolute units)
This works better with the object transform step I filed to dynamically add the "base-font-size"

{
  "typography": {
    "xxs": {
      "title1": {
        "size": { "value": 21, "attributes": { "category": "size" } },
        "line-height": { "value": 28, "base-font-size": 21 }
    }
  }
}

css/var/deep
An output like this allows the consuming application to adjust the theme on the fly.

:root {
  --kite-color-base-blue-20: #0073d1;
  --kite-color-primary: var(--kite-color-base-blue-20);
  --kite-border-color-primary: var(--kite-color-primary);
  --kite-button-primary-background-color: var(--kite-color-primary);
}

Most helpful comment

@chazzmoney, is it cool to share a link here? If not, please feel free to yell at me.

@fredriklind, I've pushed the code into a forked repo that I use for contributing. It's in this folder: https://github.com/tonyjwalt/style-dictionary/tree/feature/cssVarDeep/examples/custom-formats

Please note that I've only written about half of the unit test; so there may be use cases it doesn't support yet.

All 5 comments

@tonyjwalt Cold you share the css/var/deep format? I need something similar and haven't figured out how to do it yet.

@chazzmoney, is it cool to share a link here? If not, please feel free to yell at me.

@fredriklind, I've pushed the code into a forked repo that I use for contributing. It's in this folder: https://github.com/tonyjwalt/style-dictionary/tree/feature/cssVarDeep/examples/custom-formats

Please note that I've only written about half of the unit test; so there may be use cases it doesn't support yet.

@tonyjwalt This is great stuff!

Would like to see about adding them. Can you submit a PR for each format separately? That way we can examine each individually.

I know we've been weird about too many formats because we have concerns about being able to maintain them... but I think some of what you are doing is becoming mainstream these days and is missing. A PR provides a nice space for us to discuss.

I created one for CSS Var Deep. I figured it'd be best to start a conversation there. It has extra support for CSS variables flat, supports quoted and unquoted string data-types, and splitting out dark mode tokens. I can totally rip that out if it makes things easier. Take a look, let me know, and I'll go from there.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chazzmoney picture chazzmoney  路  5Comments

gael-boyenval picture gael-boyenval  路  3Comments

chazzmoney picture chazzmoney  路  4Comments

dbanksdesign picture dbanksdesign  路  3Comments

tlouisse picture tlouisse  路  4Comments