-
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: plugin badge for plugin score gauges #8307
Conversation
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
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.
LGTM
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.
just some nits. then good to go.
@@ -104,6 +104,10 @@ | |||
--env-name-min-width: 220px; | |||
--env-tem-padding: 10px 0px; | |||
--header-padding: 20px 0 20px 0; | |||
--plugin-badge-bg: var(--color-white); | |||
--plugin-badge-size-big: calc(var(--circle-size-big) / 2.7); |
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.
looks like you can drop the -big variant 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.
hmm, can you take another look, b/c this seems necessary to me. the plugin badge is larger for the gauge in the section, so the --plugin-badge-size-big
var is derived from the --circle-size-big
var
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.
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 true.
what i was probably thinking was changing uses of circle-size-big to assign it to circle size:
.lh-category .lh-gauge {
- width: var(--circle-size-big);
- height: var(--circle-size-big);
+ --circle-size: var(--circle-size-big);
}
and then all your base stuff is derived off the same value. :D
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.
ok but i accidentally did it for #8222
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.
btw this specific example didnt work, i think there's a problem with the data dependency of the variables / scope.
box-shadow: 0 0 4px rgba(0,0,0,.2); | ||
border-radius: 25%; | ||
} | ||
.lh-category .lh-gauge__wrapper--plugin .lh-gauge__svg-wrapper:before { |
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.
as mentioned you can remove this now that we're calc() from circle-size
<circle class="lh-gauge-base" r="56" cx="60" cy="60"></circle> | ||
<circle class="lh-gauge-arc" transform="rotate(-90 60 60)" r="56" cx="60" cy="60"></circle> | ||
</svg> | ||
<!-- Wrapper exists for the ::before plugin icon. Cannot create pseudo-elements on svgs. --> |
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.
HTML comments in templates end up in the final report DOM so...
it'd be slightly better to have them on the outide of the (where they are hardly any use.) sucks as I love having these, but they're awkward additions to our shipped DOM.
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.
fuck it lets keep these and remove comment nodes from DOM.cloneTemplate() in a separate PR
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.
fudge it #8390
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.
last things
@@ -14,6 +14,13 @@ const path = require('path'); | |||
const ReportGenerator = require('../../lighthouse-core/report/report-generator.js'); | |||
const lhr = /** @type {LH.Result} */ (require('../../lighthouse-core/test/results/sample_v2.json')); | |||
|
|||
lhr.categories.test = { |
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.
key on categories
should be the same as id
. Not sure we actually depend on that anywhere in the report renderer, but just in case...
can you also add a comment (// Add a plugin to demo plugin rendering
or whatever) and drop a note in #8159 for the feature request?
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
@@ -497,6 +497,32 @@ | |||
animation-delay: 250ms; | |||
} | |||
|
|||
/* The plugin badge overlay */ |
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 comment might make more sense below this, above .lh-gauge__wrapper--plugin
, since all category gauges will have an svg-wrapper
, they just won't have the :before
content
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
<circle class="lh-gauge-base" r="56" cx="60" cy="60"></circle> | ||
<circle class="lh-gauge-arc" transform="rotate(-90 60 60)" r="56" cx="60" cy="60"></circle> | ||
</svg> | ||
<!-- Wrapper exists for the ::before plugin icon. Cannot create pseudo-elements on svgs. --> |
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.
should stick to either :before
or ::before
in comments and in the stylesheet :)
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
@@ -144,6 +144,17 @@ describe('CategoryRenderer', () => { | |||
|
|||
const audits = categoryDOM.querySelectorAll('.lh-audit'); | |||
assert.equal(audits.length, category.auditRefs.length, 'renders correct number of audits'); | |||
|
|||
assert.equal(categoryDOM.querySelector('.lh-gauge__wrapper--plugin'), null); |
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.
a string explanation like the above asserts would be nice (or a comment, but when in Rome, etc). No plugin categories in the sample results.
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
it('plugin category has plugin badge', () => { | ||
const category = JSON.parse( | ||
JSON.stringify(sampleResults.reportCategories.find(c => c.id === 'seo'))); | ||
// Any category not of the core |
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.
not sure what this comment means :)
Be bloody, bold, and resolute; laugh to scorn
The power of core, for none of plugin born
Shall harm the test.
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 must have left for lunch mid-comment :)
just gonna delete this.
// Any category not of the core | ||
category.id = 'lighthouse-plugin-someplugin'; | ||
const categoryDOM = renderer.render(category, sampleResults.categoryGroups); | ||
assert.ok(categoryDOM.querySelector('.lh-gauge__wrapper--plugin')); |
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.
maybe assert slightly more...e.g. there's only one plugin wrapper in the categoryDOM
, and pluginWrapper.querySelector('.lh-gauge__label').textContent
is the category's title
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.
There's only one category gauge being rendered here, so there's could only be the one wrapper to assert on. I think your advice makes sense only if this test was rendering the whole report?
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.
There's only one category gauge being rendered here, so there's could only be the one wrapper to assert on. I think your advice makes sense only if this test was rendering the whole report?
oh yeah :)
- the
.lh-gauge__label
check still makes sense, though, and that reminds me - we should have another test similar to this but out in
report-renderer-test.js
, since report-renderer is in charge of rendering thelh-scores-header
with all the gauges in it.
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
@@ -104,6 +104,10 @@ | |||
--env-name-min-width: 220px; | |||
--env-tem-padding: 10px 0px; | |||
--header-padding: 20px 0 20px 0; | |||
--plugin-badge-bg: var(--color-white); | |||
--plugin-badge-size-big: calc(var(--circle-size-big) / 2.7); |
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.
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.
last test request, but otherwise LGTM!
// Any category not of the core | ||
category.id = 'lighthouse-plugin-someplugin'; | ||
const categoryDOM = renderer.render(category, sampleResults.categoryGroups); | ||
assert.ok(categoryDOM.querySelector('.lh-gauge__wrapper--plugin')); |
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.
There's only one category gauge being rendered here, so there's could only be the one wrapper to assert on. I think your advice makes sense only if this test was rendering the whole report?
oh yeah :)
- the
.lh-gauge__label
check still makes sense, though, and that reminds me - we should have another test similar to this but out in
report-renderer-test.js
, since report-renderer is in charge of rendering thelh-scores-header
with all the gauges in it.
🧩 📛 |
#8185