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

Dark mode #84

Open
gjhltn opened this issue Jun 9, 2022 · 4 comments
Open

Dark mode #84

gjhltn opened this issue Jun 9, 2022 · 4 comments

Comments

@gjhltn
Copy link

gjhltn commented Jun 9, 2022

I need to use a different syntax stylesheet in dark vs light mode. How can I achieve this? As far as I can tell, it's not possible? If so this seems like important missing functionality??

The way to do this using highlight is hacky - switching link tags - and is essentially impossible to arrange with a bundler. It would be great if there was an easy way to scope the css to a tag for instance...

Thanks

@miko007
Copy link

miko007 commented Sep 30, 2022

you basically just import a dark color scheme in your sass via:

@import "~highlight.js/styles/monokai.css";

for example.

@gjhltn
Copy link
Author

gjhltn commented Sep 30, 2022

Thanks for helping. My question was more how to switch between the different styles. Does sass let you import a css file conditionally into a media query scope? If so great but sass isn't part of everybody's stack, and as far as I can see it's not easy at all to arrange with my stack - webpack and styled components. Having an external stylesheet at all is a already inconvenient enough but is understandable, but having two and trying to get them to switch is I think nontrivial?

If there was a way to configure the component with a stylesheet to use in light mode and one in dark (and perhaps for other preferences) that would I think be a really helpful feature,

@miko007
Copy link

miko007 commented Oct 1, 2022

in that case, you would need to do some of this magic: https://github.com/highlightjs/highlight.js/blob/main/demo/demo.js

@gjhltn
Copy link
Author

gjhltn commented Oct 1, 2022

Very much appreciate this thank you. This is pretty much the solution I was describing in my original post but it's very helpful indeed to confirm that it's not crazy! Many thanks indeed. Have a great weekend.

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

2 participants