Skip to content

Commit 1d0c2db

Browse files
Adam RaineDevtools-frontend LUCI CQ
authored andcommitted
[RPP Observations] Improve help links
- Reintroduce textual local/field help link but smaller - Add (?) buttons for each metric only visible on hover - Move the network cache tooltip to the checkbox and label https://screenshot.googleplex.com/ALg4pwyLgCrss3s Bug: 362252927 Change-Id: I5759c70dee25740d282323b9d1adfbcb1a6644e3 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5983127 Reviewed-by: Paul Irish <[email protected]> Commit-Queue: Adam Raine <[email protected]>
1 parent e99cccf commit 1d0c2db

File tree

8 files changed

+91
-45
lines changed

8 files changed

+91
-45
lines changed

front_end/core/common/SettingRegistration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ export interface SettingRegistration {
302302
*/
303303
export interface LearnMore {
304304
tooltip: () => Platform.UIString.LocalizedString;
305-
url: Platform.DevToolsPath.UrlString;
305+
url?: Platform.DevToolsPath.UrlString;
306306
}
307307

308308
interface LocalizedSettingExtensionOption {

front_end/core/sdk/sdk-meta.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,11 @@ const UIStrings = {
315315
*/
316316
enableRemoteFileLoading:
317317
'Allow `DevTools` to load resources, such as source maps, from remote file paths. Disabled by default for security reasons.',
318+
/**
319+
* @description Tooltip text for a setting that controls the network cache. Disabling the network cache can simulate the network connections of users that are visiting a page for the first time.
320+
*/
321+
networkCacheExplanation:
322+
'Disabling the network cache will simulate a network experience similar to a first time visitor.',
318323
};
319324
const str_ = i18n.i18n.registerUIStrings('core/sdk/sdk-meta.ts', UIStrings);
320325
const i18nLazyString = i18n.i18n.getLazilyComputedLocalizedString.bind(undefined, str_);
@@ -1040,6 +1045,9 @@ Common.Settings.registerSettingExtension({
10401045
title: i18nLazyString(UIStrings.enableCache),
10411046
},
10421047
],
1048+
learnMore: {
1049+
tooltip: i18nLazyString(UIStrings.networkCacheExplanation),
1050+
},
10431051
});
10441052

10451053
Common.Settings.registerSettingExtension({

front_end/panels/timeline/components/LiveMetricsView.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ describeWithMockConnection('LiveMetricsView', () => {
729729
assert.match(fieldMessage!.innerText, /See how your local metrics compare/);
730730

731731
const title = getLiveMetricsTitle(view);
732-
assert.strictEqual(title.innerText, 'Local metrics ');
732+
assert.strictEqual(title.innerText, 'Local metrics');
733733
});
734734

735735
it('should show when crux is enabled', async () => {
@@ -760,7 +760,7 @@ describeWithMockConnection('LiveMetricsView', () => {
760760
assert.match(fieldMessage!.innerText, /Jan.+2024/);
761761

762762
const title = getLiveMetricsTitle(view);
763-
assert.strictEqual(title.innerText, 'Local and field metrics ');
763+
assert.strictEqual(title.innerText, 'Local and field metrics');
764764
});
765765

766766
it('should show empty values when crux is enabled but there is no field data', async () => {
@@ -784,7 +784,7 @@ describeWithMockConnection('LiveMetricsView', () => {
784784
assert.match(fieldMessage!.textContent!, /Not enough data/);
785785

786786
const title = getLiveMetricsTitle(view);
787-
assert.strictEqual(title.innerText, 'Local and field metrics ');
787+
assert.strictEqual(title.innerText, 'Local and field metrics');
788788
});
789789

790790
it('should make initial request on render when crux is enabled', async () => {

front_end/panels/timeline/components/LiveMetricsView.ts

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import '../../../ui/components/menus/menus.js';
1010
import './MetricCard.js';
1111

1212
import * as Common from '../../../core/common/common.js';
13-
import * as Host from '../../../core/host/host.js';
1413
import * as i18n from '../../../core/i18n/i18n.js';
1514
import type * as Platform from '../../../core/platform/platform.js';
1615
import type * as SDK from '../../../core/sdk/sdk.js';
@@ -175,11 +174,6 @@ const UIStrings = {
175174
* @description Text for a link that is inserted inside a larger text block that explains how to simulate different mobile and desktop devices.
176175
*/
177176
simulateDifferentDevices: 'simulate different devices',
178-
/**
179-
* @description Tooltip text that explains how disabling the network cache can simulate the network connections of users that are visiting a page for the first time.
180-
*/
181-
networkCacheExplanation:
182-
'Disabling the network cache will simulate a network experience similar to a first time visitor.',
183177
/**
184178
* @description Text label for a checkbox that controls if the network cache is disabled.
185179
*/
@@ -220,11 +214,15 @@ const UIStrings = {
220214
* @example {Chrome UX Report} PH1
221215
*/
222216
seeHowYourLocalMetricsCompare: 'See how your local metrics compare to real user data in the {PH1}.',
217+
/**
218+
* @description Text for a link that goes to more documentation about local and field data. "Local" refers to performance metrics measured in the developers local environment. "field data" is data measured by real users in the field.
219+
*/
220+
localFieldLearnMoreLink: 'Learn more about local and field data',
223221
/**
224222
* @description Tooltip text for a link that goes to documentation explaining the difference between local and field metrics. "Local metrics" are performance metrics measured in the developers local environment. "field data" is data measured by real users in the field.
225223
*/
226-
learnMoreAboutMetrics:
227-
'Local metrics are captured from the current page using your network connection and device. Field data is measured by real users using many different network connections and devices. Click to learn more about local and field metrics.',
224+
localFieldLearnMoreTooltip:
225+
'Local metrics are captured from the current page using your network connection and device. Field data is measured by real users using many different network connections and devices.',
228226
/**
229227
* @description Tooltip text explaining that this user interaction was ignored when calculating the Interaction to Next Paint (INP) metric because the interaction delay fell beyond the 98th percentile of interaction delays on this page. "INP" is an acronym and should not be translated.
230228
*/
@@ -664,12 +662,7 @@ export class LiveMetricsView extends LegacyWrapper.LegacyWrapper.WrappableCompon
664662
textOverride: i18nString(UIStrings.disableNetworkCache),
665663
} as Settings.SettingCheckbox.SettingCheckboxData}
666664
></setting-checkbox>
667-
<devtools-icon
668-
class="setting-hint"
669-
name="help"
670-
title=${i18nString(UIStrings.networkCacheExplanation)}
671-
></devtools-icon>
672-
</div>
665+
</div>
673666
`;
674667
// clang-format on
675668
}
@@ -1106,18 +1099,8 @@ export class LiveMetricsView extends LegacyWrapper.LegacyWrapper.WrappableCompon
11061099
const output = html`
11071100
<div class="container">
11081101
<div class="live-metrics-view">
1109-
<main class="live-metrics"
1110-
>
1111-
<h2 class="section-title">
1112-
${liveMetricsTitle}
1113-
<devtools-button
1114-
class="section-title-help"
1115-
title=${i18nString(UIStrings.learnMoreAboutMetrics)}
1116-
.iconName=${'help'}
1117-
.variant=${Buttons.Button.Variant.ICON}
1118-
@click=${() => Host.InspectorFrontendHost.InspectorFrontendHostInstance.openInNewTab(helpLink)}
1119-
></devtools-button>
1120-
</h2>
1102+
<main class="live-metrics">
1103+
<h2 class="section-title">${liveMetricsTitle}</h2>
11211104
<div class="metric-cards"
11221105
on-render=${ComponentHelpers.Directives.nodeRenderedCallback(node => {
11231106
this.#tooltipContainerEl = node;
@@ -1133,6 +1116,11 @@ export class LiveMetricsView extends LegacyWrapper.LegacyWrapper.WrappableCompon
11331116
${this.#renderInpCard()}
11341117
</div>
11351118
</div>
1119+
<x-link
1120+
href=${helpLink}
1121+
class="local-field-link"
1122+
title=${i18nString(UIStrings.localFieldLearnMoreTooltip)}
1123+
>${i18nString(UIStrings.localFieldLearnMoreLink)}</x-link>
11361124
${this.#renderLogSection()}
11371125
</main>
11381126
<aside class="next-steps" aria-labelledby="next-steps-section-title">

front_end/panels/timeline/components/MetricCard.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
import * as Host from '../../../core/host/host.js';
56
import * as i18n from '../../../core/i18n/i18n.js';
67
import * as Platform from '../../../core/platform/platform.js';
78
import * as CrUXManager from '../../../models/crux-manager/crux-manager.js';
9+
import * as Buttons from '../../../ui/components/buttons/buttons.js';
810
import * as ComponentHelpers from '../../../ui/components/helpers/helpers.js';
911
import * as LitHtml from '../../../ui/lit-html/lit-html.js';
1012

@@ -121,6 +123,20 @@ const UIStrings = {
121123
* @description Column header for table cell values representing a phase duration (in milliseconds) that was measured in the developers local environment.
122124
*/
123125
duration: 'Local duration (ms)',
126+
/**
127+
* @description Tooltip text for a link that goes to documentation explaining the Largest Contentful Paint (LCP) metric. "LCP" is an acronym and should not be translated.
128+
*/
129+
lcpHelpTooltip:
130+
'LCP reports the render time of the largest image, text block, or video visible in the viewport. Click here to learn more about LCP.',
131+
/**
132+
* @description Tooltip text for a link that goes to documentation explaining the Cumulative Layout Shift (CLS) metric. "CLS" is an acronym and should not be translated.
133+
*/
134+
clsHelpTooltip: 'CLS measures the amount of unexpected shifted content. Click here to learn more about CLS.',
135+
/**
136+
* @description Tooltip text for a link that goes to documentation explaining the Interaction to Next Paint (INP) metric. "INP" is an acronym and should not be translated.
137+
*/
138+
inpHelpTooltip:
139+
'INP measures the overall responsiveness to all click, tap, and keyboard interactions. Click here to learn more about INP.',
124140
};
125141

126142
const str_ = i18n.i18n.registerUIStrings('panels/timeline/components/MetricCard.ts', UIStrings);
@@ -291,6 +307,28 @@ export class MetricCard extends HTMLElement {
291307
}
292308
}
293309

310+
#getHelpLink(): Platform.DevToolsPath.UrlString {
311+
switch (this.#data.metric) {
312+
case 'LCP':
313+
return 'https://web.dev/articles/lcp' as Platform.DevToolsPath.UrlString;
314+
case 'CLS':
315+
return 'https://web.dev/articles/cls' as Platform.DevToolsPath.UrlString;
316+
case 'INP':
317+
return 'https://web.dev/articles/inp' as Platform.DevToolsPath.UrlString;
318+
}
319+
}
320+
321+
#getHelpTooltip(): string {
322+
switch (this.#data.metric) {
323+
case 'LCP':
324+
return i18nString(UIStrings.lcpHelpTooltip);
325+
case 'CLS':
326+
return i18nString(UIStrings.clsHelpTooltip);
327+
case 'INP':
328+
return i18nString(UIStrings.inpHelpTooltip);
329+
}
330+
}
331+
294332
#getLocalValue(): number|undefined {
295333
const {localValue} = this.#data;
296334
if (localValue === undefined) {
@@ -579,12 +617,20 @@ export class MetricCard extends HTMLElement {
579617

580618
#render = (): void => {
581619
const fieldEnabled = CrUXManager.CrUXManager.instance().getConfigSetting().get().enabled;
620+
const helpLink = this.#getHelpLink();
582621

583622
// clang-format off
584623
const output = html`
585624
<div class="metric-card">
586625
<h3 class="title">
587626
${this.#getTitle()}
627+
<devtools-button
628+
class="title-help"
629+
title=${this.#getHelpTooltip()}
630+
.iconName=${'help'}
631+
.variant=${Buttons.Button.Variant.ICON}
632+
@click=${() => Host.InspectorFrontendHost.InspectorFrontendHostInstance.openInNewTab(helpLink)}
633+
></devtools-button>
588634
</h3>
589635
<div tabindex="0" class="metric-values-section"
590636
@mouseenter=${() => this.#showTooltip(500)}

front_end/panels/timeline/components/liveMetricsView.css

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,6 @@
7373
margin-bottom: 10px;
7474
}
7575

76-
.section-title-help {
77-
height: var(--sys-typescale-headline4-line-height);
78-
vertical-align: top;
79-
}
80-
8176
.settings-card {
8277
border-radius: var(--sys-shape-corner-small);
8378
padding: 14px 16px 16px;
@@ -135,6 +130,10 @@
135130
min-width: 0;
136131
}
137132

133+
.local-field-link {
134+
margin-top: 8px;
135+
}
136+
138137
.logs-section {
139138
margin-top: 24px;
140139
display: flex;
@@ -293,13 +292,6 @@ x-link { /* stylelint-disable-line selector-type-no-unknown */
293292
margin-top: 8px;
294293
}
295294

296-
.setting-hint {
297-
margin-left: 6px;
298-
vertical-align: bottom;
299-
height: 18px;
300-
width: 18px;
301-
}
302-
303295
.environment-recs-title {
304296
margin-top: 12px;
305297
font-weight: var(--ref-typeface-weight-medium);
@@ -336,7 +328,7 @@ x-link { /* stylelint-disable-line selector-type-no-unknown */
336328

337329
.phase-table {
338330
border-top: 1px solid var(--sys-color-divider);
339-
padding: 7px 0;
331+
padding: 7px 4px;
340332
margin-left: var(--phase-table-margin);
341333
}
342334

front_end/panels/timeline/components/metricCard.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,27 @@
1010
background-color: var(--sys-color-surface3);
1111
height: 100%;
1212
box-sizing: border-box;
13+
14+
&:not(:hover) .title-help {
15+
visibility: hidden;
16+
}
1317
}
1418

1519
.title {
20+
display: flex;
21+
justify-content: space-between;
1622
font-size: var(--sys-typescale-headline5-size);
1723
line-height: var(--sys-typescale-headline5-line-height);
1824
font-weight: var(--ref-typeface-weight-medium);
1925
margin: 0;
2026
margin-bottom: 6px;
2127
}
2228

29+
.title-help {
30+
height: var(--sys-typescale-headline5-line-height);
31+
margin-left: 4px;
32+
}
33+
2334
.metric-values-section {
2435
position: relative;
2536
display: flex;

front_end/ui/components/settings/SettingCheckbox.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ export class SettingCheckbox extends HTMLElement {
6969
}
7070

7171
const learnMore = this.#setting.learnMore();
72-
if (learnMore) {
72+
if (learnMore && learnMore.url) {
73+
const url = learnMore.url;
7374
const data: Buttons.Button.ButtonData = {
7475
iconName: 'help',
7576
variant: Buttons.Button.Variant.ICON,
@@ -78,7 +79,7 @@ export class SettingCheckbox extends HTMLElement {
7879
title: i18nString(UIStrings.learnMore),
7980
};
8081
const handleClick = (event: MouseEvent): void => {
81-
Host.InspectorFrontendHost.InspectorFrontendHostInstance.openInNewTab(learnMore.url);
82+
Host.InspectorFrontendHost.InspectorFrontendHostInstance.openInNewTab(url);
8283
event.consume();
8384
};
8485
return html`<devtools-button

0 commit comments

Comments
 (0)