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

Feature/transform modify to hex #166

Merged

Conversation

druhill
Copy link
Contributor

@druhill druhill commented Jun 29, 2023

Adds a transform that would allow for use of any colour space modifiers within tokens studio that will then convert these to hex during the build process.

From what I can see it is currently not possible to populate the 'format' attribute from Figma, so this transform would replace the requirement to edit the json to add these attributes.

This approach could be expanded to add transforms for each colour space that could be specified during the build process to ensure consistency.

The code is essentially just a port of the code used within the Tokens Studio plugin

fixes #53

@changeset-bot
Copy link

changeset-bot bot commented Jun 29, 2023

🦋 Changeset detected

Latest commit: 1327559

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@tokens-studio/sd-transforms Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@jorenbroekema
Copy link
Member

Hm I am interested in allowing you to globally specify the format of color modifiers, once, rather than per token, but please take a look at this issue where I outlined how I'd like the API to be for that #53

Would you be interested in implementing it that way instead in this PR?

@druhill
Copy link
Contributor Author

druhill commented Jun 30, 2023

@jorenbroekema Very much still a WIP, but is this the kind of approach you mean?

@jorenbroekema
Copy link
Member

So the API would become:

registerTransform(StyleDictionary, {
  "ts/color/modifiers": {
    format: "hex"
  },
});

and

transformColorModifiers(token, { format: "hex" });

respectively, depending on whether you use the full transformGroup or the color modifier transform function as standalone. And then you don't need a secondary transform to handle the formatting of the color after the color modification, and you get the same result which is passing the output format once only, rather than per token

@jorenbroekema jorenbroekema force-pushed the feature/transform-modify-to-hex branch from 95d4dc6 to 1327559 Compare July 14, 2023 12:31
@jorenbroekema
Copy link
Member

I added a changeset, add some small detail to readme, and adjusted one of my integration/smoke tests to include this option, so that we have at least 1 test that checks that this option is working from end to end.

Thanks a lot for contributing this! :) looks great overall

@jorenbroekema jorenbroekema merged commit 809b262 into tokens-studio:main Jul 14, 2023
1 check passed
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.

Allow specifying color modifier format option globally
2 participants