Skip to content

Conversation

@voliva
Copy link
Contributor

@voliva voliva commented Dec 10, 2020

Original issue => #137

Here's my approach to integrate with github's dark mode - I'm using github's CSS custom properties so that it grabs the same colour as github's theme.

There are a few colours I didn't really know which one to pick... For those ones it currently does the job, but we have no guarantee it will look alright if github decides to change it.

Which also makes me think that if github removes some of these variables, this extension will need to be updated again - I'm absolutely open to suggestions or better implementations.

Normal
image
image

Search
image
image

^^^^ This search one is an example where it could get better. Maybe we need to also have our own "fallback" palette that it depends on html[data-color-mode] attribute?

src/js/style.css Outdated
Comment on lines 77 to 79
background: var(--color-auto-gray-2);
color: var(--color-diff-blob-hunk-text);
border: 1px solid var(--color-auto-gray-2);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Specifically these are the ones I'm not sure I'm targetting the right custom property

@berzniz
Copy link
Owner

berzniz commented Dec 11, 2020

Thanks @voliva, I think this is the correct approach. I'll review and add it for the next release

@berzniz
Copy link
Owner

berzniz commented Dec 11, 2020

Hi @voliva, are you aware of any way to provide fallback values to CSS variables? That way we can keep the original colors as fallback, in case GitHub removes these variables, and will not make the extension completely unusable

@voliva
Copy link
Contributor Author

voliva commented Dec 11, 2020

Hey @berzniz - Yes there is, it's the second parameter when using var (e.g. var(--color-text-primary, #fff))

Question I have though is should we keep the dark mode in settings? Another possibility would be to try and detect whether github is running in dark mode directly.

@berzniz
Copy link
Owner

berzniz commented Dec 11, 2020

Hi @voliva - so let's add the fallback colors. I prefer to completely remove the dark mode settings and base it on the GitHub appearance preference (the solution you showed).

@voliva
Copy link
Contributor Author

voliva commented Dec 12, 2020

Updated with fallbacks.

A caveat is that with appearance=auto it will fallback to light mode - Solution is to use a media query @media (prefers-color-scheme: dark), but I would have to copy-paste all the fallback dark colors inside the media query :| - IMO it doesn't matter that much as they are just in case github changes their variable names.

@berzniz
Copy link
Owner

berzniz commented Dec 13, 2020

Great, thank you @voliva, I am merging and this will be out in the next version (I'll submit it today)

@berzniz berzniz merged commit d0e605f into berzniz:master Dec 13, 2020
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.

2 participants