-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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: metric toggle without JS #8844
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,10 +58,6 @@ class ReportUIFeatures { | |
this.stickyHeaderEl; // eslint-disable-line no-unused-expressions | ||
/** @type {HTMLElement} */ | ||
this.highlightEl; // eslint-disable-line no-unused-expressions | ||
/** @type {HTMLInputElement} */ | ||
this.metricDescriptionToggleEl; // eslint-disable-line no-unused-expressions | ||
/** @type {HTMLElement} */ | ||
this.metricAuditGroup; // eslint-disable-line no-unused-expressions | ||
|
||
this.onMediaQueryChange = this.onMediaQueryChange.bind(this); | ||
this.onCopy = this.onCopy.bind(this); | ||
|
@@ -74,7 +70,6 @@ class ReportUIFeatures { | |
this.expandAllDetails = this.expandAllDetails.bind(this); | ||
this._toggleDarkTheme = this._toggleDarkTheme.bind(this); | ||
this._updateStickyHeaderOnScroll = this._updateStickyHeaderOnScroll.bind(this); | ||
this._toggleMetricDescription = this._toggleMetricDescription.bind(this); | ||
} | ||
|
||
/** | ||
|
@@ -97,7 +92,6 @@ class ReportUIFeatures { | |
this._document.addEventListener('copy', this.onCopy); | ||
this._document.addEventListener('scroll', this._updateStickyHeaderOnScroll); | ||
window.addEventListener('resize', this._updateStickyHeaderOnScroll); | ||
this._setupMetricDescriptionToggleElements(); | ||
const topbarLogo = this._dom.find('.lh-topbar__logo', this._document); | ||
topbarLogo.addEventListener('click', this._toggleDarkTheme); | ||
} | ||
|
@@ -260,26 +254,6 @@ class ReportUIFeatures { | |
this._copyAttempt = false; | ||
} | ||
|
||
_setupMetricDescriptionToggleElements() { | ||
const metricDescriptionToggleEl = this._document.querySelector('.lh-metrics-toggle__input'); | ||
// No metrics if performance category wasn't run. | ||
if (!metricDescriptionToggleEl) return; | ||
|
||
this.metricDescriptionToggleEl = /** @type {HTMLInputElement} */ (metricDescriptionToggleEl); | ||
this.metricAuditGroup = this._dom.find('.lh-audit-group--metrics', this._document); | ||
this.metricDescriptionToggleEl.addEventListener('input', this._toggleMetricDescription); | ||
this.metricAuditGroup.addEventListener('click', e => { | ||
const el = /** @type {HTMLElement} */ (e.target); | ||
if (el.closest('.lh-metric__title')) this.metricDescriptionToggleEl.click(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we lose this click behavior now IMO, it was a little wonky anyhoo so not the biggest loss but something to consider 🤷♂ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we agreed to remove this thing separately. connor's PR also nukes it |
||
}); | ||
} | ||
|
||
_toggleMetricDescription() { | ||
this.metricDescriptionToggleEl.blur(); | ||
const show = this.metricDescriptionToggleEl.checked; | ||
this.metricAuditGroup.classList.toggle('lh-audit-group--metrics__show-descriptions', show); | ||
} | ||
|
||
/** | ||
* Copies the report JSON to the clipboard (if supported by the browser). | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did we lose a little padding by removing this nesting layer? feels a bit close now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx.