Refactor Theme API - #113
Merged
Merged
Conversation
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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
amadeus
marked this pull request as ready for review
October 30, 2025 00:59
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
themeprop or athemesprop 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
themeprop that takes either a theme or an object ofdark/light. This way we don't have toORthings 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
themesprop 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.