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

Handle CSS-defined light/dark theme #488

Open
pharmpy-dev-123 opened this issue Oct 18, 2022 · 0 comments
Open

Handle CSS-defined light/dark theme #488

pharmpy-dev-123 opened this issue Oct 18, 2022 · 0 comments

Comments

@pharmpy-dev-123
Copy link

CSS seems to be one* proper solution to get rid of the "theme-flickering" problem (see for instance mui/material-ui#12827). You load twice as much theme-related CSS, but at least your first render of the page is coherent with the user-selected theme.

There is at least one standard way of handling this in CSS, via the media query (prefers-color-scheme: dark), but this only handles following the underlying system's theme. There are also custom CSS classes or HTML attributes (which can be queried via CSS), for instance in MUI the <html> root element gets an extra attribute data-mui-color-scheme="dark" (see https://mui.com/material-ui/experimental-api/css-theme-variables/customization/#custom-styles-per-mode). These allow more complex behaviors such as manually setting the theme, independently of the underlying system's theme.

* Request headers parsing could also work to some extent but that's not the subject here.

Describe the solution you'd like
react-syntax-highlighter should provide some styles that are "dynamic", in that they take into account the CSS solutions mentioned above. For instance we could have a generic function to combine one light style and one dark style into one dynamic style. Or we could have a mui style that specifically handles the MUI way of defining the current theme.

Describe alternatives you've considered
One can write their own ad-hoc dynamic highlight style. But that takes time or involves redundant copy-pasting.

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

No branches or pull requests

1 participant