system-ui.com icon indicating copy to clipboard operation
system-ui.com copied to clipboard

Suggestion for reducing redundancy and arriving toward pure JSON

Open aaronshaf opened this issue 6 years ago • 0 comments

Consider the following example:

colors: {
  blue: '#07c',
  blues: [
    '#004170',
    '#006fbe',
    '#2d8fd5',
    '#5aa7de',
  ]
}

One then has to then assign color names:

theme.colors.blues.regalBlue = theme.colors.blues[0]

But because object literals in JSON and JavaScript are already ordered, one could perhaps use instead:

colors: {
  blue: '#07c',
  blues: {
    regalBlue: '#004170',
    lochmara: '#006fbe',
    curiousBlue: '#2d8fd5',
    havelockBlue: '#5aa7de',
  }
}

Something like styled-system could then transform blues to be available as an array, e.g. blues[0] or blues.0. Keys in JavaScript are already ordered.

It'd be perhaps nice if theme objects could be in JSON? Then we could use a JSON schema to validate theme objects.

aaronshaf avatar Aug 29 '19 16:08 aaronshaf