Open mimarz opened 1 month ago
This needs to be done after #2287
@mimarz & @Febakke Here's my step-by-step plan to implement this, based on my existing proof of concept. If this seems okay, should I add these as separate issues and add them to the board, or is it enough to track it here?
[x] cli: Refactor build script for easier extension with new modes
[x] css/cli/themes: Output only global and semantic color variables
[x] ~css/cli/themes: Output only semantic size/space/radius variables~ ~#2642~ Doing this the "easy way" (references: false) has some issues, and it is not necessary for the rest to work, so we leave it out for now
[x] tokens: Add tokens and Tokens Studio themes for main-color
and support-color
, but without using them anywhere. The structure will be
[accent]
[brand1, brand2, brand3]
Colors in semantic/colors.json
remain the same, and CLI build output is unchanged.
[x] cli: Implement data-color
, which combines colors from main
and support
, and the individual neutral/success/warning/danger
colors.
[x] css/react:
data-color
in components that already had a color
prop (no implicit color inheritance yet)"accent"
, since we won't require a color named "accent"
in the future. This should be done without changing the default of components that currently default to "neutral"
(or other built-in colors)data-color
in components that currently use accent
and don't have a color
prop, so they can be changed.
[ ] Figma: Replace color props in Figma component variants with the combination of color: main | support
and setting the correct mode
[x] cli/theme-builder: Implement support for specifying your own color names and number of colors per color category. This will require some changes in the theme builder under the hood, but the GUI will remain the same for now.
Example: my-theme.json
{
"colors": {
"main": {
"dominant": "#303030",
"complimentary": "#BED5E8",
"accent": "#76C69D"
},
"support": {
"alt1": "#B9D9C8",
"alt2": "#BAC6D8",
"alt3": "#E5CEAE"
}
}
}
CLI:
npx @digdir/designsystemet tokens create --json my-theme.json
[ ] theme-builder: Implement UI for configuring your own color names and number of colors per category
After demo today we suggest the following.
neutral
color for this system to work.data-color
does not override global colors such as info
, warning
, success
and danger
subtle
variant should be used. Currently only Card
& Accordion
neutral
color instead of "default" color.data-color
as the portal element is put outside somewhere else in the dom-tree (usually on body)Figma testing with @unekinn
Color scales that will be included as Figma variables
Two new modes
Obs
We need to document that if users use the color scales from semantic that are used in main and support directly they might have issues if the change names later. For instance if you set background color to primary-background
instead of main-background
. We have experienced that Token Studio might not always be able to make Figma understand that they are the same scales. The consequence is dead token references in Figma
Figma tasks
next
branch now
TLDR; Lift semantic color definition to a higher level and have components only use a generic
--ds-color-*
variable. Which semantic color i used for a component is then defined by the user using data-attributes ([data-color="accent|neutral|my-color"]
). Users are free to add any number of colors and name them accordingly to their semantic needs.Example code
WIP Notes
data-ds-color-scheme
) to change which color scale the color variables are pointing to.--ds-color-accent-*
which works like this, but might be hard to rename to--ds-color-*
because of mapping to Figma variables.data-ds-color-mode
, which users can use to switch betweendark | light | auto