primevue-mirror/doc/menu/pt/PTDoc.vue

188 lines
5.5 KiB
Vue
Raw Normal View History

2023-04-27 14:52:22 +00:00
<template>
<DocSectionText v-bind="$attrs"> </DocSectionText>
<div class="card flex justify-content-center">
<Menu
:model="items"
:pt="{
submenuHeader: { class: 'text-surface-900' },
2023-05-02 11:27:56 +00:00
action: ({ props, state, context }) => ({
class: context.focused ? 'bg-primary-400' : undefined
2023-04-27 14:52:22 +00:00
})
}"
/>
</div>
<DocSectionCode :code="code" />
</template>
<script>
export default {
data() {
return {
items: [
{
label: 'Options',
items: [
{
label: 'Update',
icon: 'pi pi-refresh',
command: () => {
this.$toast.add({ severity: 'success', summary: 'Updated', detail: 'Data Updated', life: 3000 });
}
},
{
label: 'Delete',
icon: 'pi pi-times',
command: () => {
this.$toast.add({ severity: 'warn', summary: 'Delete', detail: 'Data Deleted', life: 3000 });
}
}
]
},
{
label: 'Navigate',
items: [
{
label: 'Vue Website',
icon: 'pi pi-external-link',
url: 'https://vuejs.org/'
},
{
label: 'Router',
icon: 'pi pi-upload',
to: '/fileupload'
}
]
}
],
code: {
2023-08-16 13:58:31 +00:00
basic: `<Menu
2023-04-27 14:52:22 +00:00
:model="items"
:pt="{
submenuHeader: { class: 'text-surface-900' },
2023-05-02 11:27:56 +00:00
action: ({ props, state, context }) => ({
class: context.focused ? 'bg-primary-400' : undefined
2023-04-27 14:52:22 +00:00
})
}"
/>`,
2023-08-16 13:58:31 +00:00
options: `<template>
2023-04-27 14:52:22 +00:00
<div class="card flex justify-content-center">
<Menu
:model="items"
:pt="{
submenuHeader: { class: 'text-surface-900' },
2023-05-02 11:27:56 +00:00
action: ({ props, state, context }) => ({
class: context.focused ? 'bg-primary-400' : undefined
2023-04-27 14:52:22 +00:00
})
}"
/>
<Toast />
</div>
</template>
<script>
export default {
data() {
return {
items: [
{
label: 'Options',
items: [
{
label: 'Update',
icon: 'pi pi-refresh',
command: () => {
this.$toast.add({ severity: 'success', summary: 'Updated', detail: 'Data Updated', life: 3000 });
}
},
{
label: 'Delete',
icon: 'pi pi-times',
command: () => {
this.$toast.add({ severity: 'warn', summary: 'Delete', detail: 'Data Deleted', life: 3000 });
}
}
]
},
{
label: 'Navigate',
items: [
{
label: 'Vue Website',
icon: 'pi pi-external-link',
url: 'https://vuejs.org/'
},
{
label: 'Router',
icon: 'pi pi-upload',
to: '/fileupload'
}
]
}
]
};
}
};
<\/script>`,
2023-08-16 13:58:31 +00:00
composition: `<template>
2023-04-27 14:52:22 +00:00
<div class="card flex justify-content-center">
<Menu
:model="items"
:pt="{
submenuHeader: { class: 'text-surface-900' },
2023-05-02 11:27:56 +00:00
action: ({ props, state, context }) => ({
class: context.focused ? 'bg-primary-400' : undefined
2023-04-27 14:52:22 +00:00
})
}"
/>
<Toast />
</div>
</template>
<script setup>
import { ref } from "vue";
import { useToast } from "primevue/usetoast";
const toast = useToast();
const items = ref([
{
label: 'Options',
items: [
{
label: 'Update',
icon: 'pi pi-refresh',
command: () => {
toast.add({ severity: 'success', summary: 'Updated', detail: 'Data Updated', life: 3000 });
}
},
{
label: 'Delete',
icon: 'pi pi-times',
command: () => {
toast.add({ severity: 'warn', summary: 'Delete', detail: 'Data Deleted', life: 3000 });
}
}
]
},
{
label: 'Navigate',
items: [
{
label: 'Vue Website',
icon: 'pi pi-external-link',
url: 'https://vuejs.org/'
},
{
label: 'Router',
icon: 'pi pi-upload',
to: '/fileupload'
}
]
}
]);
<\/script>`
}
};
}
};
</script>