Skip to content

Commit 7d7e34d

Browse files
ktranDevtools-frontend LUCI CQ
authored andcommitted
[uikit] Document Cards component
Bypass-Check-License: Parent CL moving files Bug: 464124169 Change-Id: I62c50305d735039e98d4c0b25013d053f7146fc1 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7207119 Reviewed-by: Kateryna Prokopenko <[email protected]> Commit-Queue: Kim-Anh Tran <[email protected]>
1 parent 6a7805f commit 7d7e34d

File tree

4 files changed

+99
-12
lines changed

4 files changed

+99
-12
lines changed

docs/styleguide/ux/components.md

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,19 +123,10 @@ button.addEventListener('click', event => onClick(event));
123123

124124
### Resources
125125

126-
#### For developers
127-
128-
##### Implementation
129-
130126
* [`devtools-button`](https://source.chromium.org/chromium/chromium/src/+/main:third_party/devtools-frontend/src/front_end/ui/components/buttons/Button.ts)
131-
132-
#### For designers
133-
134-
##### Figma
135-
136-
* [Buttons](https://www.figma.com/design/A5iQBBNAe5zPFpJvUzUgW8/CDT-design-kit?node-id=481-2167&m=dev)
127+
* [Buttons Figma](https://www.figma.com/design/A5iQBBNAe5zPFpJvUzUgW8/CDT-design-kit?node-id=481-2167&m=dev)
137128
* [Icon
138-
buttons](https://www.figma.com/design/A5iQBBNAe5zPFpJvUzUgW8/CDT-design-kit?node-id=571-616&m=dev)
129+
buttons Figma](https://www.figma.com/design/A5iQBBNAe5zPFpJvUzUgW8/CDT-design-kit?node-id=571-616&m=dev)
139130

140131
## Combo Boxes and Single Select menus
141132

@@ -568,3 +559,53 @@ UI.ContextMenu.registerItem({
568559
```
569560

570561
This will automatically add the "Open file" action to the context menu that appears when clicking the Elements panel's 3-dot button.
562+
563+
564+
## Cards
565+
566+
![Card component](images/cards.png)
567+
568+
### Usage
569+
570+
#### Developer guidelines
571+
572+
###### Basic card with heading
573+
574+
Usage with lit-html:
575+
576+
```ts
577+
html`<devtools-card heading="Simple card">
578+
<div class="content">This is a simple card.</div>
579+
</devtools-card>`
580+
```
581+
582+
###### Card without a heading
583+
584+
Usage with lit-html:
585+
586+
```ts
587+
html`<devtools-card>
588+
<div class="content">This is a card without a heading.</div>
589+
</devtools-card>`
590+
```
591+
592+
###### Card with rich heading
593+
594+
Usage with lit-html:
595+
596+
```ts
597+
html`<devtools-card heading="Card with rich heading">
598+
<span slot="heading-prefix">Slotted heading prefix</span>
599+
<span slot="heading-suffix">Slotted heading suffix</span>
600+
<div class="content">This is a card with a rich heading.</div>
601+
</devtools-card>`
602+
```
603+
604+
### Resources
605+
606+
* [`devtools-card`](https://source.chromium.org/chromium/chromium/src/+/main:third_party/devtools-frontend/src/front_end/ui/kit/cards/Card.ts)
607+
* [Component Documentation Example](https://chromedevtools.github.io/devtools-frontend/)
608+
609+
* [Cards Figma](https://www.figma.com/design/A5iQBBNAe5zPFpJvUzUgW8/Chrome-DevTools-Design-Kit?node-id=3456-939)
610+
611+
* [Greenlines](go/chrome-devtools:cards-greenlines)
35.4 KB
Loading

front_end/ui/kit/BUILD.gn

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ devtools_ui_module("unittests") {
5757
}
5858

5959
component_doc("docs") {
60-
sources = [ "icons/Icon.docs.ts" ]
60+
sources = [
61+
"cards/Card.docs.ts",
62+
"icons/Icon.docs.ts",
63+
]
6164
deps = [
6265
":bundle",
6366
"../lit:bundle",
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright 2025 The Chromium Authors
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import '../kit.js';
6+
7+
import * as Lit from '../../lit/lit.js';
8+
9+
const {html} = Lit;
10+
11+
export function render(container: HTMLElement): void {
12+
Lit.render(
13+
html`
14+
<style>
15+
devtools-card {
16+
margin: 1em;
17+
}
18+
.content {
19+
padding: 1em;
20+
}
21+
span {
22+
align-self: center;
23+
}
24+
</style>
25+
<h2>Basic card with heading</h2>
26+
<devtools-card heading="Simple card">
27+
<div class="content">This is a simple card.</div>
28+
</devtools-card>
29+
30+
<h2>Card without a heading</h2>
31+
<devtools-card>
32+
<div class="content">This is a card without a heading.</div>
33+
</devtools-card>
34+
35+
<h2>Card with rich heading</h2>
36+
<devtools-card heading="Card with rich heading">
37+
<span slot="heading-prefix">Slotted heading prefix</span>
38+
<span slot="heading-suffix">Slotted heading suffix</span>
39+
<div class="content">This is a card with a rich heading.</div>
40+
</devtools-card>
41+
`,
42+
container);
43+
}

0 commit comments

Comments
 (0)