Skip to content

DO NOT MERGE feat: add script to merge all tokens into a single JSON file #104

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

srambach
Copy link
Member

AI-generated code via Cursor to output the deep merge of all the exported token files as JSON token format. First commit puts all into one file, but that would mix dark/default themes, so in the second commit I separated them into two files.

@garrett perhaps this helps?

@garrett
Copy link

garrett commented May 13, 2025

I tried this with node packages/module/merge-tokens.js and the resulting JSON files are not properly loading in Penpot. Only colors load, and most of the colors are broken references. The basic color palette seems to work. Nothing other than colors work. Additionally, there's no Default vs Dark.

@garrett
Copy link

garrett commented May 15, 2025

Thanks again for your start on this!

I kind of went a bit overboard and did some type sniffing based on name and content, to map the tokens into W3C types for standards support and Penpot compliance.

I also split off sets of tokens, so that Definitions are a set (so they can be avoided, generally, unless a certain hardcoded version is needed), Semantic ones are set (which is the main one to use), and Charts are separate (to avoid flooding all the colors with charts). Additionally, there are Dark and Chart-Dark overrides for dark support, selectable in the themes dropdown.

Anyway, it's a bit hackish, especially in some places, but it works for me and produces a W3C token compatible file that works in Penpot!

Penpot is supporting new token types soon, so some might just work (I added in some future support for them), and there are passthroughs from this too. There are more tokens in the resulting file than Penpot can work with currently, but it already handles all the main ones! (Currently, there aren't shadows or font/type related tokens. But all the rest of the most useful ones are there already.)

...and remove the previous merged token file from the previous script
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.

2 participants