-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(tui): system-like custom themes #9184
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
base: dev
Are you sure you want to change the base?
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found one potentially related PR: Potentially Related:
The other results (#5020 on layout systems and #8239 on desktop appearance toggle) are related but address different aspects of the system. Conclusion: No clear duplicate PRs found. PR #9184 appears to be implementing a novel feature for system-like custom themes in the TUI that doesn't have an existing equivalent PR. |
b23e51c to
c710973
Compare
| ### Terminal defaults | ||
|
|
||
| The special value `"none"` can be used for any color to inherit the terminal's default color. This is particularly useful for creating themes that blend seamlessly with your terminal's color scheme: | ||
|
|
||
| - `"text": "none"` - Uses terminal's default foreground color | ||
| - `"background": "none"` - Uses terminal's default background color | ||
|
|
||
| --- | ||
|
|
||
| ### System color references | ||
|
|
||
| Custom themes can use `"system"` as a color value to inherit colors from your terminal's palette. This lets you create themes that blend custom branding with your terminal's native colors: | ||
|
|
||
| ```json title="my-system-theme.json" | ||
| { | ||
| "theme": { | ||
| "background": "system", | ||
| "text": "system", | ||
| "primary": "#ff5500", | ||
| "secondary": "system", | ||
| ... | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| Colors set to `"system"` will update when your terminal's palette changes (after sending SIGUSR2 to reload). | ||
|
|
||
| --- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I never quite understood how none's documentation matches its implementation. none's documentation does seem to match the implementation for system though.
none's implementation returns 0s for every color key:
case "transparent":
case "none":
return RGBA.fromInts(0, 0, 0, 0)c710973 to
736f101
Compare
Issues
systemcolors #6322Feature
Custom themes can now reference the
systemtheme that is generated from the user's terminal color palette by using"system"as a color value:{ "theme": { "background": "system", "foreground": "system", "primary": "#ff5500" } }Performance optimization
The theme context now readies 10x faster in the by-far most common case (using one of the default themes). The speedup is due to not waiting for resources to load that are irrelevant for the requested theme.
Timed using this patch that calls
console.timeinsidecreateSimpleContext.After = 3.558ms
Before = 31.264ms
More details
Key behaviors
createResourcecreateMemoreturning(requested theme, resource loading status)Miscellany
Toggle appearanceCommits
Three atomic commits build up to this feature:
fix(tui): system theme light & dark variantsrefactor(tui): theme switching & loading reactivityfeat(tui): system-like custom themesNotes