-
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
feat: add groups to config, accessibility renderer #2057
Conversation
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.
This is neat.
lighthouse-core/config/config.js
Outdated
@@ -568,6 +569,11 @@ class Config { | |||
get categories() { | |||
return this._categories; | |||
} | |||
|
|||
/** @type {Object<{title: string, description: string}>} */ |
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.
closure noob here. can this be:{{title: string, description: string}}
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.
it's an object where the values are {title: string, description: string}
but IIRC we actually need Object<string,{title: string, description: string}>
now, will update
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.
Ah! That makes more sense :)
lighthouse-core/config/default.js
Outdated
{"id": "bypass", "weight": 1, "tags": ["accessibility-describe-contents"]}, | ||
{"id": "color-contrast", "weight": 1, "tags": ["accessibility-color-contrast"]}, | ||
{"id": "definition-list", "weight": 1, "tags": ["accessibility-well-structured"]}, | ||
{"id": "dlitem", "weight": 1, "tags": ["accessibility-well-structured"]}, |
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.
nit: we could shorten these to a11y-*
. Doesn't all this stuff end up in our json dump?
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.
done, yep it does
@@ -142,7 +142,16 @@ class CategoryRenderer { | |||
* @param {!ReportRenderer.CategoryJSON} category | |||
* @return {!Element} | |||
*/ | |||
render(category) { | |||
render(category, tags) { |
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.
tags needs a doc string
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.
done
} | ||
} | ||
|
||
_renderDefaultCategory(category) { |
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.
docs
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.
done
@@ -167,6 +176,69 @@ class CategoryRenderer { | |||
element.appendChild(passedElem); | |||
return element; | |||
} | |||
|
|||
_renderAuditGroup(audits, tag) { |
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.
docs
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.
done
const auditGroupHeader = this._dom.createElement('div', 'lh-audit-group__header'); | ||
auditGroupHeader.textContent = tag.title; | ||
|
||
const auditGroupDescription = this._dom.createElement('div', 'lh-audit-group__description'); |
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.
you can style the details arrow like the rest by adding a selector like
lighthouse/lighthouse-core/report/v2/report-styles.css
Lines 228 to 234 in 2ae69be
.lh-score__snippet::-moz-list-bullet { | |
display: none; | |
} | |
.lh-score__snippet::-webkit-details-marker { | |
display: none; | |
} |
lighthouse/lighthouse-core/report/v2/templates.html
Lines 19 to 22 in 2ae69be
<summary class="lh-score__snippet"> | |
<span class="lh-score__title"><!-- fill me --></span> | |
<div class="lh-score__arrow" title="See audits"></div> | |
</summary> |
lh-score__arrow
is the gem.
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.
I saw that but wasn't convinced we wanted to reuse those, lh-score
gives me the idea that it's a scored thing specific to audit or category when these are just display groupings. If we want to reuse the same CSS, maybe we can extract it to a different distinct reusable component without tying the category/audit dependency?
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.
Yea, we can rename the CSS if you need to.
"distinct reusable component"....interesting idea. Tell me more :)
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.
"distinct reusable component"....interesting idea. Tell me more
hahaha, I've never had anything against organization of code into components :)
return auditGroupElem; | ||
} | ||
|
||
_renderAccessibilityCategory(category, tags) { |
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.
docs
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.
done
} | ||
|
||
.lh-audit-group__summary::-webkit-details-marker { | ||
float: right; |
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.
i dont think you need these styles if using lh-score__arrow
Yeah we should, fixed |
Also now noticing the arrow don't turn. They're always in the down state: You need some of
|
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.
how do you feel about tests for this
lighthouse-core/config/config.js
Outdated
@@ -568,6 +569,11 @@ class Config { | |||
get categories() { | |||
return this._categories; | |||
} | |||
|
|||
/** @type {Object<string, {title: string, description: string}>} */ |
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.
I don't believe this would be nullable. Is it |undefined
?
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.
if we're bein' real it's *
for most of these defs since the config can stick whatever it wants here ;) but yeah could be undefined I'll add
lighthouse-core/config/default.js
Outdated
{"id": "valid-lang", "weight": 1}, | ||
{"id": "video-caption", "weight": 1}, | ||
{"id": "video-description", "weight": 1}, | ||
{"id": "accesskeys", "weight": 1, "tags": ["a11y-correct-attributes"]}, |
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.
- since this is scoped, should we just call this
group
or something? - since we're only supporting the first entry, should we just drop the array?
- since we're requiring a tag for accessibility audits, should there be a check with a clear warning?
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.
I'm against doing a one off config thing per category when we can re-use the same concept, but are you proposing just renaming tags
-> groups
?
since we're requiring a tag for accessibility audits, should there be a check with a clear warning?
sure
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.
since we're only supporting the first entry, should we just drop the array?
accessibility only uses one, but forcing one already seems bad when we just planned last week to achieve the PWA goals with multiple tags on a one
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.
brendan is thinking group
making it 1:1 instead of 1:many. So each a11y audit only belongs to a single group. Same with perf.
Doing this means we wouldn't have the ability for an audit to live in two "groups", but that seems decent for now. I can't think of where we actually NEED the extensibility of 1audit:many tags.
So perhaps it's better to keep it simple for now.
@patrickhulce is there a 1:many usecase you're keeping in mind?
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.
I had thought we decided to use tags in the certifications
-style rendition of PWA checklist, but if that's a totally distinct "tag" so to speak then I'm down with 1:1 group
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.
talked to paul, I was hearing/thinking random things. certifications are to be totally separate from tags (phew!) and group sgtm 👍
Ah interesting. Looks like we need to be more specific with our selectors for the arrows....now that there are sub sub arrows :) Changing to this works: |
yup that's what I got now :) |
like we should definitely have some 👍 |
PTAL this is blocking #2111 :) |
understood, I'm just thinking if we only have like three uses of this hardcoded into each categoryRenderer, having a generic |
lgtm on groups refactor |
@brendankenny you appeased? :) |
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.
sweet, LGTM
ELL GEE TEE EMM |
addresses topics item in #1937
I'd prefer to leave UI bikeshedding for when we implement the real version that's going in DevTools, but here's a screenshot