Resolve aliases in prop value when it is an object
lancetharper opened this issue · comments
The design token spec says prop values "Can be any valid JSON value" but it looks like aliases don't work if prop values are anything but a string (or at least they don't when value is an object).
Looking at the the resolveAliases
function, it finds the alias in the object that it needs to replace just fine but only attempts a string replace.
Example
# aliases.yml
aliases:
primary-font: Roboto
font-size-lg: 96px
line-height-lg: 106px
# heading.yml
props:
# Works as a string (as expected)
heading-lg-font-family: "{!heading-font-family}"
# Doesn't work as an object
heading-lg:
value:
font-family: "{!heading-font-family}"
font-size: "{!font-size-lg}"
line-height: "{!line-height-lg}"
type: typography # Have a value transform handle this
aliases:
heading-font-family: "{!primary-font}"
global:
category: Heading
imports:
- ./aliases.yml
We could definitely account for that case. I'd just need to make a new function that can recursively resolve aliases on an object/array. Side note, unless you are registering a custom value transform, most templates are just going to output the value as [object Object]
I've just published 7.0.0
which should fix this issue