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

fix: syntax highlighting doesn't switch dark / light mode when the UI does #51

Open
cablehead opened this issue Feb 16, 2024 · 1 comment

Comments

@cablehead
Copy link
Owner

cablehead commented Feb 16, 2024

image

Currently, markdown rendering and syntax highlighting are handled in the Rust backend. This might be a mistake, and potentially we should move this responsibility to the webview / Javascript.

Syntax highlighting leverages syntext, as detailed here: https://github.com/cablehead/stacks/blob/main/src-tauri/src/ui.rs#L304-L313

The implementation "bakes" the color scheme directly into the generated HTML. The frontend, which caches this content, doesn't update the syntax highlighting color scheme when the main UI toggles between light and dark modes.

I think there's ~2 solutions:

  1. Use classes for syntax highlighting elements, avoiding hardcoded color values. This way, CSS classes with variables can adjust to light/dark mode changes in the main UI.

Possible approaches for this solution include:

  1. Invalidate the frontend's content cache when toggling between light and dark modes.
@cablehead
Copy link
Owner Author

This'll be nice to fix

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant