Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(infobox): cleanup header image display #4197

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

iMarbot
Copy link
Collaborator

@iMarbot iMarbot commented Apr 20, 2024

Summary

Cleaned up the output for infobox header images a bit so that it doesn't end up producing two of the same image when there is no need. Also removed some unnecessary div wrappers by moving their functionality into existing css classes.

HTML darkmode/lightmode allmode
Old image image
New image image

How did you test this change?

Tested on dev.

@iMarbot iMarbot added c: infobox stylesheets changes to stylesheets labels Apr 20, 2024
@iMarbot iMarbot requested review from Rathoz and hjpalpha April 20, 2024 17:05
@iMarbot iMarbot self-assigned this Apr 20, 2024
@hjpalpha
Copy link
Collaborator

hjpalpha commented Apr 20, 2024

can you check if it breaks infoboxes with fixed image size?

example page: https://liquipedia.net/starcraft2/Stimpack

from preview it looks broken to me but i can not check the css changes applied with it on mobile
i think the css change solves it, just double checking here^^

with this pr:
IMG_4941
before:
IMG_4942

Copy link
Collaborator

@hjpalpha hjpalpha left a comment

Choose a reason for hiding this comment

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

lgtm if test case mentioned above is checked and doesn't break

@iMarbot
Copy link
Collaborator Author

iMarbot commented Apr 20, 2024

can you check if it breaks infoboxes with fixed image size?

example page: https://liquipedia.net/starcraft2/Stimpack

from preview it looks broken to me but i can not check the css changes applied with it on mobile i think the css change solves it, just double checking here^^

Yeah the CSS centers it correctly.

image

Copy link
Collaborator

@Rathoz Rathoz left a comment

Choose a reason for hiding this comment

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

Would it make sense to use Module:Image instead?

@iMarbot
Copy link
Collaborator Author

iMarbot commented Apr 21, 2024

  • Removed the percent based size stuff was it was used on only two dota2 pages where the same result is already achieved with max-height CSS on the image itself.
  • Reworked as best I could to use Module:Image, however, it's not as simple as replacing everything with it because the infobox image structure uses a different way to swap between lightmode/darkmode logos.
  • Old code would not process any image inputs if a lightmode (|image= or default) image was not present. New code independently handles the two modes, so there can be no lightmode image but there will still be a darkmode image when theme is toggled (imo this is better - although unlikely to really matter).

Copy link
Collaborator

@hjpalpha hjpalpha left a comment

Choose a reason for hiding this comment

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

imo pass both dark and lightmode version to image module at the same time

@iMarbot
Copy link
Collaborator Author

iMarbot commented Apr 21, 2024

imo pass both dark and lightmode version to image module at the same time

As I mentioned in the comment, I can't do that because of differences in how lightmode/darkmode image is swapped in the infobox. It uses its own classes that aren't applied to the img tag.

size = size or ''
if tonumber(size) then
size = tonumber(size) .. 'px'
local infoboxImage = mw.html.create('div'):addClass('infobox-image'):addClass(mode)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could the css be tweaked so infobox-image is only needed to be set on the wrapper?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The way the infobox itself is all written, it's got classless div rows, and then each of those rows is filled with different things (headers/images/rows/etc.). It wouldn't make much sense to only change one of these and have the rest be as before, imo.
image

Copy link
Collaborator

@Rathoz Rathoz Apr 21, 2024

Choose a reason for hiding this comment

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

<div class="...-infobox">
 ...
 <div>
  <div class="infobox-image">
   <div class="lightmode">
     ...
   </div>
  </div>
 </div>
 ...
</div>

How about this

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Would still require tweaking some CSS, but wouldn't be too hard.

Idk if there's any conventions on "adjective" class names needing to be applied to an element with an existing "noun" class name (if that makes sense?) Obviously, on a technical level it makes absolutely no difference, just wondering how people feel about it in general (i.e. "lightmode" what? vs "lightmode" "infobox image").

Copy link
Collaborator

@hjpalpha hjpalpha Apr 22, 2024

Choose a reason for hiding this comment

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

do we even need the inner div (which sets the lightmode)?
if using module:Image it would get set in the image itself

<div class="...-infobox">
 ...
 <div>
  <div class="infobox-image [infobox-fixed-size-image]">
   [File:...|class=show-when-light-mode][File:...|class=show-when-dark-mode] <-- Module Image call
  </div>
 </div>
 ...
</div>

would be in line with how other infobox rows are displayed too

Screenshot 2024-04-22 074735
(obviously in this case it would merke the 2 images into 1 since they are the same, just for showcasing with 2 different light/dark mode)

https://liquipedia.net/commons/index.php?title=Module%3AInfobox%2FWidget%2FHeader%2Fdev&type=revision&diff=703437&oldid=703225

tested on sc2 with

  • case with light + dark mode
  • case with only light mode (hence using it for darkmode also
  • case with fixed size (stimpack)

no extra css changes needed (only the one already suggested in the PR)
can probably even kick some css

if tonumber(size) then
size = tonumber(size) .. 'px'
local infoboxImage = mw.html.create('div'):addClass('infobox-image'):addClass(mode)
if Logic.isNumeric(size) then
infoboxImage:addClass('infobox-fixed-size-image')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: infobox stylesheets changes to stylesheets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants