blueswen / mkdocs-glightbox

A MkDocs plugin supports image lightbox (zoom effect) with GLightbox.
https://blueswen.github.io/mkdocs-glightbox/
MIT License
115 stars 14 forks source link

Force captions in lightbox to always be white on black #32

Closed patrislav1 closed 4 months ago

patrislav1 commented 5 months ago

The caption shown in the lightbox seems to inherit the currently selected color scheme. So when the light theme (aka default theme) is selected, the lightbox shows a bright black-on-white caption box which can look unpleasant and distract from the image (esp. when the image is low key). Since the lightbox itself always has a black background, it would make a lot of sense to force the lightbox caption to always have white(ish) text on black background, regardless of currently selected color theme. Is there a way to do so, without modifying the source code?

Lexachoc commented 4 months ago

You can modify the css (for example, using extra.css)

load it in the mkdocs.yml

extra_css:
  - stylesheets/extra.css

and then in extra.css

.gdesc-inner {
    background: rgba(0,0,0,.92) !important;
}

.gslide-title, .gslide-desc {
    color: #fff !important;
}

The result: image

BTW, if you are using mkdocs-material: see: https://squidfunk.github.io/mkdocs-material/reference/images/?h=images#light-and-dark-mode

You can switch between light and dark mode, and the result will be: Light mode: image

Dark mode: image

For me, the default color of mkdocs-glightbox works well because I prepare the images with light and dark tones that match the light/dark modes.

patrislav1 commented 4 months ago

Thank you! Your CSS example works in default / light mode but doesn't change the colors in dark mode. Is it possible to set the colors to fixed values regardless of selected color scheme?

Lexachoc commented 4 months ago

ah sorry about that! Use the below one instead! (I have also edited my previous reply)

.gdesc-inner {
    background: rgba(0,0,0,.92) !important;
}

.gslide-title, .gslide-desc {
    color: #fff !important;
}

For comparison, I changed the caption background to red so you can see that the background is fixed in both modes: image image

psifertex commented 4 months ago

It would be better if glightbox rather could just use the page's background colors instead of having to hard code is own single background color. This seems like it would just be a better default.

patrislav1 commented 4 months ago

ah sorry about that! Use the below one instead! (I have also edited my previous reply)

Works for me, thanks a lot!