Skip to content

Commit

Permalink
feat(NcListItem): provide additional slots for customization
Browse files Browse the repository at this point in the history
- extra-actions for inline component
- actions-icon for icon in NcActions component

Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
  • Loading branch information
Antreesy committed Aug 3, 2024
1 parent b22698b commit 4ea068a
Showing 1 changed file with 107 additions and 2 deletions.
109 changes: 107 additions & 2 deletions src/components/NcListItem/NcListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,94 @@
</template>
</NcListItem>
```
### NcListItem with extra actions slot and customized icon

The `extra-actions` slot can be used to add other interactive components.

The `actions-icon` slot can be used to pass icon to the inner NcActions component.

```vue
<template>
<div>
<NcListItem
name="This is an active element with extra actions slot"
:bold="true"
:active="true"
:force-display-actions="true">
<template #icon>
<NcAvatar disable-menu :size="44" user="janedoe" display-name="Jane Doe" />
</template>
<template #extra-actions>
<NcButton type="primary">
<template #icon>
<IconCog :size="20" />
</template>
</NcButton>
</template>
<template #actions-icon>
<IconNoteText :size="20" />
</template>
<template #actions>
<NcActionButton>
Button one
</NcActionButton>
<NcActionButton>
Button two
</NcActionButton>
<NcActionButton>
Button three
</NcActionButton>
</template>
</NcListItem>
<NcListItem
name="This is an element with extra actions slot"
:bold="true">
<template #icon>
<NcAvatar disable-menu :size="44" user="janedoe" display-name="Jane Doe" />
</template>
<template #extra-actions>
<NcButton type="tertiary">
<template #icon>
<IconPencil :size="20" />
</template>
</NcButton>
<NcButton type="tertiary">
<template #icon>
<IconCog :size="20" />
</template>
</NcButton>
</template>
<template #actions-icon>
<IconNoteText :size="20" />
</template>
<template #actions>
<NcActionButton>
Button one
</NcActionButton>
<NcActionButton>
Button two
</NcActionButton>
<NcActionButton>
Button three
</NcActionButton>
</template>
</NcListItem>
</div>
</template>
<script>
import IconCog from 'vue-material-design-icons/Cog.vue'
import IconNoteText from 'vue-material-design-icons/NoteText.vue'
import IconPencil from 'vue-material-design-icons/Pencil.vue'
export default {
components: {
IconCog,
IconNoteText,
IconPencil,
},
}
</script>
```
### NcListItem compact mode
```vue
<template>
Expand Down Expand Up @@ -413,6 +501,11 @@
</div>
</a>

<div v-if="$slots['extra-actions']" class="list-item-content__extra-actions">
<!-- @slot Extra elements next to the right side quick menu -->
<slot name="extra-actions" />
</div>

<!-- Actions -->
<div v-show="forceDisplayActions || displayActionsOnHoverFocus"
class="list-item-content__actions"
Expand All @@ -421,13 +514,17 @@
:primary="isActive || active"
:aria-label="computedActionsAriaLabel"
@update:open="handleActionsUpdateOpen">
<template #icon>
<!-- @slot Provide the custom icon for the right side quick menu -->
<slot name="actions-icon" />
</template>
<!-- @slot Provide the actions for the right side quick menu -->
<slot name="actions" />
</NcActions>
</div>

<!-- @slot Extra elements below the item -->
<div v-if="$slots.extra" class="list-item__extra">
<!-- @slot Extra elements below the item -->
<slot name="extra" />
</div>
</div>
Expand Down Expand Up @@ -898,12 +995,20 @@ export default {
align-items: end;
}
&__actions {
&__actions,
&__extra-actions {
flex: 0 0 auto;
align-self: center;
justify-content: center;
margin-left: 4px;
}
&__extra-actions {
display: flex;
align-self: center;
justify-content: center;
gap: 4px;
}
}
&-details {
Expand Down

0 comments on commit 4ea068a

Please sign in to comment.