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 theme code blocks contrast too heavily with message background #13792

Closed
MyriaCore opened this issue May 24, 2020 · 0 comments · Fixed by matrix-org/matrix-react-sdk#6320

Comments

@MyriaCore
Copy link

Description

This is totally a subjective thing, but I find the background coloring of the code blocks in darktheme to be a bit off, at least when compared to the rest of the app. I think this is most obvious when hovering over the codeblock, but still noticably not great when just looking at them.

I think this off-ness is rooted in the contrast between the background of the code-block, and the background of the message. Here are a few screenshots demonstrating what I mean.

image

As you can see from the above screenshot, the syntax highlighting in the codeblocks is fighting for the attention of the viewer, and almost seems to shimmer due to the stark contrast against the codeblock's dark background. More so, the codeblocks themselves seem almost alien against the background - like they really don't belong there.

If you're not following, I feel this is made more obvious when there are lighter elements on the screen, such as when hovering over the codeblock:

image

One interesting element is that this problem seems less obvious when presented without the full context of the UI:

image

This is actually what helped lead me to the conclusion that the contrast was the problem - the sidebars are the lightest element in the UI when using darktheme, and when you remove those, it's harder to see the negative affect. That's because you've removed one of the main contrasting elements.

image

This is an issue that does not seem to be shared by light-theme. While there is contrast in the light-theme code-block background and the light-theme message background, it's not nearly as much. This lends the sense that light-theme code blocks "belong" more with their surroundings than dar-theme ones.

image

Contrast Analysis

In the below screenshots, I've put the hex color values of the different UI elements for dark-theme and for light-theme. I've just used GIMP's color-picker to pick out these hex values, so it's likely that the actual in-code values are different.

image

image

For the light-theme codeblocks, the difference is #ffffff#f7f7f7 = 0x80808. For dark-theme codeblocks, the difference is #181b21 - #000000 = 0x181b21. As we can see, dark-theme codeblocks contrast with the background way more than light-theme codeblocks do - just over three times more, in fact.

Steps Forward / How to fix

I tried fiddling around with the styling to see if I could try to play around with some of these hex values myself, and it appears that this darktheme is achieved by literally inverting the colors with filter: invert(1), and the color provided by .mx_EventTile_content .markdown-body code, .mx_EventTile_content .markdown-body pre.

demo

I'm not familiar enough with the code-base to tell if this is actually what's happening, or if it just looks like what's happening, but if it is what's happening, this might make it difficult to individually adjust the stylings of different UI elements. However, if I were to try to adjust this, I'd probably just make the background color for codeblocks a little less black, and a little closer to the color of the message background.

Version information

  • Platform: desktop

  • OS: Manjaro Linux

  • Version:

    • riot-web version: 1.6.0
    • olm version: 3.1.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants