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

report: vertically center thumbnails #11220

Merged
merged 4 commits into from
Aug 6, 2020

Conversation

lemcardenas
Copy link
Contributor

@lemcardenas lemcardenas commented Aug 4, 2020

Summary

This PR addresses #11218 to vertically center thumbnails with respect to their rows in the lighthouse report.

Needed to merge #11217

previously:
image
with this change:
Screen Shot 2020-08-05 at 1 10 43 PM
Related Issues/PRs

#11217 #11218

@lemcardenas lemcardenas requested a review from a team as a code owner August 4, 2020 21:59
@lemcardenas lemcardenas requested review from brendankenny and removed request for a team August 4, 2020 21:59
@lemcardenas lemcardenas linked an issue Aug 4, 2020 that may be closed by this pull request
@@ -1410,6 +1411,9 @@
width: var(--image-preview-size);
height: var(--image-preview-size);
display: block;
position: absolute;
Copy link
Collaborator

@connorjclark connorjclark Aug 4, 2020

Choose a reason for hiding this comment

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

could you try using flexbox instead?

https://css-tricks.com/snippets/css/a-guide-to-flexbox/

should be something like set display: flex; align-items: center on .lh-table-column--url

Copy link
Contributor Author

@lemcardenas lemcardenas Aug 4, 2020

Choose a reason for hiding this comment

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

yeah, using display: flex was my original approach but I missed using it on .lh-table-column--url because it wasn't working, I'll fix it!

Copy link
Contributor Author

@lemcardenas lemcardenas Aug 5, 2020

Choose a reason for hiding this comment

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

update @connorjclark so when I tried to use display: flex; align-items: center; on .lh-table-column--url or .lh-table .lh-table-column--thumbnail I wasn't getting any movement, I couldn't find the official docs for it but this post suggests that using align-items only works if we explicitly sized the height of the container which I don't think we do

When I tried to check if explicitly sizing a column entry helped, it did center the child element within the parent container, but then the row was not evenly centered, as some elements had different column heights than others

The other method I tried out did not use any flexboxes at all and only involved overriding .lh-table tr's vertical-align: baseline to be vertical-align: middle in .lh-table .lh-table-column--thumbnail. This generally worked well:
Screen Shot 2020-08-04 at 5 21 46 PM

Is the vertical-align method fine or should I continue looking at flexbox methods?

Copy link
Collaborator

Choose a reason for hiding this comment

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

this post suggests that using align-items only works if we explicitly sized the height of the container which I don't think we do

that doesn't seem right. for example, lh-load-opportunity__col is a flex container using align-items w/o an explicit height, and it works.

I forgot that flex doesn't work to well within table elements. https://stackoverflow.com/a/41421700/2788187 .

given all this... I suppose the original PR wfm

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't pretend to know CSS too well, but I just nerdsniped myself and am going to read through https://www.w3.org/Style/CSS/read.en.html over the next couple weeks ..

@lemcardenas
Copy link
Contributor Author

lemcardenas commented Aug 5, 2020

the first attempt on this PR used position: relative + position: absolute which worked when the thumbnails were smaller than the other columns of information:
vert-centered-thumbnails

However, when the thumbnails were larger than the other columns of information we had this behavior:
image

The second method used vertical-align: middle in .lh-table .lh-table-column--thumbnail, overriding its inherited vertical-align: baseline.
Screen Shot 2020-08-04 at 5 21 46 PM

The third method and preferred method so far involved replacing .lh-table tr's vertical-align: baseline with vertical-align: middle:
Screen Shot 2020-08-05 at 1 10 43 PM

However, this third method vertically centers all rows in the report tables, so the following changes would also happen throughout the report:
original:
Screen Shot 2020-08-05 at 1 16 23 PM
new: (note the shift in Element and 0.061)
Screen Shot 2020-08-05 at 1 16 59 PM

Additionally, it looks like with vertical-align: middle, thumbnails do not bleed over rows if the other elements are smaller in height than the thumbnail:
Screen Shot 2020-08-05 at 2 15 40 PM

@vercel vercel bot temporarily deployed to Preview August 5, 2020 21:17 Inactive
@connorjclark connorjclark merged commit 47a1b47 into master Aug 6, 2020
@connorjclark connorjclark deleted the vert-center-report-thumbnails branch August 6, 2020 17:51
radum added a commit to radum/lighthouse that referenced this pull request Aug 13, 2020
* upstream/master: (42 commits)
  docs: add Code of Conduct to project (GoogleChrome#11212)
  docs(readme): add related project: lighthouse-viewer (GoogleChrome#11250)
  core(font-size): remove deprecated DOM.getFlattenedDocument (GoogleChrome#11248)
  misc: fix typo in method name (GoogleChrome#11239)
  i18n: make double dollar validation less strict (GoogleChrome#10299)
  misc: rephrase comments to be more inclusive (GoogleChrome#11228)
  misc: tweak gcp scripts to work in google corp (GoogleChrome#11233)
  v6.2.0 (GoogleChrome#11232)
  report: correctly display CLS in budget table (GoogleChrome#11209)
  report: vertically center thumbnails (GoogleChrome#11220)
  i18n: import (GoogleChrome#11225)
  tests: istanbul ignore inpage function (GoogleChrome#11229)
  deps(snyk): update script to prune <0.0.0 and update snapshot (GoogleChrome#11223)
  core(stacks): timeout stack detection (GoogleChrome#11172)
  core(config): unsized-images to default (GoogleChrome#11217)
  core(image-elements): collect CSS sizing, ShadowRoot, & position (GoogleChrome#11188)
  core: add FormElements gatherer (GoogleChrome#11062)
  new_audit: report animations not run on compositor (GoogleChrome#11105)
  tests: update chromestatus expecatations (GoogleChrome#11221)
  deps: update dot-prop secondary dependency (GoogleChrome#11198)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

report thumbnail should be centered
5 participants