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

fix: don't add mode level if only one mode is present #278

Merged
merged 1 commit into from
Oct 7, 2023

Conversation

jonbrooks
Copy link
Contributor

This PR is primarily for discussion. It addresses bugs I've been seeing with the most recent version of the plugin. I was seeing similar behavior as #271 , #273 and #274.

In my case, our token variables had a collection of primitives with a single mode, and then a colors collection with 2 modes whose values all referred back to primitive values. The desired output would look like so:

  "primitives": {
    "color": {
      "white": {
        "50": {
          "type": "color",
          "value": "#ffffffff",
          "blendMode": "normal"
        },
      "black": {
        "50": {
          "type": "color",
          "value": "#00000000",
          "blendMode": "normal"
        },
      ...
      }
    }
  "colors": {
    "dark": {
      "text": {
        "primary": {
          "type": "color",
          "value": "{primitives.color.white.50}"
        }
      }
    },
    "light": {
      "text": {
        "primary": {
          "type": "color",
          "value": "{primitives.color.black.60}"
        }
      }
    },

What came out was very confusing - with a "Value" level in primitives, and the colors had a mix of values grouped into a top level value object and others grouped into top level light and dark objects. I couldn't figure out any rhyme or reason to it.

The changes here disable adding the mode level if there's only one mode, and with this change, I get what I want in my tokens, but maybe there's a good reason not to do this - I'm not sure. I think it may have already been discussed around #258.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 6357542902

  • 0 of 3 (0.0%) changed or added relevant lines in 1 file are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.3%) to 66.2%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/utilities/getVariables.ts 0 3 0.0%
Files with Coverage Reduction New Missed Lines %
src/utilities/getVariables.ts 2 20.0%
Totals Coverage Status
Change from base Build 6296098097: -0.3%
Covered Lines: 496
Relevant Lines: 733

💛 - Coveralls

@lukasoppermann
Copy link
Owner

This looks interesting, I'll give it a try.

@lukasoppermann lukasoppermann merged commit f0fc19f into lukasoppermann:main Oct 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants