Skip to content

Commit 5fc11a8

Browse files
ktranDevtools-frontend LUCI CQ
authored andcommitted
[GM3Restyling] Use card components for shortcut settings page
Before: https://i.imgur.com/XEoE5fD.png After: https://i.imgur.com/M5CSvVF.png Bug: 368238837 Change-Id: I6b8fa54418733cd3898947ae91a42ed82351b094 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5952534 Reviewed-by: Kateryna Prokopenko <[email protected]> Commit-Queue: Kim-Anh Tran <[email protected]>
1 parent 541d0fd commit 5fc11a8

File tree

2 files changed

+71
-94
lines changed

2 files changed

+71
-94
lines changed

front_end/panels/settings/KeybindsSettingsTab.ts

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ import * as Host from '../../core/host/host.js';
77
import * as i18n from '../../core/i18n/i18n.js';
88
import * as Platform from '../../core/platform/platform.js';
99
import * as Buttons from '../../ui/components/buttons/buttons.js';
10+
import * as Cards from '../../ui/components/cards/cards.js';
1011
import * as IconButton from '../../ui/components/icon_button/icon_button.js';
1112
import * as UI from '../../ui/legacy/legacy.js';
1213
import * as VisualLogging from '../../ui/visual_logging/visual_logging.js';
1314

1415
import keybindsSettingsTabStyles from './keybindsSettingsTab.css.js';
16+
import settingsScreenStyles from './settingsScreen.css.js';
1517

1618
const UIStrings = {
1719
/**
@@ -108,26 +110,31 @@ export class KeybindsSettingsTab extends UI.Widget.VBox implements UI.ListContro
108110

109111
this.element.setAttribute('jslog', `${VisualLogging.pane('keybinds')}`);
110112

111-
const header = this.contentElement.createChild('header');
112-
header.createChild('h1').textContent = i18nString(UIStrings.shortcuts);
113+
const settingsContent =
114+
this.contentElement.createChild('div', 'settings-card-container-wrapper').createChild('div');
115+
settingsContent.classList.add('settings-card-container');
116+
113117
const keybindsSetSetting = Common.Settings.Settings.instance().moduleSetting('active-keybind-set');
114118
const userShortcutsSetting = Common.Settings.Settings.instance().moduleSetting('user-shortcuts');
115119
keybindsSetSetting.addChangeListener(this.update, this);
116120
const keybindsSetSelect =
117121
UI.SettingsUI.createControlForSetting(keybindsSetSetting, i18nString(UIStrings.matchShortcutsFromPreset));
122+
123+
const card = new Cards.Card.Card();
124+
settingsContent.appendChild(card);
125+
118126
if (keybindsSetSelect) {
119127
keybindsSetSelect.classList.add('keybinds-set-select');
120-
this.contentElement.appendChild(keybindsSetSelect);
121128
}
122129

123130
this.items = new UI.ListModel.ListModel();
124131
this.list = new UI.ListControl.ListControl(this.items, this, UI.ListControl.ListMode.NonViewport);
132+
this.list.element.classList.add('shortcut-list');
125133
this.items.replaceAll(this.createListItems());
126134
UI.ARIAUtils.markAsList(this.list.element);
127135

128-
this.contentElement.appendChild(this.list.element);
129136
UI.ARIAUtils.setLabel(this.list.element, i18nString(UIStrings.keyboardShortcutsList));
130-
const footer = this.contentElement.createChild('div');
137+
const footer = document.createElement('div');
131138
footer.classList.add('keybinds-footer');
132139
const docsLink = UI.XLink.XLink.create(
133140
'https://developer.chrome.com/docs/devtools/shortcuts/', i18nString(UIStrings.FullListOfDevtoolsKeyboard),
@@ -143,29 +150,39 @@ export class KeybindsSettingsTab extends UI.Widget.VBox implements UI.ListContro
143150
this.editingItem = null;
144151
this.editingRow = null;
145152

153+
card.data = {
154+
heading: i18nString(UIStrings.shortcuts),
155+
content: keybindsSetSelect ? [keybindsSetSelect, this.list.element, footer] : [this.list.element, footer],
156+
};
157+
146158
this.update();
147159
}
148160

149161
createElementForItem(item: KeybindsItem): Element {
150-
let itemElement = document.createElement('div');
162+
const itemWrapper = document.createElement('div');
163+
itemWrapper.classList.add('keybinds-list-item-wrapper');
151164

165+
let itemContent;
152166
if (typeof item === 'string') {
153-
UI.ARIAUtils.setLevel(itemElement, 1);
154-
itemElement.classList.add('keybinds-category-header');
155-
itemElement.textContent = UI.ActionRegistration.getLocalizedActionCategory(item);
167+
itemWrapper.classList.add('keybinds-header-wrapper');
168+
UI.ARIAUtils.setLevel(itemWrapper, 1);
169+
itemContent = itemWrapper.createChild('div');
170+
itemContent.classList.add('keybinds-category-header');
171+
itemContent.textContent = UI.ActionRegistration.getLocalizedActionCategory(item);
156172
} else {
157173
const listItem = new ShortcutListItem(item, this, item === this.editingItem);
158-
itemElement = listItem.element;
159-
UI.ARIAUtils.setLevel(itemElement, 2);
174+
itemContent = listItem.element;
175+
UI.ARIAUtils.setLevel(itemContent, 2);
160176
if (item === this.editingItem) {
161177
this.editingRow = listItem;
162178
}
179+
itemContent.classList.add('keybinds-list-item');
180+
itemWrapper.appendChild(itemContent);
163181
}
164182

165-
itemElement.classList.add('keybinds-list-item');
166-
UI.ARIAUtils.markAsListitem(itemElement);
167-
itemElement.tabIndex = item === this.list.selectedItem() && item !== this.editingItem ? 0 : -1;
168-
return itemElement;
183+
UI.ARIAUtils.markAsListitem(itemContent);
184+
itemContent.tabIndex = item === this.list.selectedItem() && item !== this.editingItem ? 0 : -1;
185+
return itemWrapper;
169186
}
170187

171188
commitChanges(
@@ -303,7 +320,7 @@ export class KeybindsSettingsTab extends UI.Widget.VBox implements UI.ListContro
303320
}
304321
override wasShown(): void {
305322
super.wasShown();
306-
this.registerCSSFiles([keybindsSettingsTabStyles]);
323+
this.registerCSSFiles([keybindsSettingsTabStyles, settingsScreenStyles]);
307324
}
308325
}
309326

front_end/panels/settings/keybindsSettingsTab.css

Lines changed: 38 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,9 @@
44
* found in the LICENSE file.
55
*/
66

7-
header {
8-
padding: 0 0 6px;
9-
border-bottom: 1px solid var(--sys-color-divider);
10-
flex: none;
11-
margin-bottom: 16px;
12-
}
13-
14-
h1 {
15-
font-size: 18px;
16-
font-weight: normal;
17-
padding-bottom: 3px;
18-
margin: 0;
19-
}
20-
21-
[role="list"] {
22-
overflow: auto;
23-
24-
> * {
25-
min-width: 300px;
26-
}
7+
.shortcut-list {
8+
padding-left: 0;
9+
padding-right: 0;
2710
}
2811

2912
.keybinds-key {
@@ -42,32 +25,26 @@ h1 {
4225
}
4326

4427
.keybinds-list-item {
45-
min-height: 30px;
28+
margin: 0 var(--sys-size-7);
29+
padding: var(--sys-size-4) 0;
4630
display: grid;
47-
grid-template-rows: repeat(auto-fit, minmax(30px, auto));
31+
grid-template-rows: 1fr ;
4832
grid-template-columns: 1fr 30px 2fr 30px 30px;
49-
flex: auto 1 1;
50-
}
51-
52-
.keybinds-list-item:focus-visible {
53-
background-color: var(--sys-color-tonal-container);
5433
}
5534

5635
.keybinds-list-item:not(.keybinds-category-header) {
57-
padding: 4px 0 4px 20px;
58-
border-radius: 7px;
36+
border-top: 1px solid var(--sys-color-divider);
5937
}
6038

61-
.keybinds-list-item:not(.keybinds-category-header):last-child {
62-
margin-bottom: 5px;
39+
.keybinds-list-item:focus-visible {
40+
background-color: var(--sys-color-tonal-container);
6341
}
6442

6543
.keybinds-list-item.keybinds-editing {
6644
background-color: var(--sys-color-neutral-container);
6745
}
6846

6947
.keybinds-list-text.keybinds-action-name {
70-
padding-top: 7px;
7148
grid-row: 1 / 3;
7249
}
7350

@@ -77,19 +54,6 @@ h1 {
7754
grid-column: 3 / span 1;
7855
}
7956

80-
.keybinds-shortcut.devtools-link {
81-
align-items: center;
82-
margin-left: 3px;
83-
}
84-
85-
.keybinds-shortcut .devtools-link {
86-
padding: 4px 0;
87-
}
88-
89-
.keybinds-info .devtools-link {
90-
padding-top: 6px;
91-
}
92-
9357
.keybinds-error {
9458
color: var(--sys-color-error);
9559
}
@@ -100,21 +64,7 @@ h1 {
10064

10165
.keybinds-modified {
10266
grid-column: 2 / span 1;
103-
margin-top: 2px;
104-
}
105-
106-
.keybinds-list-item button {
107-
border: none;
108-
padding: 0;
109-
background: transparent;
110-
}
111-
112-
.keybinds-list-item button:hover devtools-icon {
113-
color: var(--icon-default-hover);
114-
}
115-
116-
.keybinds-list-item button:focus-visible {
117-
background-color: var(--sys-color-tonal-container);
67+
margin-top: var(--sys-size-3);
11868
}
11969

12070
.keybinds-list-item button[disabled] {
@@ -128,7 +78,7 @@ h1 {
12878
.keybinds-edit-button {
12979
display: none;
13080
grid-row: 1 / span 1;
131-
grid-column: 4 / span 1;
81+
grid-column: 5 / span 1;
13282
}
13383

13484
.keybinds-list-item:not(.keybinds-editing):hover .keybinds-edit-button,
@@ -137,7 +87,9 @@ h1 {
13787
}
13888

13989
.keybinds-list-text {
140-
padding: 3px 0;
90+
min-height: var(--sys-size-12);
91+
display: flex;
92+
align-items: center;
14193
user-select: none;
14294
color: var(--sys-color-on-surface);
14395
text-align: start;
@@ -146,35 +98,28 @@ h1 {
14698
}
14799

148100
.keybinds-category-header {
149-
font-weight: bold;
150-
line-height: 30px;
101+
display: flex;
102+
align-items: center;
103+
font: var(--sys-typescale-body4-bold);
104+
height: var(--sys-size-13);
105+
padding: var(--sys-size-4) var(--sys-size-7);
151106
white-space: nowrap;
152107
}
153108

154-
.keybinds-category-header:not(:nth-child(2)) {
155-
border-top: 1px solid var(--sys-color-divider);
109+
.keybinds-header-wrapper + .keybinds-list-item-wrapper > .keybinds-list-item {
110+
border: none;
156111
}
157112

158-
.keybinds-list-item:not(.keybinds-category-header):hover,
159-
.keybinds-list-item:not(.keybinds-editing):focus-within {
113+
.keybinds-list-item-wrapper:has(:not(.keybinds-category-header):hover),
114+
.keybinds-list-item-wrapper:has(.keybinds-list-item:not(.keybinds-editing)):focus-within {
160115
background: var(--sys-color-state-hover-on-subtle);
161116
}
162117

163-
.keybinds-set-select {
164-
text-align: right;
165-
margin-bottom: 16px;
166-
}
167-
168118
.keybinds-set-select label p {
169119
display: inline;
170120
color: var(--sys-color-on-surface);
171121
}
172122

173-
.keybinds-set-select select {
174-
margin-left: 6px;
175-
margin-top: 6px;
176-
}
177-
178123
button.text-button {
179124
width: fit-content;
180125
align-self: flex-end;
@@ -184,6 +129,20 @@ button.text-button {
184129
margin: 0 2px;
185130
}
186131

132+
.keybinds-set-select {
133+
margin: 0;
134+
padding: var(--sys-size-5) var(--sys-size-7);
135+
136+
& .settings-select {
137+
display: flex;
138+
justify-content: space-between;
139+
140+
& label {
141+
padding: 0;
142+
}
143+
}
144+
}
145+
187146
.keybinds-list-text:has(.keybinds-delete-button) {
188147
grid-column: 3 / -1;
189148
}
@@ -196,6 +155,7 @@ button.text-button {
196155
}
197156

198157
.keybinds-footer {
158+
padding: var(--sys-size-5) var(--sys-size-7);
199159
display: flex;
200160
flex-wrap: wrap;
201161
justify-content: space-between;

0 commit comments

Comments
 (0)