- From: Ryan Johnson via GitHub <sysbot+gh@w3.org>
- Date: Mon, 06 Jun 2022 22:45:02 +0000
- To: public-design-tokens-log@w3.org
## Idea 1: All JSON properties are group names
1. All JSON properties are considered group names.
2. The presence of a `$value` property is the critical condition for identifying token presence.
* Token _identification_ is based on occurrences of `$value` properties in the JSON hierarchy.
* Token identification should include ALL occurrences of `$value`, not just the first in a path (when resolving top-down).
* A `tokens.json` file will define N tokens, where N is the count of `$value` properties in the file.
* A tokens file with 4 `$value` properties will define 4 tokens.
* Token paths are calculated from the path to a specific `$value` property.
* `foo.bar.$value` resolves to a token path of `foo.bar`
### Example:
```javascript
{
// GROUP: color
"color": {
"$description": "All the colors",
"$type": "color",
// GROUP: color.background
"background": {
"$value": "#eaeaea", // TOKEN: color.background
// GROUP: color.background.highContrast
"highContrast": {
"$value": "#ffffff" // TOKEN: background.highContrast
},
// GROUP: color.background.dark
"dark": {
"$value": "#555555", // TOKEN: color.background.dark
// GROUP: color.background.dark.highContrast
"highContrast": {
"$value": "#000000" // TOKEN: color.background.dark.highContrast
}
},
}
}
}
```
which _should_ resolve to the following, flattened token hierarchy:
```json
{
"color.background": {
"$type": "color",
"$value": "#eaeaea"
},
"color.background.highContrast": {
"$type": "color",
"$value": "#ffffff"
},
"color.background.dark": {
"$type": "color",
"$value": "#555555"
},
"color.background.dark.highContrast": {
"$type": "color",
"$value": "#000000"
}
}
```
## Challenges
1. Extraneous properties cannot be easily differentiated from group identifiers.
* For efficiency, you'd only want to traverse deeper if you know you need to.
* Requires traversing EVERY property to identify tokens at all levels.
--
GitHub Notification of comment by CITguy
Please view or discuss this issue at https://github.com/design-tokens/community-group/issues/135#issuecomment-1148006952 using your GitHub account
--
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Monday, 6 June 2022 22:45:04 UTC