primevue-mirror/apps/showcase/doc/tieredmenu/TemplateDoc.vue

329 lines
11 KiB
Vue
Raw Normal View History

2023-11-06 15:14:05 +00:00
<template>
<DocSectionText v-bind="$attrs">
2023-11-09 07:29:50 +00:00
<p>TieredMenu offers item customization with the <i>item</i> template that receives the menuitem instance from the model as a parameter.</p>
2023-11-06 15:14:05 +00:00
</DocSectionText>
2024-05-20 12:14:38 +00:00
<div class="card flex justify-center">
2023-11-06 15:14:05 +00:00
<TieredMenu :model="items">
<template #item="{ item, props, hasSubmenu }">
2024-05-20 12:14:38 +00:00
<a v-ripple class="flex items-center" v-bind="props.action">
2023-11-06 15:14:05 +00:00
<span :class="item.icon" />
<span class="ml-2">{{ item.label }}</span>
<Badge v-if="item.badge" class="ml-auto" :value="item.badge" />
<span v-if="item.shortcut" class="ml-auto border border-surface rounded bg-emphasis text-muted-color text-xs p-1">{{ item.shortcut }}</span>
2024-01-24 11:05:15 +00:00
<i v-if="hasSubmenu" class="pi pi-angle-right ml-auto"></i>
2023-11-06 15:14:05 +00:00
</a>
</template>
</TieredMenu>
</div>
<DocSectionCode :code="code" />
</template>
<script>
export default {
data() {
return {
items: [
{
label: 'File',
icon: 'pi pi-file',
items: [
{
label: 'New',
icon: 'pi pi-plus',
items: [
{
label: 'Document',
icon: 'pi pi-file',
shortcut: '⌘+N'
},
{
label: 'Image',
icon: 'pi pi-image',
shortcut: '⌘+I'
},
{
label: 'Video',
icon: 'pi pi-video',
shortcut: '⌘+L'
}
]
},
{
label: 'Open',
icon: 'pi pi-folder-open',
shortcut: '⌘+O'
},
{
label: 'Print',
icon: 'pi pi-print',
shortcut: '⌘+P'
}
]
},
{
label: 'Edit',
icon: 'pi pi-file-edit',
items: [
{
label: 'Copy',
icon: 'pi pi-copy',
shortcut: '⌘+C'
},
{
label: 'Delete',
icon: 'pi pi-times',
shortcut: '⌘+D'
}
]
},
{
label: 'Search',
icon: 'pi pi-search',
shortcut: '⌘+S'
},
{
separator: true
},
{
label: 'Share',
icon: 'pi pi-share-alt',
items: [
{
label: 'Slack',
icon: 'pi pi-slack',
badge: 2
},
{
label: 'Whatsapp',
icon: 'pi pi-whatsapp',
badge: 3
}
]
}
],
code: {
basic: `
<TieredMenu :model="items">
<template #item="{ item, props, hasSubmenu }">
2024-05-20 12:14:38 +00:00
<a v-ripple class="flex items-center" v-bind="props.action">
2023-11-06 15:14:05 +00:00
<span :class="item.icon" />
<span class="ml-2">{{ item.label }}</span>
<Badge v-if="item.badge" class="ml-auto" :value="item.badge" />
<span v-if="item.shortcut" class="ml-auto border border-surface rounded bg-emphasis text-muted-color text-xs p-1">{{ item.shortcut }}</span>
2024-01-24 11:05:15 +00:00
<i v-if="hasSubmenu" class="pi pi-angle-right ml-auto"></i>
2023-11-06 15:14:05 +00:00
</a>
</template>
</TieredMenu>
`,
options: `
<template>
2024-05-20 12:14:38 +00:00
<div class="card flex justify-center">
2023-11-06 15:14:05 +00:00
<TieredMenu :model="items">
<template #item="{ item, props, hasSubmenu }">
2024-05-20 12:14:38 +00:00
<a v-ripple class="flex items-center" v-bind="props.action">
2023-11-06 15:14:05 +00:00
<span :class="item.icon" />
<span class="ml-2">{{ item.label }}</span>
<Badge v-if="item.badge" class="ml-auto" :value="item.badge" />
<span v-if="item.shortcut" class="ml-auto border border-surface rounded bg-emphasis text-muted-color text-xs p-1">{{ item.shortcut }}</span>
2024-01-24 11:05:15 +00:00
<i v-if="hasSubmenu" class="pi pi-angle-right ml-auto"></i>
2023-11-06 15:14:05 +00:00
</a>
</template>
</TieredMenu>
</div>
</template>
<script>
export default {
data() {
return {
items: [
{
label: 'File',
icon: 'pi pi-file',
items: [
{
label: 'New',
icon: 'pi pi-plus',
items: [
{
label: 'Document',
icon: 'pi pi-file',
shortcut: '⌘+N'
},
{
label: 'Image',
icon: 'pi pi-image',
shortcut: '⌘+I'
},
{
label: 'Video',
icon: 'pi pi-video',
shortcut: '⌘+L'
}
]
},
{
label: 'Open',
icon: 'pi pi-folder-open',
shortcut: '⌘+O'
},
{
label: 'Print',
icon: 'pi pi-print',
shortcut: '⌘+P'
}
]
},
{
label: 'Edit',
icon: 'pi pi-file-edit',
items: [
{
label: 'Copy',
icon: 'pi pi-copy',
shortcut: '⌘+C'
},
{
label: 'Delete',
icon: 'pi pi-times',
shortcut: '⌘+D'
}
]
},
{
label: 'Search',
icon: 'pi pi-search',
shortcut: '⌘+S'
},
{
separator: true
},
{
label: 'Share',
icon: 'pi pi-share-alt',
items: [
{
label: 'Slack',
icon: 'pi pi-slack',
badge: 2
},
{
label: 'Whatsapp',
icon: 'pi pi-whatsapp',
badge: 3
}
]
}
]
};
}
};
<\/script>
`,
composition: `
<template>
2024-05-20 12:14:38 +00:00
<div class="card flex justify-center">
2023-11-06 15:14:05 +00:00
<TieredMenu :model="items">
<template #item="{ item, props, hasSubmenu }">
2024-05-20 12:14:38 +00:00
<a v-ripple class="flex items-center" v-bind="props.action">
2023-11-06 15:14:05 +00:00
<span :class="item.icon" />
<span class="ml-2">{{ item.label }}</span>
<Badge v-if="item.badge" class="ml-auto" :value="item.badge" />
<span v-if="item.shortcut" class="ml-auto border border-surface rounded bg-emphasis text-muted-color text-xs p-1">{{ item.shortcut }}</span>
2024-01-24 11:05:15 +00:00
<i v-if="hasSubmenu" class="pi pi-angle-right ml-auto"></i>
2023-11-06 15:14:05 +00:00
</a>
</template>
</TieredMenu>
</div>
</template>
<script setup>
import { ref } from "vue";
const items = ref([
{
label: 'File',
icon: 'pi pi-file',
items: [
{
label: 'New',
icon: 'pi pi-plus',
items: [
{
label: 'Document',
icon: 'pi pi-file',
shortcut: '⌘+N'
},
{
label: 'Image',
icon: 'pi pi-image',
shortcut: '⌘+I'
},
{
label: 'Video',
icon: 'pi pi-video',
shortcut: '⌘+L'
}
]
},
{
label: 'Open',
icon: 'pi pi-folder-open',
shortcut: '⌘+O'
},
{
label: 'Print',
icon: 'pi pi-print',
shortcut: '⌘+P'
}
]
},
{
label: 'Edit',
icon: 'pi pi-file-edit',
items: [
{
label: 'Copy',
icon: 'pi pi-copy',
shortcut: '⌘+C'
},
{
label: 'Delete',
icon: 'pi pi-times',
shortcut: '⌘+D'
}
]
},
{
label: 'Search',
icon: 'pi pi-search',
shortcut: '⌘+S'
},
{
separator: true
},
{
label: 'Share',
icon: 'pi pi-share-alt',
items: [
{
label: 'Slack',
icon: 'pi pi-slack',
badge: 2
},
{
label: 'Whatsapp',
icon: 'pi pi-whatsapp',
badge: 3
}
]
}
]);
<\/script>
`
}
};
}
};
</script>