Skip to content

Commit 0eeab74

Browse files
ktranDevtools-frontend LUCI CQ
authored andcommitted
[GM3Restyling] Update Network throttling settings page
This CL introduces cards to the network throttling settings page. Before: https://i.imgur.com/xsinva9.png After: https://i.imgur.com/9mTc2Sc.png Bug: 368238837 Change-Id: I74f855f2e42aa8b37529e755c08bd0ad77aa7776 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5993273 Reviewed-by: Kateryna Prokopenko <[email protected]> Commit-Queue: Kim-Anh Tran <[email protected]>
1 parent bd2c504 commit 0eeab74

File tree

3 files changed

+31
-33
lines changed

3 files changed

+31
-33
lines changed

front_end/panels/mobile_throttling/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ devtools_module("mobile_throttling") {
2727
"../../core/host:bundle",
2828
"../../core/i18n:bundle",
2929
"../../core/sdk:bundle",
30+
"../../ui/components/cards:bundle",
3031
"../../ui/components/icon_button:bundle",
3132
"../../ui/legacy:bundle",
3233
"../../ui/visual_logging:bundle",

front_end/panels/mobile_throttling/ThrottlingSettingsTab.ts

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,23 @@
55
import * as Common from '../../core/common/common.js';
66
import * as i18n from '../../core/i18n/i18n.js';
77
import type * as SDK from '../../core/sdk/sdk.js';
8+
import * as Buttons from '../../ui/components/buttons/buttons.js';
9+
import * as Cards from '../../ui/components/cards/cards.js';
810
import * as UI from '../../ui/legacy/legacy.js';
911
import * as VisualLogging from '../../ui/visual_logging/visual_logging.js';
12+
import settingsScreenStyles from '../settings/settingsScreen.css.js';
1013

1114
import throttlingSettingsTabStyles from './throttlingSettingsTab.css.js';
1215

1316
const UIStrings = {
1417
/**
1518
*@description Text in Throttling Settings Tab of the Network panel
1619
*/
17-
networkThrottlingProfiles: 'Network Throttling Profiles',
20+
networkThrottlingProfiles: 'Network throttling profiles',
1821
/**
1922
*@description Text of add conditions button in Throttling Settings Tab of the Network panel
2023
*/
21-
addCustomProfile: 'Add custom profile...',
24+
addCustomProfile: 'Add profile',
2225
/**
2326
*@description A value in milliseconds
2427
*@example {3} PH1
@@ -129,21 +132,30 @@ export class ThrottlingSettingsTab extends UI.Widget.VBox implements
129132

130133
this.element.setAttribute('jslog', `${VisualLogging.pane('throttling-conditions')}`);
131134

132-
const header = this.contentElement.createChild('div', 'header');
133-
header.textContent = i18nString(UIStrings.networkThrottlingProfiles);
134-
UI.ARIAUtils.markAsHeading(header, 1);
135-
136-
const addButton =
137-
UI.UIUtils.createTextButton(i18nString(UIStrings.addCustomProfile), this.addButtonClicked.bind(this), {
138-
className: 'add-conditions-button',
139-
jslogContext: 'network.add-conditions',
140-
});
141-
this.contentElement.appendChild(addButton);
142-
135+
const settingsContent =
136+
this.contentElement.createChild('div', 'settings-card-container-wrapper').createChild('div');
137+
settingsContent.classList.add('settings-card-container', 'ignore-list-settings');
138+
139+
const addButton = new Buttons.Button.Button();
140+
addButton.classList.add('add-conditions-button');
141+
addButton.data = {
142+
variant: Buttons.Button.Variant.OUTLINED,
143+
iconName: 'plus',
144+
jslogContext: 'network.add-conditions',
145+
};
146+
addButton.textContent = i18nString(UIStrings.addCustomProfile);
147+
addButton.addEventListener('click', () => this.addButtonClicked());
148+
149+
const listContainer = settingsContent.createChild('div');
150+
const card = new Cards.Card.Card();
151+
settingsContent.appendChild(card);
152+
card.data = {
153+
heading: i18nString(UIStrings.networkThrottlingProfiles),
154+
content: [listContainer, addButton],
155+
};
143156
this.list = new UI.ListWidget.ListWidget(this);
144157
this.list.element.classList.add('conditions-list');
145-
146-
this.list.show(this.contentElement);
158+
this.list.show(listContainer);
147159

148160
this.customSetting = Common.Settings.Settings.instance().moduleSetting('custom-network-conditions');
149161
this.customSetting.addChangeListener(this.conditionsUpdated, this);
@@ -154,7 +166,7 @@ export class ThrottlingSettingsTab extends UI.Widget.VBox implements
154166
override wasShown(): void {
155167
super.wasShown();
156168
this.list.registerCSSFiles([throttlingSettingsTabStyles]);
157-
this.registerCSSFiles([throttlingSettingsTabStyles]);
169+
this.registerCSSFiles([throttlingSettingsTabStyles, settingsScreenStyles]);
158170
this.conditionsUpdated();
159171
}
160172

front_end/panels/mobile_throttling/throttlingSettingsTab.css

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,12 @@
44
* found in the LICENSE file.
55
*/
66

7-
:host {
8-
overflow: hidden;
9-
}
10-
11-
.header {
12-
padding: 0 0 6px;
13-
border-bottom: 1px solid var(--sys-color-divider);
14-
font-size: 18px;
15-
font-weight: normal;
16-
flex: none;
17-
}
187

198
.add-conditions-button {
20-
flex: none;
21-
margin: 10px 5px;
22-
min-width: 140px;
23-
align-self: flex-start;
9+
border: none;
2410
}
2511

2612
.conditions-list {
27-
min-width: 640px;
2813
flex: auto;
2914
}
3015

@@ -57,7 +42,7 @@
5742
.conditions-list-title {
5843
text-align: start;
5944
display: flex;
60-
flex: auto;
45+
flex-grow: 1;
6146
align-items: flex-start;
6247
}
6348

0 commit comments

Comments
 (0)