Skip to content

Commit 1906c4c

Browse files
Nancy LiDevtools-frontend LUCI CQ
authored andcommitted
[GM3Restyling] Update the dialog's header/buttons row
Also added more example in components server See design here: https://www.figma.com/design/A5iQBBNAe5zPFpJvUzUgW8/Chrome-DevTools-Design-Kit?node-id=3653-3002&m=dev Bug: 383278166 Change-Id: Iac70968af04b967ae5ec1f5bce0fe04b37096fa3 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6084416 Commit-Queue: Nancy Li <[email protected]> Reviewed-by: Kim-Anh Tran <[email protected]>
1 parent 428dfcf commit 1906c4c

File tree

16 files changed

+83
-9
lines changed

16 files changed

+83
-9
lines changed

front_end/panels/timeline/components/ignoreListSetting.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* found in the LICENSE file.
55
*/
66
.ignore-list-setting-content {
7+
padding: 0 var(--sys-size-8);
78
width: 280px;
89
}
910

front_end/ui/components/dialogs/Dialog.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,8 @@ describe('Dialog', () => {
564564

565565
assert.isNotNull(dialog.shadowRoot);
566566
const dialogHeader = dialog.shadowRoot.querySelector('.dialog-header');
567-
assert.notExists(dialogHeader);
567+
assert.exists(dialogHeader);
568+
assert.isEmpty(dialogHeader.children);
568569
});
569570

570571
it('should render a close button in the dialog if closeButton is true', async () => {

front_end/ui/components/dialogs/Dialog.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,6 @@ export class Dialog extends HTMLElement {
705705
// Disabled until https://crbug.com/1079231 is fixed.
706706
// clang-format off
707707
return html`
708-
<div class="dialog-header">
709708
<span class="dialog-header-text">${this.#props.dialogTitle}</span>
710709
${this.#props.closeButton ? html`
711710
<devtools-button
@@ -718,7 +717,6 @@ export class Dialog extends HTMLElement {
718717
jslog=${VisualLogging.close().track({click: true})}
719718
></devtools-button>
720719
` : LitHtml.nothing}
721-
</div>
722720
`;
723721
// clang-format on
724722
}
@@ -745,7 +743,7 @@ export class Dialog extends HTMLElement {
745743
<dialog @click=${this.#handlePointerEvent} @pointermove=${this.#handlePointerEvent} @cancel=${this.#onCancel}
746744
jslog=${VisualLogging.dialog(this.#props.jslogContext).track({resize: true, keydown: 'Escape'}).parent('mapped')}>
747745
<div id="content">
748-
${this.#renderHeaderRow()}
746+
<div class="dialog-header">${this.#renderHeaderRow()}</div>
749747
<div class='dialog-content'>
750748
<slot></slot>
751749
</div>

front_end/ui/components/dialogs/dialog.css

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,19 @@ dialog:focus-visible {
5555
justify-content: space-between;
5656
align-items: center;
5757
padding: var(--sys-size-5) var(--sys-size-5) var(--sys-size-5) var(--sys-size-8);
58-
}
5958

60-
.dialog-header-text {
61-
font: var(--sys-typescale-body2-medium);
59+
&:empty {
60+
padding: 0;
61+
height: var(--sys-size-7);
62+
}
63+
64+
.dialog-header-text {
65+
font: var(--sys-typescale-body2-medium);
66+
}
6267
}
6368

6469
.dialog-content {
65-
padding: 0 var(--sys-size-8);
70+
padding: 0 0 var(--sys-size-7);
6671
overflow: hidden;
6772
}
6873

front_end/ui/components/dialogs/shortcutDialog.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
flex-direction: column;
2222
/* overwrite default`margin` and `padding` for the <ul> element */
2323
margin: 0;
24-
padding: 0;
24+
padding: 0 var(--sys-size-8);
2525
}
2626

2727
.keybinds-list-item {

front_end/ui/components/docs/dialog/basic.ts

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
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 FrontendHelpers from '../../../../testing/EnvironmentHelpers.js'; // eslint-disable-line rulesdir/es_modules_import
56
import * as Dialogs from '../../../../ui/components/dialogs/dialogs.js';
7+
import * as ComponentHelpers from '../../helpers/helpers.js';
8+
9+
await ComponentHelpers.ComponentServerSetup.setup();
10+
await FrontendHelpers.initializeGlobalVars();
611

712
const showConnectors = [true, false];
813
const verticalPositions = [Dialogs.Dialog.DialogVerticalPosition.TOP, Dialogs.Dialog.DialogVerticalPosition.BOTTOM];
@@ -104,3 +109,66 @@ for (const verticalPosition of verticalPositions) {
104109
i++;
105110
}
106111
}
112+
113+
renderDifferentModeExample();
114+
115+
function renderDifferentModeExample() {
116+
const row = document.createElement('div');
117+
row.classList.add('row');
118+
root.appendChild(row);
119+
renderDialogWithTitle();
120+
renderDialogWithTitleAndCloseButton();
121+
renderDialogWithoutTitleOrCloseButton();
122+
123+
function renderDialog(): Dialogs.Dialog.Dialog {
124+
const dialog = new Dialogs.Dialog.Dialog();
125+
126+
const container = document.createElement('div');
127+
container.classList.add('container');
128+
container.id = `container-${i}`;
129+
130+
const host = document.createElement('div');
131+
host.classList.add('dialog-host-narrow');
132+
host.id = `host-${i}`;
133+
host.textContent = 'H';
134+
135+
container.appendChild(host);
136+
row.appendChild(container);
137+
138+
dialog.position = Dialogs.Dialog.DialogVerticalPosition.BOTTOM;
139+
dialog.horizontalAlignment = Dialogs.Dialog.DialogHorizontalAlignment.AUTO;
140+
dialog.origin = host;
141+
dialog.id = `dialog-${i}`;
142+
143+
host.addEventListener('mouseover', () => {
144+
void dialog.setDialogVisible(true);
145+
});
146+
dialog.addEventListener('clickoutsidedialog', () => {
147+
void dialog.setDialogVisible(false);
148+
});
149+
const div = document.createElement('div');
150+
div.classList.add('dialog-content');
151+
152+
div.innerHTML = 'Hello, World';
153+
dialog.appendChild(div);
154+
root.appendChild(dialog);
155+
i++;
156+
157+
return dialog;
158+
}
159+
160+
function renderDialogWithTitle() {
161+
const dialog = renderDialog();
162+
dialog.dialogTitle = 'title';
163+
}
164+
165+
function renderDialogWithTitleAndCloseButton() {
166+
const dialog = renderDialog();
167+
dialog.dialogTitle = 'title';
168+
dialog.closeButton = true;
169+
}
170+
171+
function renderDialogWithoutTitleOrCloseButton() {
172+
renderDialog();
173+
}
174+
}

front_end/ui/components/docs/dialog/button_dialog.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ buttonDialog.data = {
2323
dialogTitle: 'Button dialog example',
2424
};
2525
const div = document.createElement('div');
26+
div.style.padding = '0 var(--sys-size-8)';
2627
div.createChild('div').innerHTML = 'Hello, World';
2728
div.createChild('div').innerHTML = 'This is a super long content. This is a super long content';
2829
buttonDialog.appendChild(div);
-922 Bytes
Loading
-880 Bytes
Loading
-12 Bytes
Loading

0 commit comments

Comments
 (0)