Skip to content

fix(v2): render correct syntax theme for current website theme#2150

Merged
yangshun merged 1 commit intomasterfrom
yangshun/syntax-theme-on-load
Dec 27, 2019
Merged

fix(v2): render correct syntax theme for current website theme#2150
yangshun merged 1 commit intomasterfrom
yangshun/syntax-theme-on-load

Conversation

@yangshun
Copy link
Contributor

Motivation

Fixes #2149

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

  1. Go to Netlify preview's /docs/introduction
  2. Set to dark mode if it's not already dark mode
  3. Refresh page, see code block syntax theme is dark

Related PRs

#1984

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Dec 26, 2019
@docusaurus-bot
Copy link
Contributor

Deploy preview for docusaurus-2 ready!

Built with commit 0fae54a

https://deploy-preview-2150--docusaurus-2.netlify.com

@wgao19
Copy link
Contributor

wgao19 commented Dec 27, 2019

I also noticed this, thanks for fixing!

Meanwhile, I noticed that the new theme renders dark text on top of dark background for code block in light mode which isn't very friendly

image

@yangshun
Copy link
Contributor Author

Meanwhile, I noticed that the new theme renders dark text on top of dark background for code block in light mode which isn't very friendly

Yes there's quite a bit of follow up work to do. Our highlighting colors now are just hardcoded without awareness of the current theme.

@yangshun yangshun merged commit 167f71a into master Dec 27, 2019
@yangshun yangshun deleted the yangshun/syntax-theme-on-load branch December 27, 2019 05:44
Copy link
Contributor

@endiliey endiliey left a comment

Choose a reason for hiding this comment

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

You can also use the react context (isClient) from Docusaurus context for the two pass rendering. It is built for the hydration purpose.

React toggle is consuming it

@yangshun
Copy link
Contributor Author

Oh cool. Should I use it? Was thinking of making the codeblocks more standalone 🤔

@endiliey
Copy link
Contributor

we can leave it as it is i guess. Not really sure on the perf benefit gain, probably only the fact that it does not rerender on every mount (?) cos context is on main bundle and we alrd consume context for themeconfig too.

But its safe to leave it. If web performance is concerned, we are still lacking on making the first contentful paint & meaningful content paint faster (need smaller css for non render blocking evaluation 😉)

@yangshun yangshun added the pr: bug fix This PR fixes a bug in a past release. label Jan 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA pr: bug fix This PR fixes a bug in a past release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[v2] theme syntax highlighting doesn't display properly on initial render

5 participants