Re: [community-group] Progressive Token Variant Specificity (#135)

After looking at my proposals, they both feel like a hack to work around the strict syntax imposed by JSON itself.

As-is, a JSON property is overloaded, because it can implicitly be any of the following...

- group name
- token name
- property name

Yet, to accomplish what I'm asking for, the syntax needs to be explicit. Which requires doing one of two things within the limitations of unique JSON properties.

1. Defining special, reserved properties for a "group" object to explicitly define a token at the same path as the group (as proposed above)
2. Defining special syntax for naming properties/keys, such that you can define sibling properties with the same name, but get around the unique key restriction. For example...
    ```javascript
    {
        "color": { // implicit Group
            "token:background": { /* explicit Token (color.background) */ },
            "group:background": { // explicit Group
                "highContrast": { $value: "...", ... }, // implicit Token (color.background.highContrast)
                "token:dark": { /* explicit Token (color.background.dark) */ },
                "group:dark": { // explicit Group
                    "highContrast": { $value: "...", ... } // Implicit Token (color.background.dark.highContrast)
                }
            }
        }
    }
    ```

Unfortunately, neither solution is very intuitive, nor does it feel like the right solution.

-----
Side note... It's because of this that I'm starting to wonder if JSON will be able to keep up with the evolving requirements of the spec. I've been looking into seeing if there are any existing, alternative file formats that would provide the needed flexibility.  Unfortunately, I've not found anything that could be easily adapted, so I'm experimenting with a custom syntax, along with a CLI tool to translate this syntax into universal JSON for input into translation tools. I'll share progress as I can.

-- 
GitHub Notification of comment by CITguy
Please view or discuss this issue at https://github.com/design-tokens/community-group/issues/135#issuecomment-1423539454 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 9 February 2023 02:47:29 UTC