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: plugin badge for plugin score gauges #8307

Merged
merged 56 commits into from
Apr 19, 2019

Conversation

connorjclark
Copy link
Collaborator

@connorjclark connorjclark commented Apr 16, 2019

@connorjclark connorjclark requested a review from paulirish as a code owner April 16, 2019 04:31
@googlebot
Copy link

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.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

Copy link
Member

@exterkamp exterkamp left a comment

Choose a reason for hiding this comment

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

LGTM

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.

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);
Copy link
Member

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 :)

Copy link
Collaborator Author

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

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

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

Copy link
Collaborator Author

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

Copy link
Collaborator Author

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.

lighthouse-core/report/html/report-styles.css Show resolved Hide resolved
box-shadow: 0 0 4px rgba(0,0,0,.2);
border-radius: 25%;
}
.lh-category .lh-gauge__wrapper--plugin .lh-gauge__svg-wrapper:before {
Copy link
Member

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. -->
Copy link
Member

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.

Copy link
Member

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fudge it #8390

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.

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 = {
Copy link
Member

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?

Copy link
Collaborator Author

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 */
Copy link
Member

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

Copy link
Collaborator Author

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. -->
Copy link
Member

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 :)

Copy link
Collaborator Author

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);
Copy link
Member

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.

Copy link
Collaborator Author

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
Copy link
Member

@brendankenny brendankenny Apr 19, 2019

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.

Copy link
Collaborator Author

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'));
Copy link
Member

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

Copy link
Collaborator Author

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?

Copy link
Member

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 the lh-scores-header with all the gauges in it.

Copy link
Collaborator Author

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);
Copy link
Member

Choose a reason for hiding this comment

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

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.

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'));
Copy link
Member

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 the lh-scores-header with all the gauges in it.

@brendankenny
Copy link
Member

🧩 📛

@brendankenny brendankenny merged commit 49e7a63 into master Apr 19, 2019
@brendankenny brendankenny deleted the report-ui-plugin-gauge branch April 19, 2019 23:02
@connorjclark connorjclark mentioned this pull request Apr 22, 2019
55 tasks
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.

6 participants