Skip to content

Commit 191d1be

Browse files
committed
feat: add action to list view item
1 parent f75873f commit 191d1be

File tree

3 files changed

+38
-13
lines changed

3 files changed

+38
-13
lines changed

.changeset/neat-crabs-make.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@scouterna/ui-webc": minor
3+
---
4+
5+
Add action to list view item.

packages/ui-webc/src/components/list-view-item/list-view-item.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ import {
77
Prop,
88
} from "@stencil/core";
99

10+
import ChevronRightIcon from "@tabler/icons/outline/chevron-right.svg";
11+
1012
export type ItemType = "button" | "link" | "radio" | "checkbox";
1113

14+
export type ActionType = "chevron" | null;
15+
1216
@Component({
1317
tag: "scout-list-view-item",
1418
styleUrl: "list-view-item.css",
@@ -22,6 +26,13 @@ export class ScoutListViewItem {
2226
@Prop() secondary?: string;
2327
@Prop() type: ItemType = "button";
2428

29+
/**
30+
* The action to display on the right side of the item. For example, a
31+
* chevron. This is purely visual and does not affect the behavior of the item
32+
* in any way. Not visible when the type is "radio" or "checkbox".
33+
*/
34+
@Prop() action: ActionType = null;
35+
2536
@Prop() href?: string;
2637
@Prop() target?: string;
2738
@Prop() rel?: string;
@@ -109,6 +120,14 @@ export class ScoutListViewItem {
109120
);
110121
}
111122

123+
if (this.action === "chevron") {
124+
return (
125+
<div class="suffix-icon">
126+
<div class="icon" style={{ "--icon": `url(${ChevronRightIcon})` }} />
127+
</div>
128+
);
129+
}
130+
112131
return null;
113132
}
114133
}

packages/ui-webc/src/components/list-view-item/readme.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,20 @@
55

66
## Properties
77

8-
| Property | Attribute | Description | Type | Default |
9-
| ----------- | ----------- | ----------- | --------------------------------------------- | ----------- |
10-
| `checked` | `checked` | | `boolean` | `undefined` |
11-
| `disabled` | `disabled` | | `boolean` | `undefined` |
12-
| `href` | `href` | | `string` | `undefined` |
13-
| `icon` | `icon` | | `string` | `undefined` |
14-
| `name` | `name` | | `string` | `undefined` |
15-
| `primary` | `primary` | | `string` | `undefined` |
16-
| `rel` | `rel` | | `string` | `undefined` |
17-
| `secondary` | `secondary` | | `string` | `undefined` |
18-
| `target` | `target` | | `string` | `undefined` |
19-
| `type` | `type` | | `"button" \| "checkbox" \| "link" \| "radio"` | `"button"` |
20-
| `value` | `value` | | `string` | `undefined` |
8+
| Property | Attribute | Description | Type | Default |
9+
| ----------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------- | ----------- |
10+
| `action` | `action` | The action to display on the right side of the item. For example, a chevron. This is purely visual and does not affect the behavior of the item in any way. Not visible when the type is "radio" or "checkbox". | `"chevron"` | `null` |
11+
| `checked` | `checked` | | `boolean` | `undefined` |
12+
| `disabled` | `disabled` | | `boolean` | `undefined` |
13+
| `href` | `href` | | `string` | `undefined` |
14+
| `icon` | `icon` | | `string` | `undefined` |
15+
| `name` | `name` | | `string` | `undefined` |
16+
| `primary` | `primary` | | `string` | `undefined` |
17+
| `rel` | `rel` | | `string` | `undefined` |
18+
| `secondary` | `secondary` | | `string` | `undefined` |
19+
| `target` | `target` | | `string` | `undefined` |
20+
| `type` | `type` | | `"button" \| "checkbox" \| "link" \| "radio"` | `"button"` |
21+
| `value` | `value` | | `string` | `undefined` |
2122

2223

2324
## Events

0 commit comments

Comments
 (0)