community-group icon indicating copy to clipboard operation
community-group copied to clipboard

Are references generally allowed in arrays?

Open lukasoppermann opened this issue 1 year ago • 1 comments

Hey,

so object stroke styles allow references in the dashArray (see https://design-tokens.github.io/community-group/format/#object-value). However, in cubicBeziers, this is not mentioned and also not in the fontFamily array.

I feel this should be clarified in the docs. Either by allowing it, or by defining that references are not allowed for those cases. However, I am wondering why this should be allowed for the dashArray but not other arrays.

lukasoppermann avatar Aug 15 '24 13:08 lukasoppermann

As I understand it, it’s the difference from a primitive type (8.x) vs a composite type (9.x). Primitive types may only alias to their own types. A composite type is made up of multiple primitives, and can either alias to their own type, or alias any of their individual parts (more info). I think cubicBezier and fontFamily were considered a primitive type because they get referenced within composite types (transition and typography, respectively).

My guess is it was considered too complicated to nest number aliases within a cubicBezier within a transition token. But I don’t know that was ever expressed as a concern. Also I’m going off memory, but I think the cubicBezier type predates numbers, which weren’t originally unique token types (which would explain why they don’t allow aliasing). All that said, I think as-written if a cubicBezier could have internal aliases then it would be reclassified as a composite type (9.x). But would that be bad? I personally don’t know of any downsides. Just seems like it would add more utility, like you said. Also, currently composite types can contain nested composite types, as in the case of border being able to alias nested strokeStyle tokens (both of which are composite types).

I also don’t have full context of why there’s a distinction between primitive and composite types, also; someone else may be able to answer that better. As long as we’re not allowing aliases absolutely everywhere (aliasing part of IDs or substrings would be chaotic IMO), I don’t have any downsides off the top of my head of allowing aliases wherever they seem reasonable.

drwpow avatar Aug 15 '24 14:08 drwpow

@lukasoppermann I took a stab at making it explicit in the upcoming update to the aliasing spec that references should be allowed in all instances of a composite type with an array: https://github.com/design-tokens/community-group/pull/298

I think the cubicBezier type is due for a review because of some of the issues @drwpow mentioned, but hopefully the alias update helps with the main issue here.

Let me know what you think!

ilikescience avatar Sep 02 '25 21:09 ilikescience

#298 was accepted! So there is now an official way to use JSON pointers. See the updated preview spec for examples and guidance (warning: this may change slightly in the next couple weeks, but the basic principle will be part of the spec moving forward).

drwpow avatar Oct 19 '25 03:10 drwpow