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 SSR styling of code-blocks #480

Merged
merged 8 commits into from
Oct 15, 2024

Conversation

agoose77
Copy link
Collaborator

@agoose77 agoose77 commented Sep 26, 2024

Recent theme work moved theme logic entirely client-side1, so that we can support client-only theme configuration (localStorage).

This PR vendors the current styles that we use from highlight.js, and adds selectors for the dark-mode variant. This means that we can set the theme entirely client-side.

Closes #473

Footnotes

  1. Technically SSR can render the proper state server-side, but for first-visits, we have to wait for the client to compute the proper state (and do some hydration-hacks to resolve the state).

Copy link

changeset-bot bot commented Sep 26, 2024

🦋 Changeset detected

Latest commit: e561a28

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 14 packages
Name Type
@myst-theme/styles Patch
myst-to-react Patch
@myst-theme/providers Patch
@myst-theme/frontmatter Patch
@myst-theme/diagrams Patch
@myst-theme/jupyter Patch
@myst-theme/site Patch
@myst-theme/common Patch
@myst-theme/icons Patch
@myst-theme/search Patch
@myst-theme/search-minisearch Patch
@myst-theme/book Patch
@myst-theme/article Patch
myst-demo Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@agoose77
Copy link
Collaborator Author

agoose77 commented Oct 1, 2024

@rowanc1 I've just lifted the CSS from highlightjs directly into our styling. This means that we don't need to duplicate any nodes. Are you comfortable with this change?

Comment on lines -3 to -4
import light from 'react-syntax-highlighter/dist/esm/styles/hljs/xcode.js';
import dark from 'react-syntax-highlighter/dist/esm/styles/hljs/vs2015.js';
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤮

@rowanc1 rowanc1 merged commit 348bf3b into main Oct 15, 2024
2 checks passed
@rowanc1 rowanc1 deleted the agoose77/fix-style-dark-on-client branch October 15, 2024 14:16
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

Successfully merging this pull request may close these issues.

🌗 code blocks are stuck in dark mode
2 participants