Skip to content

Conversation

cderv
Copy link
Collaborator

@cderv cderv commented Mar 12, 2024

This will allow transparent images to be seen on the media background

Closes #9047

chrome_eSgylyBi6G

format: 
  html:
    backgroundcolor: "red"

@dragonstyle do you think this is not a good idea ? I believe non-transparent images won't be affected by a set background on the div.

This will allow transparent images to be seen on the media background
@cderv cderv requested a review from dragonstyle March 12, 2024 13:19
@cscheid
Copy link
Collaborator

cscheid commented Mar 12, 2024

We do have to be careful here; if someone uses a background color that has partial alpha, I think this rule won't work (it will "double-paint" the background).

@cderv
Copy link
Collaborator Author

cderv commented Mar 12, 2024

If someone does this in the image aim to be in the lightbox, it will also apply on the image itself in the doc, won't it ? We do set background for the document I believe... I'll try it to experiment.

Or do you mean someone who would do that specifically for the image when inside the lightbox modal ?

Anyway, thanks for the feedback - I did not merge because I felt something was not enough.

@cscheid
Copy link
Collaborator

cscheid commented Mar 12, 2024

I meant that we should test what happens if someone sets quarto body background to be rgba(255,0,0,0.5) (the 0.5 being the important part). If I understand your patch correctly, you'd be adding an additional rgba(255,0,0,0.5) to the image and that would mean that visually the lightbox image would end up with rgba(255,0,0,0.75) because of the semi-transparent composition.

@cderv
Copy link
Collaborator Author

cderv commented Mar 12, 2024

Thanks for the precision - I understand now. And yes indeed it would lead to
image

FWIW we already have this issue for the description that we set using background color too.
image
My patch was inspired by this treatment

body:not(.glightbox-mobile) div.gslide div.gslide-description,
body:not(.glightbox-mobile) div.gslide-description .gslide-title,
body:not(.glightbox-mobile) div.gslide-description .gslide-desc {
color: var(--quarto-body-color);
background-color: var(--quarto-body-bg);
}

We apply to the .gslide-description but also to .gslide-title and .gslide-desc - so we have even more layer of opacity

This is run with

format: html
backgroundcolor: rgba(255,0,0,0.5)

@cscheid
Copy link
Collaborator

cscheid commented Mar 12, 2024

Maybe what we should do then is just add some documentation that recommends opacity either zero or one.

@cscheid cscheid merged commit 88c5518 into main Mar 22, 2024
@cscheid cscheid deleted the lightbox/background branch March 22, 2024 02:57
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.

Transparent lightbox images - set a default background

2 participants