- From: Ryan Johnson via GitHub <sysbot+gh@w3.org>
- Date: Wed, 07 Jun 2023 18:56:20 +0000
- To: public-design-tokens-log@w3.org
I just thought of a solution that would require minimal changes. We know that the problem with progressive token definition is being able to define both a group _and_ token name at the same level in JSON. It doesn't make sense to change the name of groups, because the JSON syntax naturally implies grouping. Instead, it would make more sense to explicitly differentiate a _token_ name using some sort of naming convention. Given that we use dot-path syntax for token alias reference, what if we allow a `.` prefix for JSON props corresponding to token definitions? * The `.` prefix is entirely optional. * Token definitions using the _current_ syntax are still valid. * Downstream tool maintainers _would_ need to add support for the optional `.<token>` syntax. * However, it's much simpler to implement than supporting an entirely new syntax for _both_ tokens _and_ groups. * I'd argue that this might be a reason to need to explicitly specify the schema version in token JSON files, so that tool authors can adjust internal logic based on supported schemas. ### Example ```javascript { "color": { // opt-in syntax, explicit Token (color.background) ".background": { $value, $type, ... }, "background": { // current syntax, implicit Token (color.background.highContrast) "highContrast": { $value, $type, ... }, // opt-in syntax, explicit Token (color.background.dark) ".dark": { $value, $type, ... }, "dark": { // current syntax, implicit Token (color.background.dark.highContrast) "highContrast": { $value: "...", ... } } } } } ``` The above would then parse out 4 tokens... ``` color.background color.background.highContrast color.background.dark color.background.dark.highContrast ``` -- GitHub Notification of comment by CITguy Please view or discuss this issue at https://github.com/design-tokens/community-group/issues/135#issuecomment-1581349448 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Wednesday, 7 June 2023 18:56:22 UTC