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: support narrow screens #6857

Merged
merged 3 commits into from
Jan 4, 2019
Merged

report: support narrow screens #6857

merged 3 commits into from
Jan 4, 2019

Conversation

exterkamp
Copy link
Member

Transition from full width to >500px
mobile_view
minimum width without horizontal scroll (400px):
screen shot 2018-12-20 at 5 53 04 pm
minimum width without horizontal scroll (1 category):
screen shot 2018-12-20 at 5 53 55 pm

Related Issues/PRs
fixes #6645

@@ -118,6 +118,8 @@ class ReportUIFeatures {
onMediaQueryChange(mql) {
const root = this._dom.find('.lh-root', this._document);
root.classList.toggle('lh-narrow', mql.matches);
// Reset animations for the narrow view header height change.
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

@@ -226,8 +228,8 @@ class ReportUIFeatures {
this.headerSticky.style.transform = `translateY(${heightDiff * scrollPct * -1}px)`;
this.headerBackground.style.transform = `translateY(${scrollPct * this.headerOverlap}px)`;
this.lighthouseIcon.style.transform =
`translate3d(var(--report-width-half),` +
` calc(-100% - ${scrollPct * this.headerOverlap * -1}px), 0) scale(${1 - scrollPct})`;
`translate3d(0,` +
Copy link
Collaborator

Choose a reason for hiding this comment

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

you might have to explain this one to me :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Since the lh-lighthouse element is inside the header container now it doesn't need to be translated on the x axis since it is positioned absolutely to the bottom right corner.

Copy link
Collaborator

@patrickhulce patrickhulce Dec 21, 2018

Choose a reason for hiding this comment

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

and the 100% is gone because of the bottom right corner position too?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup, it had -100% on in the .lh-lighthouse class to position it before, so the new anchoring doesn't need it.

@@ -728,6 +731,7 @@

.lh-report {
background-color: #fff;
min-width: var(--report-min-width);
Copy link
Collaborator

Choose a reason for hiding this comment

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

this used to be only @media screen do we still want to keep that or doesn't matter?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm, I don't think it really matters. I moved it here because I felt like it was always true for every screen not just max-width: 964px but I'm not sure it matters?

top: var(--report-header-height);
right: 50%;
transform: translate3d(var(--report-width-half), -100%, 0);
bottom: -4px;
Copy link
Collaborator

Choose a reason for hiding this comment

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

bottom -4?

Copy link
Member Author

Choose a reason for hiding this comment

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

The lighthouse SVG element is 4px above the bottom of the svg's wrapper div (which in this screenshot is set to 0px bottom) so I moved it 4px down to match the header height exactly. I tried to fix the SVG but hand editing an SVG proved a bit difficult. So I moved the whole thing 4 px down.
image

.lh-lighthouse {
position: absolute;
top: var(--report-header-height);
right: 50%;
transform: translate3d(var(--report-width-half), -100%, 0);
Copy link
Collaborator

Choose a reason for hiding this comment

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

seems like these all changed because lh-lighthouse moved inside the header. what does that get us and do we know if there's a reason it was outside it to begin with? :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Should have included a screenshot of the current UI:
image
Since the lighthouse isn't tied to the bottom right of the header container it doesn't scale correctly on small screens and clips off the edge like so!

Copy link
Member

@paulirish paulirish left a comment

Choose a reason for hiding this comment

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

lgtm % nit

@@ -164,11 +164,13 @@
width: 100%;
will-change: transform;
}
.lh-narrow .lh-header-bg {
height: var(--report-header-height-narrow);
Copy link
Member

Choose a reason for hiding this comment

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

eh. i dont think we need this. the jump is a bit awkward and putting the LH behind the text isn't terrible:
image

but if you wanted to avoid that.. we could do max-width: 60%; on .lh-config
image

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

two nits (that may or may not be correct :) but otherwise LGTM! 🔛

@paulirish paulirish merged commit d7a344c into master Jan 4, 2019
@paulirish paulirish deleted the mobile-report branch January 4, 2019 01:19
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.

Lighthouse report shows horizontal scrollbar on mobile
4 participants