Skip to content

Commit 7fdc2ab

Browse files
ktranDevtools-frontend LUCI CQ
authored andcommitted
[GM3Restyling] Update Sources empty state
Before: https://i.imgur.com/6EpbdAN.png After: https://i.imgur.com/eYALTcc.png Bug: 325443331 Change-Id: I5cd7567783b4ae7f7b8ea1edcbb9792c5aafd623 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6190541 Reviewed-by: Kateryna Prokopenko <[email protected]> Commit-Queue: Kim-Anh Tran <[email protected]>
1 parent ce79c48 commit 7fdc2ab

File tree

2 files changed

+98
-37
lines changed

2 files changed

+98
-37
lines changed

front_end/panels/sources/SourcesView.ts

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import * as SDK from '../../core/sdk/sdk.js';
1212
import * as Bindings from '../../models/bindings/bindings.js';
1313
import * as Persistence from '../../models/persistence/persistence.js';
1414
import * as Workspace from '../../models/workspace/workspace.js';
15+
import * as IconButton from '../../ui/components/icon_button/icon_button.js';
1516
import * as QuickOpen from '../../ui/legacy/components/quick_open/quick_open.js';
1617
import * as SourceFrame from '../../ui/legacy/components/source_frame/source_frame.js';
1718
import * as UI from '../../ui/legacy/legacy.js';
@@ -145,45 +146,53 @@ export class SourcesView extends Common.ObjectWrapper.eventMixin<EventTypes, typ
145146
}
146147

147148
private placeholderElement(): Element {
149+
const placeholder = document.createElement('div');
150+
151+
const workspaceElement = placeholder.createChild('div', 'tabbed-pane-placeholder-row');
152+
workspaceElement.classList.add('workspace');
153+
154+
const icon = IconButton.Icon.create('sync', 'sync-icon');
155+
workspaceElement.createChild('span', 'icon-container').appendChild(icon);
156+
const text = workspaceElement.createChild('span');
157+
text.textContent = UIStrings.workspaceDropInAFolderToSyncSources;
158+
const browseButton = text.createChild('button');
159+
browseButton.textContent = i18nString(UIStrings.selectFolder);
160+
browseButton.addEventListener('click', this.addFileSystemClicked.bind(this));
161+
148162
const shortcuts = [
149163
{actionId: 'quick-open.show', description: i18nString(UIStrings.openFile)},
150164
{actionId: 'quick-open.show-command-menu', description: i18nString(UIStrings.runCommand)},
151-
{
152-
actionId: 'sources.add-folder-to-workspace',
153-
description: i18nString(UIStrings.workspaceDropInAFolderToSyncSources),
154-
isWorkspace: true,
155-
},
156165
];
157166

158-
const list = document.createElement('div');
167+
const list = placeholder.createChild('div', 'shortcuts-list');
168+
list.classList.add('tabbed-pane-placeholder-row');
159169
UI.ARIAUtils.markAsList(list);
160170
UI.ARIAUtils.setLabel(list, i18nString(UIStrings.sourceViewActions));
161171

162172
for (const shortcut of shortcuts) {
163-
const shortcutKeyText = UI.ShortcutRegistry.ShortcutRegistry.instance().shortcutTitleForAction(shortcut.actionId);
164-
const listItemElement = list.createChild('div', 'tabbed-pane-placeholder-row');
173+
const shortcutKeys = UI.ShortcutRegistry.ShortcutRegistry.instance().shortcutsForAction(shortcut.actionId);
174+
const listItemElement = list.createChild('div');
175+
listItemElement.classList.add('shortcut-line');
176+
165177
UI.ARIAUtils.markAsListitem(listItemElement);
166-
if (shortcutKeyText) {
167-
const title = listItemElement.createChild('span');
168-
title.textContent = shortcutKeyText;
169178

179+
// Take the first shortcut for display.
180+
if (shortcutKeys && shortcutKeys[0]) {
170181
const button = listItemElement.createChild('button');
171182
button.textContent = shortcut.description;
172183
const action = UI.ActionRegistry.ActionRegistry.instance().getAction(shortcut.actionId);
173184
button.addEventListener('click', () => action.execute());
174-
}
175-
176-
if (shortcut.isWorkspace) {
177-
const workspace = listItemElement.createChild('span', 'workspace');
178-
workspace.textContent = shortcut.description;
179185

180-
const browseButton = workspace.createChild('button');
181-
browseButton.textContent = i18nString(UIStrings.selectFolder);
182-
browseButton.addEventListener('click', this.addFileSystemClicked.bind(this));
186+
const shortcutElement = listItemElement.createChild('span', 'shortcuts');
187+
const separator = Host.Platform.isMac() ? '\u2004' : ' + ';
188+
const keys = shortcutKeys[0].descriptors.flatMap(descriptor => descriptor.name.split(separator));
189+
keys.forEach(key => {
190+
shortcutElement.createChild('span', 'keybinds-key').createChild('span').textContent = key;
191+
});
183192
}
184193
}
185194

186-
return list;
195+
return placeholder;
187196
}
188197

189198
private async addFileSystemClicked(): Promise<void> {

front_end/ui/legacy/tabbedPane.css

Lines changed: 69 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,28 +46,79 @@
4646
}
4747

4848
.tabbed-pane-placeholder {
49-
font-size: 14px;
5049
text-align: center;
51-
width: fit-content;
52-
margin: 40px auto 0;
53-
text-shadow: var(--color-background-opacity-80) 0 1px 0;
54-
line-height: 28px;
50+
display: flex;
51+
align-items: center;
52+
justify-content: center;
53+
width: 100%;
54+
height: 100%;
5555
}
5656

5757
.tabbed-pane-placeholder-row {
58-
margin-inline: 10px;
59-
60-
& span {
61-
display: inline-block;
62-
padding-inline: 10px;
58+
max-width: var(--sys-size-32);
59+
min-width: var(--sys-size-28);
60+
margin: 0 var(--sys-size-8);
61+
62+
&.workspace {
63+
display: inline-flex;
64+
align-items: center;
65+
border: var(--sys-size-2) dashed var(--sys-color-divider);
66+
padding: var(--sys-size-8);
67+
border-radius: var(--sys-shape-corner-medium);
68+
margin-bottom: var(--sys-size-11);
69+
70+
> .icon-container {
71+
flex-shrink: 0;
72+
width: var(--sys-size-13);
73+
height: var(--sys-size-13);
74+
background: var(--sys-color-tonal-container);
75+
align-content: center;
76+
border-radius: var(--sys-shape-corner-full);
77+
margin-right: var(--sys-size-8);
78+
79+
> devtools-icon {
80+
color: var(--sys-color-on-tonal-container);
81+
}
82+
}
6383
}
6484

65-
&:has(.workspace) {
66-
max-width: 400px;
67-
border: 2px dashed var(--sys-color-neutral-outline);
68-
margin-block-start: 20px;
69-
padding: 10px;
70-
margin-inline: 20px;
85+
&.shortcuts-list {
86+
padding: 0 var(--sys-size-6);
87+
88+
.shortcut-line {
89+
display: grid;
90+
grid-template-columns: 1fr 1fr;
91+
grid-column-gap: var(--sys-size-10);
92+
padding: var(--sys-size-4) 0;
93+
94+
&:not(:last-child) {
95+
border-bottom: var(--sys-size-1) solid var(--sys-color-divider);
96+
}
97+
98+
.shortcuts {
99+
display: flex;
100+
flex-direction: row;
101+
gap: var(--sys-size-4);
102+
align-items: center;
103+
}
104+
105+
.keybinds-key {
106+
display: flex;
107+
align-items: center;
108+
justify-content: center;
109+
height: var(--sys-size-11);
110+
min-width: var(--sys-size-11);
111+
font: var(--sys-typescale-body5-medium);
112+
white-space: nowrap;
113+
border-radius: var(--sys-shape-corner-small);
114+
background: var(--sys-color-tonal-container);
115+
padding: 0 var(--sys-size-4);
116+
}
117+
118+
& button {
119+
margin-inline: 0;
120+
}
121+
}
71122
}
72123

73124
& button {
@@ -77,7 +128,8 @@
77128
border: none;
78129
padding: 0;
79130
text-decoration: underline;
80-
margin-inline: 5px;
131+
margin-inline: var(--sys-size-3);
132+
text-align: left;
81133

82134
&:focus-visible {
83135
outline: 2px solid var(--sys-color-state-focus-ring);

0 commit comments

Comments
 (0)