Originate / OriginateTheme

OriginateTheme is a lightweight user interface theming framework.
MIT License
5 stars 0 forks source link

Add Reference Mechanics #23

Open pkluz opened 7 years ago

pkluz commented 7 years ago

@chhaylatte @allewun

As a first pre-processing step, OriginateTheme files need reference mechanics. E.g. when declaring a color up top like so:

{
  "colors": {
    "primaryColor": "FFFF00",
    ...
  }
  ...
}

we should be able to reference it further down like so:

{
  ...
  "components": {
    "tabBar": {
      "backgroundColor": "$colors.primary"
    }
  }
}

For this we should write an entirely new script/phase that pre-processes the raw-json file that has the references and spits out a new json file, with all the references resolved and replaced by the actual values. That file is then fed into the existing script.

The variable syntax I'd suggest is: $path.to.targetKey, which'd look for:

{
  "path": {
    "to": {
      "targetKey": "123"
    }
  }
}

For the first iteration I'd suggest disallowing references to references, in order to simplify the parser.

Any comments?