Page MenuHomePhabricator

Ensure exported tokens contain only values, not calculations
Closed, InvalidPublic5 Estimated Story Points

Description

There were two tokens in Wikit that perform a division in the token's value field. This caused some log spam in the query builder build step due to a difference in SASS versions with a change in the division syntax. Ideally we want this division (or any expression or arithmetic function) to be calculated during the build step to maximize compatibility.

Unfortunately it looks like style-dictionary does not intend to ever support this, so we need to figure out a different way to deal with it. The suggested solution appears to be calculating the value in JS, but this might be more difficult with values that contain units.

Acceptance Criteria: 🏕️🌟(July 2021)

  • All build artifacts of @wmde/wikit-tokens contain only values for all tokens (instead of calculations), when there are expressions in the token definition.
  • Tests or linting to ensure that no calculations are present
  • There is a clear and documented way to do simple token arithmetic for wikit-tokens

Event Timeline

Lucas_Werkmeister_WMDE renamed this task from Ensure exported tokens contain only absolute values to Ensure exported tokens contain only values, not calculations.Jul 27 2021, 10:25 AM

There are currently two tokens in Wikit that perform a division in the token's value field.

https://github.com/wmde/wikit/pull/455 removed those, but the underlying issue is still valid.

There are currently two tokens in Wikit that perform a division in the token's value field.

https://github.com/wmde/wikit/pull/455 removed those, but the underlying issue is still valid.

So is the first AC already done?

All build artifacts of @wmde/wikit-tokens contain only values for all tokens (instead of calculations)

In story time we removed

There is a clear and documented way to do simple token arithmetic for wikit-tokens

So as not to document something that would not currently be used or needed.
Instead we would opt for creating a new ticket for this, or just figuring it out when we come to do this again

Addshore set the point value for this task to 5.Sep 22 2021, 10:47 AM

There are currently two tokens in Wikit that perform a division in the token's value field.

https://github.com/wmde/wikit/pull/455 removed those, but the underlying issue is still valid.

So is the first AC already done?

All build artifacts of @wmde/wikit-tokens contain only values for all tokens (instead of calculations)

No, the task is to figure out how to use expressions within the definition of tokens that get compiled to values (instead of the current situation where they don't get compiled and just appear as expressions in the output token format).
Perhaps the AC can be expressed better.

I’m not sure I understand the issue. As far as I can tell, there currently aren’t any expressions left – all the values that reference other values without just copying a single value look like value lists, not expressions:

$ grep '"value":.*{' tokens/dist/index.json | grep -v '"{[^}]*}"'
            "value": "{box-shadow.inset.style.thin.value} {color.accent.50.value}"
            "value": "{box-shadow.inset.style.thin.value} {color.utility.red.50.value}"
            "value": "{box-shadow.inset.style.thin.value} {color.utility.red.50.value}"
            "value": "{box-shadow.inset.style.thin.value} {color.utility.yellow.30.value}"
            "value": "{box-shadow.inset.style.thick.value} {color.base.100.value}"
            "value": "{transition.property.color.value}, {transition.property.background-color.value}, {transition.property.border-color.value}, {transition.property.box-shadow.value}"
            "value": "{transition.property.border-color.value}, {transition.property.box-shadow.value}"
            "value": "{transition.property.color.value}, {transition.property.background-color.value}"
            "value": "{transition.property.background-color.value}, {transition.property.border-color.value}, {transition.property.box-shadow.value}"
              "value": "{box-shadow.inset.focus.progressive.value}, {box-shadow.inset.focus.inverted.value}"
              "value": "{box-shadow.inset.focus.destructive.value}, {box-shadow.inset.focus.inverted.value}"
              "value": "{box-shadow.inset.focus.progressive.value}, {box-shadow.inset.focus.inverted.value}"
            "value": "{box-shadow.inset.focus.progressive.value}, {box-shadow.inset.focus.inverted.value}"

Figuring out how to evaluate expressions during compile time is what we removed during story time, since it’s not needed at the moment. The current situation (IIUC) is that there are no expressions within the token definitions, therefore there are no expressions in the output token format either, and the second AC will ensure that it stays this way for now. If we want to use expressions again later, then we’ll have to figure out the compilation step, but not at the moment.

moved back from the campsite board which is going to go away, and popped it at the top of the high prio [DEPRECATED] wdwb-tech column for now

• Sarai-WMDE lowered the priority of this task from Medium to Lowest.Nov 12 2021, 11:51 AM
• Sarai-WMDE subscribed.

The DS Minions team decided to lower the priority of this task to the minimum because there are currently no issues caused by this limitation. There's also not a need to build a solution for WiKit given the unlikely continuity of the project. In any case, though, we should ensure that this
limitation is acknowledged/documented somewhere, as it could be a valuable heads-up for future users of Style dictionary (like Codex).

Relevant issue on GH about calculations in Style dictionary: https://github.com/amzn/style-dictionary/issues/365

ItamarWMDE subscribed.

This is no longer valid as wikit is being deprecated