Skip to content

Commit a70b05c

Browse files
committed
feat(picker): add support for displaying pictures in the picker list items
1 parent 12726f4 commit a70b05c

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import { LimelPickerCustomEvent, ListItem } from '@limetech/lime-elements';
2+
import { Component, h, State } from '@stencil/core';
3+
4+
/**
5+
* With pictures
6+
*/
7+
@Component({
8+
tag: 'limel-example-picker-pictures',
9+
shadow: true,
10+
})
11+
export class PickerPicturesExample {
12+
@State()
13+
private selectedItems: Array<ListItem<number>> = [];
14+
15+
private allItems: Array<ListItem<number>> = [
16+
{
17+
text: 'Lucy Chyzhova',
18+
secondaryText: 'UX Designer',
19+
value: 1,
20+
icon: {
21+
name: 'santas_hat',
22+
color: 'rgb(var(--color-coral-default))',
23+
},
24+
image: {
25+
src: 'https://lundalogik.github.io/lime-elements/780af2a6-d3d1-4593-8642-f03210d09271.png',
26+
alt: 'A picture of Lucy Chyzhova, UX designer at Lime Technologies',
27+
},
28+
},
29+
{
30+
text: 'Kiarokh Moattar',
31+
secondaryText: 'Product Designer',
32+
value: 2,
33+
icon: {
34+
name: 'party_hat',
35+
color: 'rgb(var(--color-pink-default))',
36+
},
37+
image: {
38+
src: 'https://lundalogik.github.io/lime-elements/2e86c284-d190-4c41-8da2-4de50103a0cd.png',
39+
alt: 'A picture of Kiarokh Moattar, Product Designer at Lime Technologies',
40+
},
41+
},
42+
{
43+
text: 'Adrian Schmidt',
44+
secondaryText: 'Engineer',
45+
value: 3,
46+
icon: 'viking_helmet',
47+
image: {
48+
src: 'https://lundalogik.github.io/lime-elements/0e6f74c0-11d9-465b-aac6-44f33da3cb7c.png',
49+
alt: 'A picture of Adrian Schmidt, Head of Smooth Operations at Lime Technologies',
50+
},
51+
},
52+
{
53+
text: 'Befkadu Degefa',
54+
secondaryText: 'Engineer',
55+
value: 4,
56+
icon: {
57+
name: 'bowler_hat',
58+
color: 'rgb(var(--color-sky-default))',
59+
},
60+
},
61+
];
62+
63+
public render() {
64+
return [
65+
<limel-picker
66+
label="Favorite awesomenaut"
67+
value={this.selectedItems}
68+
searchLabel={'Search your awesomenaut'}
69+
multiple={true}
70+
allItems={this.allItems}
71+
emptyResultMessage="No matching awesomenauts found"
72+
onChange={this.onChange}
73+
onInteract={this.onInteract}
74+
/>,
75+
<limel-example-value value={this.selectedItems} />,
76+
];
77+
}
78+
79+
private onChange = (
80+
event: LimelPickerCustomEvent<Array<ListItem<number>>>,
81+
) => {
82+
this.selectedItems = [...event.detail];
83+
};
84+
85+
private onInteract = (event: LimelPickerCustomEvent<ListItem<number>>) => {
86+
console.log('Value interacted with:', event.detail);
87+
};
88+
}

src/components/picker/picker.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const DEFAULT_SEARCHER_MAX_RESULTS = 20;
4343
* @exampleComponent limel-example-picker-basic
4444
* @exampleComponent limel-example-picker-multiple
4545
* @exampleComponent limel-example-picker-icons
46+
* @exampleComponent limel-example-picker-pictures
4647
* @exampleComponent limel-example-picker-value-as-object
4748
* @exampleComponent limel-example-picker-value-as-object-with-actions
4849
* @exampleComponent limel-example-picker-empty-suggestions
@@ -347,6 +348,7 @@ export class Picker {
347348
text: listItem.text,
348349
removable: true,
349350
icon: name ? { name: name, color: color } : undefined,
351+
image: listItem.image,
350352
value: listItem,
351353
menuItems: listItem.actions,
352354
};

0 commit comments

Comments
 (0)