Skip to content

Refactor Theme API - #113

Merged
amadeus merged 4 commits into
mainfrom
amadeus/themes-api-improvements
Oct 30, 2025
Merged

Refactor Theme API#113
amadeus merged 4 commits into
mainfrom
amadeus/themes-api-improvements

Conversation

@amadeus

@amadeus amadeus commented Oct 30, 2025

Copy link
Copy Markdown
Member

This change is something I'll need to communicate to users of, it's unfortunately a bit of an annoying change but should be trivial to fix.

Basically one of the crappy parts of the components and API that I inherited from Shiki is that you can either provide a theme prop or a themes prop that defines dark/light themes, but not both together. This required typing a lot of areas with a OR types and it generally made the API very shitty to work with in practice.

I've decided to make a change here -- a singular theme prop that takes either a theme or an object of dark/light. This way we don't have to OR things everywhere, and the only internal things is I have to manage how those props get passed to shiki, which is pretty trivial.

Part of what drove this is that I already got a bug report that the themes prop didn't work, simply because the typescript error was so obtuse.

I thought about allowing both optionally, but then it could still result in confusion because we have to pick one over the other in priority and it might still get reported as a bug. Having 1 prop I think is much cleaner and clearer from an API perspective despite maybe the pluralization being weird when specifying dark/light.

I still need to update the docs before merging this and then ship a release at the same time so the docs go out at the same time.

Only a singular theme prop, that can take both a theme string or
dark/light object.  This will vastly simplify the API, reduce the chance
of mistakes, and avoid some really tricky code
@amadeus
amadeus requested review from SlexAxton and fat October 30, 2025 00:35
@vercel

vercel Bot commented Oct 30, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
pierrejs-diff-demo Ready Ready Preview Oct 30, 2025 0:57am
pierrejs-docs Ready Ready Preview Oct 30, 2025 0:57am

@amadeus
amadeus marked this pull request as ready for review October 30, 2025 00:59
@amadeus
amadeus merged commit 4c0e9e7 into main Oct 30, 2025
2 checks passed
@amadeus
amadeus deleted the amadeus/themes-api-improvements branch October 30, 2025 01:01
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.

1 participant