vtex / shoreline

VTEX Design System for back-office experiences. Currently available for internal usage at VTEX.
https://shoreline.vtex.com
23 stars 1 forks source link

[shoreline-css] Generate javascript object from css variables #1771

Open matheusps opened 1 month ago

matheusps commented 1 month ago

Problem

We have multiple files to manage the same theme: tokens.css and preset.ts. The css file is the actual theme, preset is only used for the documentation site.

The main problem of the current solution is having two sources of truth for theming - creating the necessity of changing both for a successful theme change.

Solution

Generate the javascript version from css tokens. For example, the css code:

@theme sunrise {
  :root {
    --color-blue: #0000FF
  }
}

Becomes:

export default {
  colorBlue: '#0000FF'
}

Usage examples

No response

Dependencies

No response

References

matheusps commented 1 month ago

https://github.com/vtex/shoreline/issues/1765