Menu router demo updates

pull/4628/head
Tuğçe Küçükoğlu 2023-10-16 18:12:36 +03:00
parent 3418204383
commit dd62fbd753
5 changed files with 99 additions and 18 deletions

View File

@ -10,7 +10,7 @@
<ContextMenu ref="routemenu" :model="items">
<template #item="{ label, item, props }">
<router-link v-if="item.route" v-slot="routerProps" :to="item.route" custom>
<a :href="routerProps.href" v-bind="props.action">
<a :href="routerProps.href" v-bind="props.action" @click="routerProps.navigate">
<span v-bind="props.icon" />
<span v-bind="props.label">{{ label }}</span>
</a>
@ -42,13 +42,39 @@ export default {
code: {
basic: `
<img alt="Logo" src="/images/nature/nature3.jpg" class="w-full md:w-auto" @contextmenu="onImageRightClick" aria-haspopup="true" />
<ContextMenu ref="routemenu" :model="items" />
<ContextMenu ref="routemenu" :model="items">
<template #item="{ label, item, props }">
<router-link v-if="item.route" v-slot="routerProps" :to="item.route" custom>
<a :href="routerProps.href" v-bind="props.action" @click="routerProps.navigate">
<span v-bind="props.icon" />
<span v-bind="props.label">{{ label }}</span>
</a>
</router-link>
<a v-else :href="item.url" :target="item.target" v-bind="props.action">
<span v-bind="props.icon" />
<span v-bind="props.label">{{ label }}</span>
</a>
</template>
</ContextMenu>
`,
options: `
<template>
<div class="card flex md:justify-content-center">
<img alt="Logo" src="https://primefaces.org/cdn/primevue/images/nature/nature3.jpg" @contextmenu="onImageRightClick" class="w-full md:w-auto" aria-haspopup="true" />
<ContextMenu ref="routemenu" :model="items" />
<ContextMenu ref="routemenu" :model="items">
<template #item="{ label, item, props }">
<router-link v-if="item.route" v-slot="routerProps" :to="item.route" custom>
<a :href="routerProps.href" v-bind="props.action" @click="routerProps.navigate">
<span v-bind="props.icon" />
<span v-bind="props.label">{{ label }}</span>
</a>
</router-link>
<a v-else :href="item.url" :target="item.target" v-bind="props.action">
<span v-bind="props.icon" />
<span v-bind="props.label">{{ label }}</span>
</a>
</template>
</ContextMenu>
</div>
</template>
@ -79,7 +105,20 @@ export default {
<template>
<div class="card">
<img alt="Logo" src="https://primefaces.org/cdn/primevue/images/nature/nature3.jpg" @contextmenu="onImageRightClick" class="w-full md:w-auto" aria-haspopup="true" />
<ContextMenu ref="routemenu" :model="items" />
<ContextMenu ref="routemenu" :model="items">
<template #item="{ label, item, props }">
<router-link v-if="item.route" v-slot="routerProps" :to="item.route" custom>
<a :href="routerProps.href" v-bind="props.action" @click="routerProps.navigate">
<span v-bind="props.icon" />
<span v-bind="props.label">{{ label }}</span>
</a>
</router-link>
<a v-else :href="item.url" :target="item.target" v-bind="props.action">
<span v-bind="props.icon" />
<span v-bind="props.label">{{ label }}</span>
</a>
</template>
</ContextMenu>
</div>
</template>

View File

@ -9,7 +9,7 @@
<MegaMenu :model="items">
<template #item="{ label, item, props, hasSubmenu }">
<router-link v-if="item.route" v-slot="routerProps" :to="item.route" custom>
<a :href="routerProps.href" v-bind="props.action">
<a :href="routerProps.href" v-bind="props.action" @click="routerProps.navigate">
<span v-bind="props.icon" />
<span v-bind="props.label">{{ label }}</span>
</a>
@ -155,7 +155,7 @@ export default {
<MegaMenu :model="items">
<template #item="{ label, item, props, hasSubmenu }">
<router-link v-if="item.route" v-slot="routerProps" :to="item.route" custom>
<a :href="routerProps.href" v-bind="props.action">
<a :href="routerProps.href" v-bind="props.action" @click="routerProps.navigate">
<span v-bind="props.icon" />
<span v-bind="props.label">{{ label }}</span>
</a>
@ -174,7 +174,7 @@ export default {
<MegaMenu :model="items">
<template #item="{ label, item, props, hasSubmenu }">
<router-link v-if="item.route" v-slot="routerProps" :to="item.route" custom>
<a :href="routerProps.href" v-bind="props.action">
<a :href="routerProps.href" v-bind="props.action" @click="routerProps.navigate">
<span v-bind="props.icon" />
<span v-bind="props.label">{{ label }}</span>
</a>
@ -325,7 +325,7 @@ export default {
<MegaMenu :model="items">
<template #item="{ label, item, props, hasSubmenu }">
<router-link v-if="item.route" v-slot="routerProps" :to="item.route" custom>
<a :href="routerProps.href" v-bind="props.action">
<a :href="routerProps.href" v-bind="props.action" @click="routerProps.navigate">
<span v-bind="props.icon" />
<span v-bind="props.label">{{ label }}</span>
</a>

View File

@ -70,7 +70,7 @@ export default {
<Menu :model="items">
<template #item="{ label, item, props }">
<router-link v-if="item.route" v-slot="routerProps" :to="item.route" custom>
<a :href="routerProps.href" v-bind="props.action">
<a :href="routerProps.href" v-bind="props.action" @click="routerProps.navigate">
<span v-bind="props.icon" />
<span v-bind="props.label">{{ label }}</span>
</a>
@ -88,7 +88,7 @@ export default {
<Menu :model="items">
<template #item="{ label, item, props }">
<router-link v-if="item.route" v-slot="routerProps" :to="item.route" custom>
<a :href="routerProps.href" v-bind="props.action">
<a :href="routerProps.href" v-bind="props.action" @click="routerProps.navigate">
<span v-bind="props.icon" />
<span v-bind="props.label">{{ label }}</span>
</a>

View File

@ -9,7 +9,7 @@
<Menubar :model="items">
<template #item="{ label, item, props, root, hasSubmenu }">
<router-link v-if="item.route" v-slot="routerProps" :to="item.route" custom>
<a :href="routerProps.href" v-bind="props.action">
<a :href="routerProps.href" v-bind="props.action" @click="routerProps.navigate">
<span v-bind="props.icon" />
<span v-bind="props.label">{{ label }}</span>
</a>
@ -162,7 +162,7 @@ export default {
<Menubar :model="items">
<template #item="{ label, item, props, root, hasSubmenu }">
<router-link v-if="item.route" v-slot="routerProps" :to="item.route" custom>
<a :href="routerProps.href" v-bind="props.action">
<a :href="routerProps.href" v-bind="props.action" @click="routerProps.navigate">
<span v-bind="props.icon" />
<span v-bind="props.label">{{ label }}</span>
</a>
@ -181,7 +181,7 @@ export default {
<Menubar :model="items">
<template #item="{ label, item, props, root, hasSubmenu }">
<router-link v-if="item.route" v-slot="routerProps" :to="item.route" custom>
<a :href="routerProps.href" v-bind="props.action">
<a :href="routerProps.href" v-bind="props.action" @click="routerProps.navigate">
<span v-bind="props.icon" />
<span v-bind="props.label">{{ label }}</span>
</a>
@ -339,7 +339,7 @@ export default {
<Menubar :model="items">
<template #item="{ label, item, props, root, hasSubmenu }">
<router-link v-if="item.route" v-slot="routerProps" :to="item.route" custom>
<a :href="routerProps.href" v-bind="props.action">
<a :href="routerProps.href" v-bind="props.action" @click="routerProps.navigate">
<span v-bind="props.icon" />
<span v-bind="props.label">{{ label }}</span>
</a>

View File

@ -9,7 +9,7 @@
<TieredMenu :model="items">
<template #item="{ label, item, props, hasSubmenu }">
<router-link v-if="item.route" v-slot="routerProps" :to="item.route" custom>
<a :href="routerProps.href" v-bind="props.action">
<a :href="routerProps.href" v-bind="props.action" @click="($event) => routerProps.navigate($event)">
<span v-bind="props.icon" />
<span v-bind="props.label">{{ label }}</span>
</a>
@ -162,12 +162,40 @@ export default {
],
code: {
basic: `
<TieredMenu :model="items" />
<TieredMenu :model="items">
<template #item="{ label, item, props, hasSubmenu }">
<router-link v-if="item.route" v-slot="routerProps" :to="item.route" custom>
<a :href="routerProps.href" v-bind="props.action" @click="($event) => routerProps.navigate($event)">
<span v-bind="props.icon" />
<span v-bind="props.label">{{ label }}</span>
</a>
</router-link>
<a v-else :href="item.url" :target="item.target" v-bind="props.action">
<span v-bind="props.icon" />
<span v-bind="props.label">{{ label }}</span>
<span v-if="hasSubmenu" class="pi pi-fw pi-angle-right" v-bind="props.submenuicon" />
</a>
</template>
</TieredMenu>
`,
options: `
<template>
<div class="card flex justify-content-center">
<TieredMenu :model="items" />
<TieredMenu :model="items">
<template #item="{ label, item, props, hasSubmenu }">
<router-link v-if="item.route" v-slot="routerProps" :to="item.route" custom>
<a :href="routerProps.href" v-bind="props.action" @click="($event) => routerProps.navigate($event)">
<span v-bind="props.icon" />
<span v-bind="props.label">{{ label }}</span>
</a>
</router-link>
<a v-else :href="item.url" :target="item.target" v-bind="props.action">
<span v-bind="props.icon" />
<span v-bind="props.label">{{ label }}</span>
<span v-if="hasSubmenu" class="pi pi-fw pi-angle-right" v-bind="props.submenuicon" />
</a>
</template>
</TieredMenu>
</div>
</template>
@ -314,7 +342,21 @@ export default {
composition: `
<template>
<div class="card flex justify-content-center">
<TieredMenu :model="items" />
<TieredMenu :model="items">
<template #item="{ label, item, props, hasSubmenu }">
<router-link v-if="item.route" v-slot="routerProps" :to="item.route" custom>
<a :href="routerProps.href" v-bind="props.action" @click="($event) => routerProps.navigate($event)">
<span v-bind="props.icon" />
<span v-bind="props.label">{{ label }}</span>
</a>
</router-link>
<a v-else :href="item.url" :target="item.target" v-bind="props.action">
<span v-bind="props.icon" />
<span v-bind="props.label">{{ label }}</span>
<span v-if="hasSubmenu" class="pi pi-fw pi-angle-right" v-bind="props.submenuicon" />
</a>
</template>
</TieredMenu>
</div>
</template>