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

277 lines
9.0 KiB
Vue
Raw Normal View History

2023-11-08 08:33:18 +00:00
<template>
<DocSectionText v-bind="$attrs">
<p>PanelMenu offers item customization with the <i>item</i> template that receives the menuitem instance from the model as a parameter.</p>
</DocSectionText>
2024-05-20 12:14:38 +00:00
<div class="card flex justify-center">
<PanelMenu :model="items" class="w-full md:w-80">
2023-11-08 08:33:18 +00:00
<template #item="{ item }">
2024-05-30 08:57:44 +00:00
<a v-ripple class="flex items-center px-4 py-2 cursor-pointer group">
<span :class="[item.icon, 'text-primary group-hover:text-inherit']" />
2023-11-08 08:33:18 +00:00
<span :class="['ml-2', { 'font-semibold': item.items }]">{{ 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>
2023-11-08 08:33:18 +00:00
</a>
</template>
</PanelMenu>
</div>
<DocSectionCode :code="code" />
</template>
<script>
export default {
data() {
return {
items: [
{
label: 'Mail',
icon: 'pi pi-envelope',
badge: 5,
items: [
{
label: 'Compose',
icon: 'pi pi-file-edit',
shortcut: '⌘+N'
},
{
label: 'Inbox',
icon: 'pi pi-inbox',
badge: 5
},
{
label: 'Sent',
icon: 'pi pi-send',
shortcut: '⌘+S'
},
{
label: 'Trash',
icon: 'pi pi-trash',
shortcut: '⌘+T'
}
]
},
{
label: 'Reports',
icon: 'pi pi-chart-bar',
shortcut: '⌘+R',
items: [
{
label: 'Sales',
icon: 'pi pi-chart-line',
badge: 3
},
{
label: 'Products',
icon: 'pi pi-list',
badge: 6
}
]
},
{
label: 'Profile',
icon: 'pi pi-user',
shortcut: '⌘+W',
items: [
{
label: 'Settings',
icon: 'pi pi-cog',
shortcut: '⌘+O'
},
{
label: 'Privacy',
icon: 'pi pi-shield',
shortcut: '⌘+P'
}
]
}
],
code: {
basic: `
<PanelMenu :model="items">
<template #item="{ item }">
2024-05-30 08:57:44 +00:00
<a v-ripple class="flex items-center px-4 py-2 cursor-pointer group">
<span :class="[item.icon, 'text-primary group-hover:text-inherit']" />
2023-11-08 08:33:18 +00:00
<span :class="['ml-2', { 'font-semibold': item.items }]">{{ 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>
2023-11-08 08:33:18 +00:00
</a>
</template>
</PanelMenu>
`,
options: `
<template>
2024-05-20 12:14:38 +00:00
<div class="card flex justify-center">
<PanelMenu :model="items" class="w-full md:w-80">
2023-11-08 08:33:18 +00:00
<template #item="{ item }">
2024-05-30 08:57:44 +00:00
<a v-ripple class="flex items-center px-4 py-2 cursor-pointer group">
<span :class="[item.icon, 'text-primary group-hover:text-inherit']" />
2023-11-08 08:33:18 +00:00
<span :class="['ml-2', { 'font-semibold': item.items }]">{{ 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>
2023-11-08 08:33:18 +00:00
</a>
</template>
</PanelMenu>
</div>
</template>
<script>
export default {
data() {
return {
items: [
{
label: 'Mail',
icon: 'pi pi-envelope',
badge: 5,
items: [
{
label: 'Compose',
icon: 'pi pi-file-edit',
shortcut: '⌘+N'
},
{
label: 'Inbox',
icon: 'pi pi-inbox',
badge: 5
},
{
label: 'Sent',
icon: 'pi pi-send',
shortcut: '⌘+S'
},
{
label: 'Trash',
icon: 'pi pi-trash',
shortcut: '⌘+T'
}
]
},
{
label: 'Reports',
icon: 'pi pi-chart-bar',
shortcut: '⌘+R',
items: [
{
label: 'Sales',
icon: 'pi pi-chart-line',
badge: 3
},
{
label: 'Products',
icon: 'pi pi-list',
badge: 6
}
]
},
{
label: 'Profile',
icon: 'pi pi-user',
shortcut: '⌘+W',
items: [
{
label: 'Settings',
icon: 'pi pi-cog',
shortcut: '⌘+O'
},
{
label: 'Privacy',
icon: 'pi pi-shield',
shortcut: '⌘+P'
}
]
}
]
};
}
};
<\/script>
`,
composition: `
<template>
2024-05-20 12:14:38 +00:00
<div class="card flex justify-center">
<PanelMenu :model="items" class="w-full md:w-80">
2023-11-08 08:33:18 +00:00
<template #item="{ item }">
2024-05-30 08:57:44 +00:00
<a v-ripple class="flex items-center px-4 py-2 cursor-pointer group">
<span :class="[item.icon, 'text-primary group-hover:text-inherit']" />
2023-11-08 08:33:18 +00:00
<span :class="['ml-2', { 'font-semibold': item.items }]">{{ 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>
2023-11-08 08:33:18 +00:00
</a>
</template>
</PanelMenu>
</div>
</template>
<script setup>
import { ref } from "vue";
const items = ref([
{
label: 'Mail',
icon: 'pi pi-envelope',
badge: 5,
items: [
{
label: 'Compose',
icon: 'pi pi-file-edit',
shortcut: '⌘+N'
},
{
label: 'Inbox',
icon: 'pi pi-inbox',
badge: 5
},
{
label: 'Sent',
icon: 'pi pi-send',
shortcut: '⌘+S'
},
{
label: 'Trash',
icon: 'pi pi-trash',
shortcut: '⌘+T'
}
]
},
{
label: 'Reports',
icon: 'pi pi-chart-bar',
shortcut: '⌘+R',
items: [
{
label: 'Sales',
icon: 'pi pi-chart-line',
badge: 3
},
{
label: 'Products',
icon: 'pi pi-list',
badge: 6
}
]
},
{
label: 'Profile',
icon: 'pi pi-user',
shortcut: '⌘+W',
items: [
{
label: 'Settings',
icon: 'pi pi-cog',
shortcut: '⌘+O'
},
{
label: 'Privacy',
icon: 'pi pi-shield',
shortcut: '⌘+P'
}
]
}
]);
<\/script>
`
}
};
}
};
</script>