Skip to content

Commit 4f7c587

Browse files
committed
feat(list): added few convenient props for passing them to list item
1 parent a30c4f1 commit 4f7c587

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

packages/anu-vue/src/components/list/AList.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ const handleListItemClick = (item: ListPropItems[number]) => {
5757
v-bind="typeof item === 'string' ? {} : item"
5858
:avatar-append="props.avatarAppend"
5959
:icon-append="props.iconAppend"
60+
:color="props.color"
61+
:variant="props.variant"
62+
:states="props.states"
6063
:is-active="options[index].isSelected as unknown as boolean"
6164
:value="props.modelValue !== undefined ? options[index] : undefined"
6265
v-on="{

packages/anu-vue/src/components/list/props.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import type { ExtractPropTypes, PropType } from 'vue'
22
import type { ListItemProps } from '@/components/list-item'
3-
import { spacing } from '@/composables/useProps'
3+
import { listItemProps } from '@/components/list-item'
44

55
export type ListPropItems = (ListItemProps | string | number)[]
66

7+
// List item props
8+
const { avatarAppend, iconAppend, color, variant, states } = listItemProps
9+
710
export const listProps = {
811
/**
912
* Items to render in list
@@ -23,21 +26,24 @@ export const listProps = {
2326
*/
2427
'modelValue': null,
2528

29+
// ℹ️ Workaround for checking if event is present on component instance: https://github.com/vuejs/core/issues/5220#issuecomment-1007488240
30+
'onClick:item': Function,
31+
32+
// ℹ️ Below is list item props that will be passed to each list item
33+
2634
/**
2735
* By default when icon props are used icon rendered at start. Use `iconAppend` to render icon at end.
2836
*/
29-
'iconAppend': Boolean,
37+
iconAppend,
3038

3139
/**
3240
* By default when avatar props are used avatar is added at start. Use `avatarAppend` to render avatar at end.
3341
*/
34-
'avatarAppend': Boolean,
35-
36-
// ℹ️ Workaround for checking if event is present on component instance: https://github.com/vuejs/core/issues/5220#issuecomment-1007488240
37-
38-
'onClick:item': Function,
42+
avatarAppend,
3943

40-
'spacing': spacing,
44+
color,
45+
variant,
46+
states,
4147
}
4248

4349
export type ListProps = ExtractPropTypes<typeof listProps>

0 commit comments

Comments
 (0)