cockpit icon indicating copy to clipboard operation
cockpit copied to clipboard

pkg: enable dark theme for PF

Open jelly opened this issue 2 years ago • 10 comments

jelly avatar May 05 '22 14:05 jelly

Both @jelly and I tried for a while today to get this to work by adding various files in different orders in different places... and it's not working right for either of us.

Perhaps there's some special magic to get it to work as expected that we're just not aware of at the moment?


We did also try to add in the following files in addition to those in this PR:

  • @patternfly/patternfly/patternfly-theme-dark-prefers-color-scheme.scss
  • @patternfly/patternfly/themes/dark/base.css

Nothing's working. Some widgets do show up a bit different (no shadows, darker borders) and sometimes we can get some to change (like white text on a white background when in dark mode), but it's nowhere near a dark mode yet. So we must be doing something wrong.

garrett avatar May 05 '22 15:05 garrett

Rebased the branch, and now we get something:

image

jelly avatar Jul 12 '22 15:07 jelly

Mostly FYI:

  • When pf-theme-dark is set, patternfly enables the dark theme.
  • In chrom(ium) toggling dark mode can be done in devtools: click the three dotted (kebab) menu, more tools -> Rendering. Then select the emulation mode from "Emulate CSS media feature prefers-color-scheme"

jelly avatar Jul 13 '22 13:07 jelly

Last rebase has imporved the situation some obvious issues:

  • metrics page has issues

image

image

  • top bar looks weird:

image

  • Graphs are not readable (network manager page)

image

  • Shell menu is hard to read

image

  • Failing systemd unit

image

This uses --ct-color-list-critical-bg which needs some variant in pkg/lib/page.scss for our dark theme. This would be required for all our custom --ct-color-list values or at least have to be inspected.

Our loading animations are not looking ok

image

jelly avatar Aug 08 '22 13:08 jelly

Oh, you didn't push your rebase... so, as it rebased cleanly, I just did. :wink:

garrett avatar Aug 08 '22 15:08 garrett

One huge issue right now: On page load, the page is white. That's a dealbreaker for a proper dark theme. I guess we can set html or body to #000 on load (possibly even in the page, in a <style> block, if we can't get to it fast enough otherwise) and then let PF set it to whatever.

garrett avatar Aug 08 '22 15:08 garrett

Oh, you didn't push your rebase... so, as it rebased cleanly, I just did. wink

Hmm strange, I force pushed again with a rebase plus fixes for some pages which did not have pf-dark-theme set.

jelly avatar Aug 08 '22 17:08 jelly

Pushed one fix for the graphs in storaged/networkmanager page.

jelly avatar Aug 09 '22 13:08 jelly

The flashing is now gone, as we set the html background when creating the new iframe, but it feels that there is still some minor issue with flashing?

Unrelated:

networkmanager page does not have any difference in color between the header and the page itself?

image

Storage in contrast

image

jelly avatar Oct 06 '22 10:10 jelly

I pushed up a bunch of fixes for dark mode. I'm still ignoring the issues that a newer PF would fix; these are ones that affect us specifically and ones that PF has not addressed.

While I did solve a few things already in Metrics, it still has white lines that I've been trying to combat. I wasn't able to figure it out in time, before heading off for a few days of PTO. I'll see you next week!

garrett avatar Oct 11 '22 15:10 garrett

Rebased

garrett avatar Oct 17 '22 12:10 garrett

Rebased & stacked more fixes on top.

I couldn't find what I had done prior, but realized it was simpler than what I had done before, so I just fixed it here as-is.

But I think it's probably good enough for a beta now?! (We should probably reorder and squash a bit more and then merge this in.)

garrett avatar Oct 26 '22 16:10 garrett

The unit-tests fail, investiating

jelly avatar Oct 27 '22 09:10 jelly

image

Text here seems unreadable.

image

Would this be fixed by updating our machines cockpit lib? (The PF overrides)

jelly avatar Oct 27 '22 12:10 jelly

This is still broken:

image

jelly avatar Oct 27 '22 13:10 jelly

Talked with @garrett about pixel tests for dark theme. We think we could auto test dark theme on all biggest screenshots. We don't necessarily need medium and mobile for dark theme.

@martinpitt @jelly @mvollmer Any concerns/opinions about this?

marusak avatar Oct 27 '22 15:10 marusak

Pixel tests will fail for the dark theme in the shell nav as the highlight color changed for the light theme:

the highlight color will still change, but i'll be an orangey yellow

jelly avatar Oct 27 '22 15:10 jelly

Talked with @garrett about pixel tests for dark theme. We think we could auto test dark theme on all biggest screenshots. We don't necessarily need medium and mobile for dark theme.

@martinpitt @jelly @mvollmer Any concerns/opinions about this?

Yes, the question is how we can test this, I would not want to introduce a new test scenario:

  • [x] does the CDP support setting dark theme?
  • [ ] does Chrome allow setting via settings?
  • [ ] does firefox allow it via settings?

jelly avatar Oct 28 '22 08:10 jelly

Talked with @garrett about pixel tests for dark theme. We think we could auto test dark theme on all biggest screenshots. We don't necessarily need medium and mobile for dark theme. @martinpitt @jelly @mvollmer Any concerns/opinions about this?

Yes, the question is how we can test this, I would not want to introduce a new test scenario:

  • [x] does the CDP support setting dark theme?
  • [ ] does Chrome allow setting via settings?
  • [ ] does firefox allow it via settings?

We can use:

https://chromedevtools.github.io/devtools-protocol/tot/Emulation/#method-setEmulatedMedia

jelly avatar Oct 28 '22 09:10 jelly

Talked with @garrett about pixel tests for dark theme. We think we could auto test dark theme on all biggest screenshots. We don't necessarily need medium and mobile for dark theme. @martinpitt @jelly @mvollmer Any concerns/opinions about this?

Yes, the question is how we can test this, I would not want to introduce a new test scenario:

  • [x] does the CDP support setting dark theme?
  • [ ] does Chrome allow setting via settings?
  • [ ] does firefox allow it via settings?

We can use:

https://chromedevtools.github.io/devtools-protocol/tot/Emulation/#method-setEmulatedMedia

Created a draft PR here https://github.com/cockpit-project/cockpit/pull/17854

I don't want to push more work on to this PR.

jelly avatar Oct 28 '22 09:10 jelly

@garrett @marusak here are the new pixel tests:

New dark theme pixels https://cockpit-logs.us-east-1.linodeobjects.com/pull-17319-20221102-131822-0f1acac0-fedora-36/log.html

jelly avatar Nov 02 '22 15:11 jelly

All looks good to me, this one has a small minor issue, maybe not even dark theme related image

jelly avatar Nov 02 '22 15:11 jelly

All looks good to me, this one has a small minor issue, maybe not even dark theme related

I think it's not dark theme related, but it's probably not seen in light mode... I think in light, it's a table with a white background on modal dialog with a white background.

But it's not a big deal. I think everything I've seen in the pixel tests are at the level of a cosmetic glitch and worthy of a follow-up. I'm fine with merging this, calling it "beta", and fixing whatever small bits we uncover (as well as these tiny things) after the release.

Everything seems functional and feature complete and nothing seems broken, in other words.

garrett avatar Nov 02 '22 16:11 garrett

@garrett I think the release announcement needs a screenshot!

jelly avatar Nov 02 '22 16:11 jelly

I think the release announcement needs a screenshot!

Good point!

We should probably take the screenshot using Cockpit Client, which has had dark mode for quite some time already. :wink:

garrett avatar Nov 03 '22 08:11 garrett

I've included a heavily optimized GIF above. It's chonky, but will work everywhere and can be included with a standard img tag.

Here's a webm:

darkmode2.webm

Here's an MP4 https://user-images.githubusercontent.com/10246/199786008-9178cc82-4fcc-49ff-bfd6-80ef4629087b.mp4

Original screenshots, if all else fails:

light

dark

garrett avatar Nov 03 '22 17:11 garrett