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

Move result details to top level #1166

Merged
merged 1 commit into from
Mar 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/page-experience/lib/PageExperienceGuide.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ const CHECK_DIR = path.join(__dirname, 'checks');
*/
class Recommendations {
constructor() {
this.results = {};
this.results = {
details: {},
};
this.currentCheck = '';
}

Expand All @@ -48,6 +50,10 @@ class Recommendations {
this.addResult('FAIL', result);
}

addDetails(details) {
this.results.details[this.currentCheck] = details;
}

addResult(status, result) {
result.status = status;
this.results[this.currentCheck] = result;
Expand Down
12 changes: 6 additions & 6 deletions packages/page-experience/lib/checks/fontDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ const checkDisplayOptional = (pageData, result) => {
title: 'Improve LCP and CLS using `font-display: optional`',
url: 'https://web.dev/optimize-webfont-loading/',
message: `Load the critical webfonts using \`font-display: optional\` to improve LCP on slow connections and avoid content shifts.`,
details: {
headings: [
{label: 'Font', valueType: 'text', key: 'font'},
{key: 'fix', valueType: 'text', label: 'Suggestion'},
],
},
});
result.addDetails({
headings: [
{label: 'Font', valueType: 'text', key: 'font'},
{key: 'fix', valueType: 'text', label: 'Suggestion'},
],
items,
});
};
Expand Down
12 changes: 6 additions & 6 deletions packages/page-experience/lib/checks/fontPreloading.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ const checkPreloads = (pageData, result) => {
url: 'https://web.dev/optimize-webfont-loading/',
message:
'Preload critical fonts to help the browser discover fonts used in the first viewport quicker.',
details: {
headings: [
{label: 'Font', valueType: 'text', key: 'font'},
{key: 'fix', valueType: 'text', label: 'Suggestion'},
],
},
});
result.addDetails({
headings: [
{label: 'Font', valueType: 'text', key: 'font'},
{key: 'fix', valueType: 'text', label: 'Suggestion'},
],
items,
});
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"details": {}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
"fontDisplay": {
"title": "Improve LCP and CLS using `font-display: optional`",
"url": "https://web.dev/optimize-webfont-loading/",
"message": "Load the critical webfonts using `font-display: optional` to improve LCP on slow connections and avoid content shifts.",
"details": {
"details": {
"fontDisplay": {
"headings": [
{
"label": "Font",
Expand All @@ -15,14 +12,19 @@
"valueType": "text",
"label": "Suggestion"
}
],
"items": [
{
"font": "Open Sans",
"fix": "Add the `&display=optional` parameter to the end of your Google Font import declaration ([read more](https://web.dev/font-display/#google-fonts))."
}
]
},
"items": [
{
"font": "Open Sans",
"fix": "Add the `&display=optional` parameter to the end of your Google Font import declaration ([read more](https://web.dev/font-display/#google-fonts))."
}
],
}
},
"fontDisplay": {
"title": "Improve LCP and CLS using `font-display: optional`",
"url": "https://web.dev/optimize-webfont-loading/",
"message": "Load the critical webfonts using `font-display: optional` to improve LCP on slow connections and avoid content shifts.",
"status": "WARN"
}
}
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"details": {}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
"fontDisplay": {
"title": "Improve LCP and CLS using `font-display: optional`",
"url": "https://web.dev/optimize-webfont-loading/",
"message": "Load the critical webfonts using `font-display: optional` to improve LCP on slow connections and avoid content shifts.",
"details": {
"details": {
"fontDisplay": {
"headings": [
{
"label": "Font",
Expand All @@ -15,14 +12,19 @@
"valueType": "text",
"label": "Suggestion"
}
],
"items": [
{
"font": "Open Sans",
"fix": "Add `font-display: optional` to your font-face declaration."
}
]
},
"items": [
{
"font": "Open Sans",
"fix": "Add `font-display: optional` to your font-face declaration."
}
],
}
},
"fontDisplay": {
"title": "Improve LCP and CLS using `font-display: optional`",
"url": "https://web.dev/optimize-webfont-loading/",
"message": "Load the critical webfonts using `font-display: optional` to improve LCP on slow connections and avoid content shifts.",
"status": "WARN"
}
}
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"details": {}
}
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"details": {}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
"fontDisplay": {
"title": "Improve LCP and CLS using `font-display: optional`",
"url": "https://web.dev/optimize-webfont-loading/",
"message": "Load the critical webfonts using `font-display: optional` to improve LCP on slow connections and avoid content shifts.",
"details": {
"details": {
"fontDisplay": {
"headings": [
{
"label": "Font",
Expand All @@ -15,14 +12,19 @@
"valueType": "text",
"label": "Suggestion"
}
],
"items": [
{
"font": "Open Sans",
"fix": "Add `font-display: optional` to your font-face declaration."
}
]
},
"items": [
{
"font": "Open Sans",
"fix": "Add `font-display: optional` to your font-face declaration."
}
],
}
},
"fontDisplay": {
"title": "Improve LCP and CLS using `font-display: optional`",
"url": "https://web.dev/optimize-webfont-loading/",
"message": "Load the critical webfonts using `font-display: optional` to improve LCP on slow connections and avoid content shifts.",
"status": "WARN"
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
"fontPreloading": {
"title": "Preload critical fonts",
"url": "https://web.dev/optimize-webfont-loading/",
"message": "Preload critical fonts to help the browser discover fonts used in the first viewport quicker.",
"details": {
"details": {
"fontPreloading": {
"headings": [
{
"label": "Font",
Expand All @@ -15,14 +12,19 @@
"valueType": "text",
"label": "Suggestion"
}
],
"items": [
{
"font": "Open Sans",
"fix": "Add `<link rel=\"preload\" href=\"file:///fonts/OpenSans-Regular-webfont.woff2\" as=\"font\" crossorigin>` to your `<head>`."
}
]
},
"items": [
{
"font": "Open Sans",
"fix": "Add `<link rel=\"preload\" href=\"file:///fonts/OpenSans-Regular-webfont.woff2\" as=\"font\" crossorigin>` to your `<head>`."
}
],
}
},
"fontPreloading": {
"title": "Preload critical fonts",
"url": "https://web.dev/optimize-webfont-loading/",
"message": "Preload critical fonts to help the browser discover fonts used in the first viewport quicker.",
"status": "WARN"
}
}
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"details": {}
}
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"details": {}
}
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"details": {}
}
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"details": {}
}