Skip to content

Commit a82b6b1

Browse files
committed
Split widgets page into one subpage per widget
Change-Id: Ifbd87d724ea27e285c89a2b80af3b198a7326944
1 parent 387c8c9 commit a82b6b1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+3744
-2254
lines changed

python/tools/check_ratchet.py

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

3737
from dataclasses import dataclass
3838

39-
EXPECTED_ANY_COUNT = 39
39+
EXPECTED_ANY_COUNT = 37
4040
EXPECTED_RUN_METRIC_COUNT = 4
4141

4242
ROOT_DIR = os.path.dirname(

ui/src/assets/widgets/editor.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,8 @@
2323
font-size: 13px;
2424
}
2525
}
26+
27+
&--fill-height {
28+
height: 100%;
29+
}
2630
}

ui/src/assets/widgets/nodegraph.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
// limitations under the License.
1414

1515
.pf-canvas {
16-
height: 100%;
1716
overflow: hidden;
1817
background: linear-gradient(
1918
0deg,
@@ -31,6 +30,11 @@
3130
user-select: none;
3231
font-family: var(--pf-font-compact);
3332
cursor: grab;
33+
height: 450px; // Give the canvas some intrinsic height by default
34+
35+
&--fill-height {
36+
height: 100%;
37+
}
3438
}
3539

3640
.pf-canvas-content {

ui/src/plugins/dev.perfetto.WidgetsPage/data_grid_demo.ts

Lines changed: 0 additions & 72 deletions
This file was deleted.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// Copyright (C) 2025 The Android Open Source Project
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
import m from 'mithril';
16+
import {Anchor} from '../../../widgets/anchor';
17+
import {renderWidgetShowcase} from '../widgets_page_utils';
18+
import {Icons} from '../../../base/semantic_icons';
19+
20+
export function anchor(): m.Children {
21+
return [
22+
m(
23+
'.pf-widget-intro',
24+
m('h1', 'Anchor'),
25+
m('p', [
26+
'A hyperlink with a builtin icon to navigate to external or internal resources.',
27+
]),
28+
),
29+
30+
renderWidgetShowcase({
31+
renderWidget: ({icon, showInlineWithText, long}) =>
32+
m('', [
33+
showInlineWithText && 'Inline ',
34+
m(
35+
Anchor,
36+
{
37+
icon: icon ? Icons.ExternalLink : undefined,
38+
href: 'https://perfetto.dev/docs/',
39+
target: '_blank',
40+
},
41+
long
42+
? 'This is some really really really long text and hopefully it will overflow the container in order to demonstrate how long text within anchors behaves.'
43+
: 'Link',
44+
),
45+
showInlineWithText && ' text',
46+
]),
47+
48+
initialOpts: {
49+
icon: true,
50+
showInlineWithText: false,
51+
long: false,
52+
},
53+
}),
54+
];
55+
}
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
// Copyright (C) 2025 The Android Open Source Project
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
import m from 'mithril';
16+
import {Button, ButtonVariant} from '../../../widgets/button';
17+
import {CodeSnippet} from '../../../widgets/code_snippet';
18+
import {Intent} from '../../../widgets/common';
19+
import {EnumOption, renderWidgetShowcase} from '../widgets_page_utils';
20+
21+
export function renderButtonDemo(): m.Children {
22+
return [
23+
m(
24+
'.pf-widget-intro',
25+
m('h1', 'Button'),
26+
m('p', [
27+
'A versatile button component with multiple variants, intents, and states. ',
28+
'Supports icons, loading states, and can be grouped with other buttons.',
29+
]),
30+
),
31+
32+
renderWidgetShowcase({
33+
renderWidget: ({
34+
label,
35+
icon,
36+
rightIcon,
37+
showAsGrid,
38+
showInlineWithText,
39+
...rest
40+
}) =>
41+
showAsGrid
42+
? m(
43+
'',
44+
{
45+
style: {
46+
display: 'grid',
47+
gridTemplateColumns: 'auto auto auto',
48+
gap: '4px',
49+
},
50+
},
51+
Object.values(Intent).map((intent) => {
52+
return Object.values(ButtonVariant).map((variant) => {
53+
return m(Button, {
54+
style: {
55+
width: '80px',
56+
},
57+
...rest,
58+
label: variant,
59+
variant,
60+
intent,
61+
});
62+
});
63+
}),
64+
)
65+
: m('', [
66+
showInlineWithText && 'Inline ',
67+
m(Button, {
68+
icon: icon ? 'send' : undefined,
69+
rightIcon: rightIcon ? 'arrow_forward' : undefined,
70+
label: (label ? 'Button' : undefined) as string,
71+
onclick: () => console.log('button pressed'),
72+
...rest,
73+
}),
74+
showInlineWithText && ' text',
75+
]),
76+
initialOpts: {
77+
label: true,
78+
icon: true,
79+
rightIcon: false,
80+
disabled: false,
81+
intent: new EnumOption(Intent.None, Object.values(Intent)),
82+
active: false,
83+
compact: false,
84+
loading: false,
85+
variant: new EnumOption(
86+
ButtonVariant.Filled,
87+
Object.values(ButtonVariant),
88+
),
89+
showAsGrid: false,
90+
showInlineWithText: false,
91+
rounded: false,
92+
},
93+
}),
94+
95+
m('.pf-widget-doc-section', [
96+
m('h2', 'Basic Usage'),
97+
m('p', 'Create buttons with labels, icons, or both:'),
98+
m(CodeSnippet, {
99+
text: `// Simple button with label
100+
m(Button, {
101+
label: 'Click me',
102+
onclick: () => console.log('clicked'),
103+
})
104+
105+
// Button with icon
106+
m(Button, {
107+
icon: 'send',
108+
label: 'Send',
109+
onclick: handleSend,
110+
})
111+
112+
// Icon-only button
113+
m(Button, {
114+
icon: 'delete',
115+
onclick: handleDelete,
116+
})`,
117+
language: 'typescript',
118+
}),
119+
]),
120+
121+
m('.pf-widget-doc-section', [
122+
m('h2', 'Variants & Intents'),
123+
m('p', 'Buttons come in multiple visual styles:'),
124+
m(CodeSnippet, {
125+
text: `// Variants
126+
m(Button, {label: 'Filled', variant: ButtonVariant.Filled})
127+
m(Button, {label: 'Outlined', variant: ButtonVariant.Outlined})
128+
m(Button, {label: 'Subtle', variant: ButtonVariant.Subtle})
129+
130+
// Intents (colors)
131+
m(Button, {label: 'Primary', intent: Intent.Primary})
132+
m(Button, {label: 'Danger', intent: Intent.Danger})`,
133+
language: 'typescript',
134+
}),
135+
]),
136+
137+
m('.pf-widget-doc-section', [
138+
m('h2', 'Key Features'),
139+
m('ul', [
140+
m('li', [
141+
m('strong', 'Multiple Variants: '),
142+
'Filled, Outlined, and Subtle styles for different visual weights',
143+
]),
144+
m('li', [
145+
m('strong', 'Intent Colors: '),
146+
'Primary, Danger, and default intents for semantic meaning',
147+
]),
148+
m('li', [
149+
m('strong', 'Icons: '),
150+
'Left icon, right icon, or icon-only buttons',
151+
]),
152+
m('li', [
153+
m('strong', 'States: '),
154+
'Active, disabled, and loading states',
155+
]),
156+
m('li', [
157+
m('strong', 'Compact Mode: '),
158+
'Smaller padding for dense UIs',
159+
]),
160+
m('li', [
161+
m('strong', 'Rounded: '),
162+
'Circular icon buttons for floating actions',
163+
]),
164+
m('li', [
165+
m('strong', 'Button Groups: '),
166+
'Group related buttons with ButtonGroup or SegmentedButtons',
167+
]),
168+
]),
169+
]),
170+
];
171+
}

0 commit comments

Comments
 (0)