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

Incorrect theme for code blocks in light mode #4812

Closed
victornoleto opened this issue May 18, 2021 · 7 comments · Fixed by #4968
Closed

Incorrect theme for code blocks in light mode #4812

victornoleto opened this issue May 18, 2021 · 7 comments · Fixed by #4968
Labels
bug An error in the Docusaurus core causing instability or issues with its execution closed: question This issue is a user error/misunderstanding.

Comments

@victornoleto
Copy link

I followed the steps:

npx @docusaurus/init@latest init docs classic
cd docs
npm docusaurus start

Then I realized that the code blocks had a dark theme, unlike the rest of the project. If I switch to dark mode everything will change, except for the code blocks that remain the same.

  1. My project in light mode: https://i.imgur.com/ayshMzw.png
  2. My project in dark mode: https://i.imgur.com/Dz474na.png

I would like the theme to be the same as that shown on the official website in which the code blocks respect the light theme.

  1. Docusaurus website in light mode: https://i.imgur.com/YVUn2G5.png
  2. Docusaurus website in dark mode: https://i.imgur.com/aTvQXkn.png
@victornoleto victornoleto added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels May 18, 2021
@slorber
Copy link
Collaborator

slorber commented May 18, 2021

Looks like a similar issue: #4788

  themeConfig: {
    prism: {
      theme: require('prism-react-renderer/themes/github'),
      darkTheme: require('prism-react-renderer/themes/dracula'),
    },
  },

How can we document this better? Where did you expect to find such information?

@victornoleto
Copy link
Author

That worked, but it didn't fix the whole problem. The highlighted lines are still being shown with the wrong colors.

  1. My project: https://i.imgur.com/yk23EmX.png
  2. Docusaurus website: https://i.imgur.com/XgsGAkq.png

How can we document this better? Where did you expect to find such information?

Perhaps in Docs > Guides> Styling and Layout?

@slorber
Copy link
Collaborator

slorber commented May 18, 2021

I believe this is documented: https://docusaurus.io/docs/markdown-features/code-blocks#line-highlighting

You have to use custom CSS and define your own highlighting color.

image

@victornoleto
Copy link
Author

Thank you! And sorry for not seen that ...

@slorber
Copy link
Collaborator

slorber commented May 18, 2021

That happens :)

Please submit a doc PR if you feel we could make it more obvious

@Josh-Cena
Copy link
Collaborator

@slorber Should we document it in the documentation or should we rather just modify the init template? Most users will be satisfied with a default code block style resembling the Docusaurus website.

@slorber
Copy link
Collaborator

slorber commented Jun 14, 2021

We could do both, do you want to open a PR?

That seems reasonable to improve the discoverability of the code block theming

@Josh-Cena Josh-Cena added closed: question This issue is a user error/misunderstanding. and removed status: needs triage This issue has not been triaged by maintainers labels Feb 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution closed: question This issue is a user error/misunderstanding.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants