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

<Prism colorScheme="dark"> not respecting dark mode with highlighted lines. #2404

Closed
dmerand opened this issue Sep 9, 2022 · 3 comments
Closed
Labels
Fixed patch Completed issues that will be published with next patch (1.0.X)

Comments

@dmerand
Copy link

dmerand commented Sep 9, 2022

What package has an issue

@mantine/prism

Describe the bug

When using <Prism> with colorScheme="dark" and highlighted lines, the per-line highlight is defaulting to the "light mode" colors instead of "dark mode" colors.

What version of @mantine/hooks page do you have in package.json?

^5.1.1

If possible, please include a link to a codesandbox with the reproduced problem

https://codesandbox.io/s/happy-johnson-uheyg9

Do you know how to fix the issue

Yes

Are you willing to participate in fixing this issue and create a pull request with the fix

No

Possible fix

If I'm reading the code correctly, the reason is that the following lines are referring to the theme's colorScheme instead of the passed colorScheme value for highlighted lines:

theme.colorScheme === 'dark'

theme.colorScheme === 'dark' ? 5 : 8

theme.colorScheme === 'dark' ? 5 : 8

I believe that in all three cases, referencing the passed colorScheme variable instead of theme.colorScheme would produce the desired behavior.

My current workaround is to create a "temporary theme" using a MantineProvider e.g.:

<MantineProvider theme={{colorScheme: "dark"}}>
  <Prism language="json" highlightLines={{5: added, 7: removed}}>
    {code}
  </Prism>
</MantineProvider>

... instead of

<Prism language="json" colorScheme="dark" highlightLines={{5: added, 7: removed}}>
  {code}
</Prism>

Here's a link to a code sandbox with the simulated workaround: https://codesandbox.io/s/currying-brook-bei9um

@rtivital
Copy link
Member

rtivital commented Sep 9, 2022

Thanks for reporting, the issue will be fixed in one of the next patches

@rtivital rtivital added Fixed patch Completed issues that will be published with next patch (1.0.X) and removed review required labels Sep 9, 2022
@rtivital
Copy link
Member

Fixed in 5.3.1

@dmerand
Copy link
Author

dmerand commented Sep 14, 2022

I updated my repository and can confirm that this fixed my issue! Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed patch Completed issues that will be published with next patch (1.0.X)
Projects
None yet
Development

No branches or pull requests

2 participants