Skip to content

Commit

Permalink
fix(NcListItem): allow to pass custom NcActions component via scoped …
Browse files Browse the repository at this point in the history
…slot

Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
  • Loading branch information
Antreesy committed Jul 25, 2024
1 parent 277bcf1 commit 4300707
Showing 1 changed file with 64 additions and 5 deletions.
69 changes: 64 additions & 5 deletions src/components/NcListItem/NcListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,58 @@
</template>
</NcListItem>
```
### NcListItem with `custom-actions` slot

If there is a need to heavily customize the actions menu, the `custom-actions` slot can be used to pass the NcActions component.
Remember to pass `primary`, `aria-label` and `update-open` props from the scoped slot props to ensure full functionality.
```js static
<template #custom-actions="slotProps">
<NcActions :primary="slotProps.primary"
:aria-label="slotProps.ariaLabel"
@update:open="slotProps.updateOpen" />
</template>
```
```vue
<template>
<NcListItem
:name="'This is an active element with custom actions slot'"
:bold="true"
:active="true"
:force-display-actions="true"
counterType="highlighted">
<template #icon>
<NcAvatar disable-menu :size="44" user="janedoe" display-name="Jane Doe" />
</template>
<template #custom-actions="slotProps">
<NcActions :primary="slotProps.primary"
:aria-label="slotProps.ariaLabel"
@update:open="slotProps.updateOpen">
<template #icon>
<IconNoteText :size="20" />
</template>
<NcActionButton>
Button one
</NcActionButton>
<NcActionButton>
Button two
</NcActionButton>
<NcActionButton>
Button three
</NcActionButton>
</NcActions>
</template>
</NcListItem>
</template>
<script>
import IconNoteText from 'vue-material-design-icons/NoteText.vue'
export default {
components: {
IconNoteText,
},
}
</script>
```
### NcListItem compact mode
```vue
<template>
Expand Down Expand Up @@ -416,13 +468,20 @@
<div v-show="forceDisplayActions || displayActionsOnHoverFocus"
class="list-item-content__actions"
@focusout="handleBlur">
<NcActions ref="actions"
<!-- @slot Provide the whole NcActions for full customization -->
<slot name="custom-actions"
:primary="isActive || active"
:aria-label="computedActionsAriaLabel"
@update:open="handleActionsUpdateOpen">
<!-- @slot Provide the actions for the right side quick menu -->
<slot name="actions" />
</NcActions>
:update-open="handleActionsUpdateOpen">
<!-- Fallback content for the custom-actions slot -->
<NcActions ref="actions"
:primary="isActive || active"
:aria-label="computedActionsAriaLabel"
@update:open="handleActionsUpdateOpen">
<!-- @slot Provide the actions for the right side quick menu -->
<slot name="actions" />
</NcActions>
</slot>
</div>

<!-- @slot Extra elements below the item -->
Expand Down

0 comments on commit 4300707

Please sign in to comment.