swisspost / design-system

The Swiss Post Design System - for a consistent and accessible user experience across the web platform.
https://design-system.post.ch
Apache License 2.0
126 stars 14 forks source link

Reducing the amount of variables at :root #3372

Open gfellerph opened 3 months ago

gfellerph commented 3 months ago

CSS variables have an impact on performance: https://lisilinhart.info/posts/css-variables-performance/

Especially variables defined at the :root are inherited throughout the whole document and may potentially affect every element. The current implementation relies on the core tokens being defined in this scope. If core tokens would be resolved to their actual values instead of a variable pointing towards the value in the global scope, we could skip shipping core token definitions to the browser. This could only work if the following rules are followed by all actors:

This improvement is specific to the sass output of the token build process.

### Tasks
- [ ] Make the transformer hard code core tokens in the semantic or component layer to avoid having core tokens in the `:root`
Vandapanda commented 3 months ago

Shouldnt be a problem, right now the only links are implemented in borders (which as it stands right now dont have any reason to exist as we cant define what we really want) and in the alphas which havent been used anywhere yet

gfellerph commented 1 month ago

On hold until Cargo is done.