Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifiers are not removed while overriding variables #1150

Closed
niggeulimann opened this issue Apr 9, 2024 · 3 comments
Closed

Modifiers are not removed while overriding variables #1150

niggeulimann opened this issue Apr 9, 2024 · 3 comments

Comments

@niggeulimann
Copy link

We have a quite huge multi theme setup - we have values for each customer/theme and semantic vars which uses modifiers:
e.g.

{ "test": { "value": "#ffffff", "type": "color", "$extensions": { "studio.tokens": { "modify": { "type": "darken", "value": ".25", "space": "srgb" } } } } }

Some of those customers/themes will override these “default-vars” afterwards e.g.:
"test": { "value": "#ff0000", "type": "color" }
Unfortunately the modifiers are not removed in this case:
The export-script uses the right color #ff000 in this case, but additionally adds the modifier.

see issue in Configurator

@jorenbroekema
Copy link
Collaborator

jorenbroekema commented Apr 9, 2024

Offending code is somewhere in here: https://github.com/amzn/style-dictionary/blob/v4/lib/utils/deepExtend.js

When deep extending objects, we don't seem to take into account that merging:

{
  "test": {
    "value": "#ffffff",
    "type": "color",
    "$extensions": {
      "studio.tokens": {
        "modify": {
          "type": "darken",
          "value": ".25",
          "space": "srgb"
        }
      }
    }
  }
}

with

{
  "test": {
    "value": "#ff0000",
    "type": "color"
  }
}

should result in

{
  "test": {
    "value": "#ff0000",
    "type": "color"
  }
}

and not in

{
  "test": {
    "value": "#ff0000",
    "type": "color",
    "$extensions": {
      "studio.tokens": {
        "modify": {
          "type": "darken",
          "value": ".25",
          "space": "srgb"
        }
      }
    }
  }
}

@niggeulimann
Copy link
Author

Hey @jorenbroekema, thank you a lot!

Is V4 already ready for production?

@jorenbroekema
Copy link
Collaborator

jorenbroekema commented Apr 12, 2024

No its API is not yet stable, still a small amount of things coming that I think will be API breaking. It's a bit tricky to answer because V4 already solves a loooot of issues with V3 so staying on V3 might be more problematic than migrating to unstable V4 and doing another small migration to the final V4 when it releases (estimated in June)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants