Skip to content

Commit 72e0e67

Browse files
committed
docs(list): make it easier to test & showcase maxLinesSecondaryText
1 parent 49d0cbe commit 72e0e67

File tree

1 file changed

+38
-6
lines changed

1 file changed

+38
-6
lines changed

src/components/list/examples/list-badge-icons-with-multiple-lines.tsx

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import { Option } from '@limetech/lime-elements';
12
import { ListItem } from '@limetech/lime-elements';
2-
import { Component, h } from '@stencil/core';
3+
import { Component, h, Host, State } from '@stencil/core';
34

45
/**
56
* Multi-line versus single-line layout
@@ -23,6 +24,17 @@ import { Component, h } from '@stencil/core';
2324
shadow: true,
2425
})
2526
export class BadgeIconsListExample {
27+
@State()
28+
private maxLines: Option = { text: '2', value: '2' };
29+
30+
private options: Option[] = [
31+
{ text: '1', value: '1' },
32+
{ text: '2', value: '2' },
33+
{ text: '3', value: '3' },
34+
{ text: '4', value: '4' },
35+
{ text: '5', value: '5' },
36+
];
37+
2638
private items: Array<ListItem<number>> = [
2739
{
2840
text: 'This item only has one line of primary text, and no secondary text',
@@ -53,11 +65,31 @@ export class BadgeIconsListExample {
5365

5466
public render() {
5567
return (
56-
<limel-list
57-
items={this.items}
58-
badgeIcons={true}
59-
maxLinesSecondaryText={4}
60-
/>
68+
<Host>
69+
<limel-list
70+
items={this.items}
71+
badgeIcons={true}
72+
maxLinesSecondaryText={Number(this.maxLines?.value)}
73+
/>
74+
<limel-example-controls
75+
style={{
76+
'--example-controls-column-layout': 'auto-fit',
77+
}}
78+
>
79+
<limel-select
80+
label="maxLinesSecondaryText"
81+
options={this.options}
82+
value={this.maxLines}
83+
onChange={this.handleChange}
84+
/>
85+
</limel-example-controls>
86+
</Host>
6187
);
6288
}
89+
90+
private handleChange = (event) => {
91+
event.stopPropagation();
92+
const detail = event.detail;
93+
this.maxLines = Array.isArray(detail) ? detail[0] : detail;
94+
};
6395
}

0 commit comments

Comments
 (0)