Skip to content

Suggestion for reducing redundancy and arriving toward pure JSON #4

Open
@aaronshaf

Description

@aaronshaf

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions