Skip to content

Commit ce2ae8d

Browse files
ktranDevtools-frontend LUCI CQ
authored andcommitted
[docs] Clean up component docs
Fix various things: * wrong tooltip import * BUILD.gn deps * do not rely on #container for styles, but focus on the container element * make render function sync Bug: 414332459 Change-Id: I4098b51d9807694ee51a18df1081bcb005d98eec Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7146226 Auto-Submit: Kim-Anh Tran <[email protected]> Commit-Queue: Kateryna Prokopenko <[email protected]> Commit-Queue: Kim-Anh Tran <[email protected]> Reviewed-by: Kateryna Prokopenko <[email protected]>
1 parent 215999b commit ce2ae8d

File tree

15 files changed

+46
-31
lines changed

15 files changed

+46
-31
lines changed

front_end/ui/components/buttons/Button.docs.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44

55
import {Button, FloatingButton} from './buttons.js';
66

7-
export async function render(container: HTMLElement) {
7+
export function render(container: HTMLElement) {
8+
const buttonDocs = container.createChild('div', 'button-docs');
89
const style = document.createElement('style');
910
style.textContent = `
10-
#container > div {
11+
.button-docs > div {
1112
width: 80%;
1213
padding: var(--sys-size-11);
1314
display: flex;
@@ -16,13 +17,13 @@ export async function render(container: HTMLElement) {
1617
gap: var(--sys-size-5);
1718
}
1819
`;
19-
container.appendChild(style);
20+
buttonDocs.appendChild(style);
2021

2122
const appendSection = (headerText: string, sectionElement: HTMLElement) => {
2223
const header = document.createElement('header');
2324
header.textContent = headerText;
24-
container.appendChild(header);
25-
container.appendChild(sectionElement);
25+
buttonDocs.appendChild(header);
26+
buttonDocs.appendChild(sectionElement);
2627
};
2728

2829
const buttonsSection = document.createElement('div');

front_end/ui/components/expandable_list/BUILD.gn

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
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("../../../../scripts/build/ninja/component_doc.gni")
65
import("../../../../scripts/build/ninja/devtools_entrypoint.gni")
76
import("../../../../scripts/build/ninja/devtools_module.gni")
87
import("../../../../scripts/build/ninja/generate_css.gni")

front_end/ui/components/icon_button/BUILD.gn

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,8 @@ devtools_ui_module("unittests") {
7070

7171
component_doc("docs") {
7272
sources = [ "Icon.docs.ts" ]
73-
deps = [ ":bundle" ]
73+
deps = [
74+
":bundle",
75+
"../../lit:bundle",
76+
]
7477
}

front_end/ui/components/snackbars/Snackbars.docs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import {Snackbar} from './snackbars.js';
66

7-
export async function render(container: HTMLElement) {
7+
export function render(container: HTMLElement) {
88
const onActionClick = (): void => {
99
// eslint-disable-next-line no-console
1010
console.log('Action button clicked!');

front_end/ui/components/spinners/BUILD.gn

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,8 @@ devtools_entrypoint("bundle") {
3131

3232
component_doc("docs") {
3333
sources = [ "Spinners.docs.ts" ]
34-
deps = [ ":bundle" ]
34+
deps = [
35+
":bundle",
36+
"../../../ui/lit:bundle",
37+
]
3538
}

front_end/ui/components/spinners/Spinners.docs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ import * as Lit from '../../lit/lit.js';
88

99
const {html} = Lit;
1010

11-
export async function render(container: HTMLElement) {
11+
export function render(container: HTMLElement) {
1212
Lit.render(html`<devtools-spinner></devtools-spinner>`, container);
1313
}

front_end/ui/components/survey_link/SurveyLink.docs.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
// found in the LICENSE file.
44

55
import * as Common from '../../../core/common/common.js';
6-
import {SurveyLink} from '../survey_link/survey_link.js';
6+
7+
import {SurveyLink} from './survey_link.js';
78

89
export function render(container: HTMLElement): void {
910
const link = new SurveyLink.SurveyLink();

front_end/ui/components/switch/Switch.docs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import {Switch} from './switch.js';
66

7-
export async function render(container: HTMLElement) {
7+
export function render(container: HTMLElement) {
88
function switchExample({checked, disabled}: {checked: boolean, disabled: boolean}): HTMLElement {
99
const example = document.createElement('div');
1010
example.style.marginTop = '20px';

front_end/ui/components/tooltips/BUILD.gn

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,8 @@ devtools_ui_module("unittests") {
4747

4848
component_doc("docs") {
4949
sources = [ "Tooltip.docs.ts" ]
50-
deps = [ ":bundle" ]
50+
deps = [
51+
":bundle",
52+
"../../lit:bundle",
53+
]
5154
}

front_end/ui/components/tooltips/Tooltip.docs.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
import * as Lit from '../../lit/lit.js';
66

7-
import {Tooltip} from './Tooltip.js';
7+
import {Tooltip} from './tooltips.js';
88

99
const {html} = Lit;
1010

11-
export async function render(container: HTMLElement) {
11+
export function render(container: HTMLElement) {
1212
Lit.render(
1313
html`
1414
<div style="position: relative; z-index: 0;">
@@ -44,7 +44,7 @@ export async function render(container: HTMLElement) {
4444
container);
4545

4646
const anchor = container.querySelector('.anchor') as HTMLElement;
47-
const programmaticTooltip = new Tooltip({id: 'programatic', variant: 'rich', anchor});
47+
const programmaticTooltip = new Tooltip.Tooltip({id: 'programatic', variant: 'rich', anchor});
4848
programmaticTooltip.append('Text content');
4949
anchor.insertAdjacentElement('afterend', programmaticTooltip);
5050

0 commit comments

Comments
 (0)