Fixed #1482 - start and end slots for MegaMenu, remove default slot
parent
5b0532aeca
commit
3f5d6a2bf1
|
@ -20,6 +20,14 @@ const MegaMenuProps = [
|
||||||
];
|
];
|
||||||
|
|
||||||
const MegaMenuSlots = [
|
const MegaMenuSlots = [
|
||||||
|
{
|
||||||
|
name: "start",
|
||||||
|
description: "Custom content before the content"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "end",
|
||||||
|
description: "Custom content after the content"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "item",
|
name: "item",
|
||||||
description: "Template of a menuitem."
|
description: "Template of a menuitem."
|
||||||
|
|
|
@ -9,7 +9,8 @@ interface MegaMenuProps {
|
||||||
declare class MegaMenu {
|
declare class MegaMenu {
|
||||||
$props: MegaMenuProps;
|
$props: MegaMenuProps;
|
||||||
$slots: {
|
$slots: {
|
||||||
'': VNode[];
|
start: VNode[];
|
||||||
|
end: VNode[];
|
||||||
item: VNode[];
|
item: VNode[];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
<template>
|
<template>
|
||||||
<div :class="containerClass">
|
<div :class="containerClass">
|
||||||
|
<div class="p-megamenu-start" v-if="$slots.start">
|
||||||
|
<slot name="start"></slot>
|
||||||
|
</div>
|
||||||
<ul class="p-megamenu-root-list" role="menubar">
|
<ul class="p-megamenu-root-list" role="menubar">
|
||||||
<template v-for="(category,index) of model" :key="category.label + '_' + index">
|
<template v-for="(category,index) of model" :key="category.label + '_' + index">
|
||||||
<li v-if="visible(category)" :class="getCategoryClass(category)" :style="category.style"
|
<li v-if="visible(category)" :class="getCategoryClass(category)" :style="category.style"
|
||||||
|
@ -50,8 +53,8 @@
|
||||||
</li>
|
</li>
|
||||||
</template>
|
</template>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="p-megamenu-custom" v-if="$slots.default">
|
<div class="p-megamenu-end" v-if="$slots.end">
|
||||||
<slot></slot>
|
<slot name="end"></slot>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -142,17 +142,19 @@ export default {
|
||||||
|
|
||||||
</code></pre>
|
</code></pre>
|
||||||
|
|
||||||
<h5>Custom Content</h5>
|
<h5>Templating</h5>
|
||||||
<p>Any content inside the megamenu will be displayed on the right side by default. You may use ".p-megamenu-custom" style class to change the location of the content.
|
<p>Two slots named "start" and "end" are provided to embed content before or after the items. In additon MegaMenu, offers item customization with the <i>item</i> template that receives the menuitem instance from the model as a parameter.</p>
|
||||||
Additionally, MegaMenu offers content customization with the <i>item</i> template that receives the menuitem instance from the model as a parameter.
|
|
||||||
</p>
|
|
||||||
<pre v-code><code><template v-pre>
|
<pre v-code><code><template v-pre>
|
||||||
<MegaMenu :model="items">
|
<MegaMenu :model="items">
|
||||||
<InputText placeholder="Search" type="text" />
|
<template #start>
|
||||||
<Button label="Logout" icon="pi pi-power-off" />
|
Before
|
||||||
|
</template>
|
||||||
<template #item="{item}">
|
<template #item="{item}">
|
||||||
<a :href="item.url">{{item.label}}</a>
|
<a :href="item.url">{{item.label}}</a>
|
||||||
</template>
|
</template>
|
||||||
|
<template #end>
|
||||||
|
After
|
||||||
|
</template>
|
||||||
</MegaMenu>
|
</MegaMenu>
|
||||||
</template>
|
</template>
|
||||||
</code></pre>
|
</code></pre>
|
||||||
|
|
Loading…
Reference in New Issue