numpy.org icon indicating copy to clipboard operation
numpy.org copied to clipboard

Enable and fix for dark mode

Open alphapapa opened this issue 2 years ago • 18 comments

See https://github.com/numpy/numpy.org/issues/707.

  • [x] Undo https://github.com/numpy/numpy.org/commit/a85637404e6c80d808cd93271b8dbbe346f41761: https://github.com/numpy/numpy.org/pull/708/commits/5dfb7969544515d7f8dd469865d9b53c12077ea5
  • [x] Logos not rendering well in dark mode (scientific domains; sponsorships on About):
    • https://github.com/numpy/numpy.org/pull/708/commits/bbf3708864445ad22a90b67a085c22ae42650aeb
    • https://github.com/numpy/numpy.org/pull/708/commits/b8a2621401c7982e58ffadc9bfb5cfdd6fe4ac25
    • https://github.com/numpy/numpy.org/pull/708/commits/ab211a573e0976de3739323666262007eb73778a
  • [x] Tabs:
    • [x] "Array libraries" tab: logo images need filtering: 6c78d3bef7036bea0b1152d7dfafabec44935343
    • [X] "Data Science", "Machine Learning", "Visualization" tabs: colors need fixing: https://github.com/numpy/numpy.org/pull/708/commits/6c78d3bef7036bea0b1152d7dfafabec44935343
    • [x] "Visualization" tab's images: https://github.com/numpy/numpy.org/pull/708/commits/5b8a04b4d835045cfbaf86bb449e59d3f45eb54d
    • [x] Some tabs have a ~li~ bullet at the top of their contents: https://github.com/numpy/numpy.org/pull/708/commits/c0d23b7e08ab80b0588973793668b6ea6d7ecfa3
    • [x] Content top-margin larger for text than images: https://github.com/numpy/numpy.org/pull/708/commits/1d40832e5f7cdab405e67f6b2d63a461479169e6
  • [x] Language drop down: wrong color in dark mode (should be fixed in theme?)
    • [x] Fixed in https://github.com/scientific-python/scientific-python-hugo-theme/pull/435

alphapapa avatar Dec 07 '23 19:12 alphapapa

Deploy Preview for numpy-org ready!

Name Link
Latest commit 1a9fe8d0fad0b9fd24b6bb10084036e20bc33924
Latest deploy log https://app.netlify.com/sites/numpy-org/deploys/6604408c5c7efc0008195efc
Deploy Preview https://deploy-preview-708--numpy-org.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Dec 07 '23 19:12 netlify[bot]

@stefanv @jarrodmillman Can't request reviews on this repo, so tagging you. Thanks.

alphapapa avatar Dec 07 '23 20:12 alphapapa

See https://deploy-preview-708--numpy-org.netlify.app/about/; what do we do with those logos?

stefanv avatar Dec 08 '23 00:12 stefanv

See https://deploy-preview-708--numpy-org.netlify.app/about/; what do we do with those logos?

Apologies, I should have checked the other pages as well.

I think those logos can be decently handled by filters, like the smaller ones on the tab sections. I'll see what I can do.

Marking as a draft until ready for review again. Thanks.

alphapapa avatar Dec 08 '23 00:12 alphapapa

See #712.

jarrodmillman avatar Dec 18 '23 21:12 jarrodmillman

Looking at the logos again, as Stefan asked.

Two options come to mind:

  1. For ones with poor contrast, we could use a CSS filter to invert the colors. That would likely fix the contrast, although it would, well, invert the colors. :)
  2. We could also adjust the background color, or try using a drop-shadow filter, something like that, to gently improve contrast without adjusting the image itself.

By the way, I noticed that the sponsors.html shortcode includes this stylesheet, which isn't functional because it's not in the page header:

https://github.com/numpy/numpy.org/blob/3c39fcfe02f94459e0456180b477ff6760f027d1/layouts/shortcodes/sponsors.html#L16-L43

The partners.html file includes one as well:

https://github.com/numpy/numpy.org/blob/3c39fcfe02f94459e0456180b477ff6760f027d1/layouts/shortcodes/partners.html#L13-L40

We should probably replace those with either inline styles on the relevant elements, or generalize them into the page's stylesheet.

@stefanv @jarrodmillman

Please let me know what you'd prefer that I do about them. Thanks.

alphapapa avatar Feb 09 '24 19:02 alphapapa

Sometimes, images can be used in light and dark mode, but we definitely need the ability to specify different images for each. How about something like this:

<img src="img-dark.png" class="dark-theme"/>
<img src="img-light.png" class="light-theme"/>

Then, in the stylesheet:

html[data-theme="dark"] {
  .light-theme {
    display: none;
  }
}

html[data-theme="light"] {
  .dark-theme {
    display: none;
  }
}

stefanv avatar Feb 09 '24 19:02 stefanv

Re: sponsors.html, it should get its own .css file; or we remove sponsors.html and att it to numpy.org, since I think that's the only place it is being used.

stefanv avatar Feb 09 '24 19:02 stefanv

Re: sponsors.html, it should get its own .css file; or we remove sponsors.html and att it to numpy.org, since I think that's the only place it is being used.

@stefanv Sorry, I'm not sure what you mean about moving sponsors.html to numpy.org.

alphapapa avatar Feb 09 '24 21:02 alphapapa

Sometimes, images can be used in light and dark mode, but we definitely need the ability to specify different images for each. How about something like this:

@stefan Sure. I think we could also use the picture element to do the same thing without having to add CSS classes. What do you think?

alphapapa avatar Feb 09 '24 21:02 alphapapa

Pushed https://github.com/numpy/numpy.org/pull/725 in re https://github.com/numpy/numpy.org/pull/708#issuecomment-1936493405

alphapapa avatar Feb 09 '24 22:02 alphapapa

The style stuff in the shortcodes appears to be functional to me. It appears in the source file and when you remove the styling from the shortcode the page looks different. For example, with the styling 2024-02-09T14:17:22,330802550-08:00 and without it 2024-02-09T14:18:46,025201639-08:00

So we can probably just leave it as is for now. Or move it.

jarrodmillman avatar Feb 09 '24 22:02 jarrodmillman

The style stuff in the shortcodes appears to be functional to me. It appears in the source file and when you remove the styling from the shortcode the page looks different. For example, with the styling 2024-02-09T14:17:22,330802550-08:00 and without it 2024-02-09T14:18:46,025201639-08:00

So we can probably just leave it as is for now. Or move it.

Hm, ok, according to this, it's not officially supported yet, but unofficially it works.

I'll close #725 then. Thanks.

alphapapa avatar Feb 09 '24 22:02 alphapapa

Re: picture element + media selectors:

I considered that, but we do not merely rely on the browser preference, we also allow setting it, and that appears as a data element on html.

stefanv avatar Feb 09 '24 22:02 stefanv

I considered that, but we do not merely rely on them preference, we also allow setting it, and that appears as a data element on html.

Thanks.

alphapapa avatar Feb 09 '24 23:02 alphapapa

Once we get the grid sorted out, maybe these can just be grids of images (i.e., maybe we don't need special roles for sponsors and partners).

jarrodmillman avatar Feb 10 '24 03:02 jarrodmillman

Let's put this on hold for a bit b/c I want to revisit if we can use theme functionality directly.

jarrodmillman avatar Mar 27 '24 16:03 jarrodmillman

See https://github.com/scientific-python/scientific-python-hugo-theme/pull/599 and #746. Still working on things, but there is progress.

jarrodmillman avatar May 05 '24 21:05 jarrodmillman