Tokens for MegaMenu

pull/5756/head
Cagatay Civici 2024-05-11 11:33:40 +03:00
parent fe7ec96f47
commit 6c0edbffb1
5 changed files with 222 additions and 100 deletions

View File

@ -87,9 +87,9 @@ export interface MegaMenuPassThroughOptions {
*/
submenuIcon?: MegaMenuPassThroughOptionType;
/**
* Used to pass attributes to the panel's DOM element.
* Used to pass attributes to the overlay DOM element.
*/
panel?: MegaMenuPassThroughOptionType;
overlay?: MegaMenuPassThroughOptionType;
/**
* Used to pass attributes to the grid's DOM element.
*/
@ -101,15 +101,11 @@ export interface MegaMenuPassThroughOptions {
/**
* Used to pass attributes to the submenu item's DOM element.
*/
submenuItem?: MegaMenuPassThroughOptionType;
submenuLabel?: MegaMenuPassThroughOptionType;
/**
* Used to pass attributes to the submenu's DOM element.
*/
submenu?: MegaMenuPassThroughOptionType;
/**
* Used to pass attributes to the submenu item label's DOM element.
*/
submenuItemLabel?: MegaMenuPassThroughOptionType;
/**
* Used to pass attributes to the separator's DOM element.
*/

View File

@ -1,6 +1,6 @@
<template>
<ul :class="level === 0 ? cx('rootList') : cx('submenu')" :tabindex="tabindex" v-bind="level === 0 ? ptm('rootList') : ptm('submenu')">
<li v-if="submenu" :class="[cx('submenuItem', { submenu }), getItemProp(submenu, 'class')]" :style="getItemProp(submenu, 'style')" role="presentation" v-bind="ptm('submenuItem')">{{ getItemLabel(submenu) }}</li>
<li v-if="submenu" :class="[cx('submenuLabel', { submenu }), getItemProp(submenu, 'class')]" :style="getItemProp(submenu, 'style')" role="presentation" v-bind="ptm('submenuLabel')">{{ getItemLabel(submenu) }}</li>
<template v-for="(processedItem, index) of items" :key="getItemKey(processedItem)">
<li
v-if="isItemVisible(processedItem) && !getItemProp(processedItem, 'separator')"
@ -25,7 +25,7 @@
<a v-ripple :href="getItemProp(processedItem, 'url')" :class="cx('itemLink')" :target="getItemProp(processedItem, 'target')" tabindex="-1" aria-hidden="true" v-bind="getPTOptions(processedItem, index, 'itemLink')">
<component v-if="templates.itemicon" :is="templates.itemicon" :item="processedItem.item" :class="cx('itemIcon')" />
<span v-else-if="getItemProp(processedItem, 'icon')" :class="[cx('itemIcon'), getItemProp(processedItem, 'icon')]" v-bind="getPTOptions(processedItem, index, 'itemIcon')" />
<span :class="level === 0 ? cx('itemLabel') : cx('submenuItemLabel')" v-bind="level === 0 ? getPTOptions(processedItem, index, 'itemLabel') : getPTOptions(processedItem, index, 'submenuItemLabel')">
<span :class="cx('itemLabel')" v-bind="getPTOptions(processedItem, index, 'itemLabel')">
{{ getItemLabel(processedItem) }}
</span>
<template v-if="isItemGroup(processedItem)">
@ -36,7 +36,7 @@
</template>
<component v-else :is="templates.item" :item="processedItem.item" :hasSubmenu="isItemGroup(processedItem)" :label="getItemLabel(processedItem)" :props="getMenuItemProps(processedItem, index)"></component>
</div>
<div v-if="isItemVisible(processedItem) && isItemGroup(processedItem)" :class="cx('panel')" v-bind="ptm('panel')">
<div v-if="isItemVisible(processedItem) && isItemGroup(processedItem)" :class="cx('overlay')" v-bind="ptm('overlay')">
<div :class="cx('grid')" v-bind="ptm('grid')">
<div v-for="col of processedItem.items" :key="getItemKey(col)" :class="cx('column', { processedItem })" v-bind="ptm('column')">
<MegaMenuSub

View File

@ -2,25 +2,36 @@ import BaseStyle from 'primevue/base/style';
const theme = ({ dt }) => `
.p-megamenu {
display: flex;
position: relative;
padding: 0.5rem 0.5rem;
display: flex;
align-items: center;
background: ${dt('megamenu.background')};
color: ${dt('megamenu.color')};
border: 1px solid ${dt('megamenu.border.color')};
border-radius: ${dt('border.radius.md')};
border-radius: ${dt('megamenu.border.radius')};
color: ${dt('megamenu.color')};
}
.p-megamenu-root-list {
margin: 0;
padding: 0;
outline: 0;
list-style: none;
outline: 0 none;
align-items: center;
display: flex;
flex-wrap: wrap;
}
.p-megamenu-root-list > .p-megamenu-item > .p-menumegamenubar-item-content {
border-radius: ${dt('megamenu.base.item.border.radius')};
}
.p-megamenu-root-list > .p-megamenu-item > .p-megamenu-item-content > .p-megamenu-item-link {
padding: ${dt('megamenu.base.item.padding')};
}
.p-megamenu-item-content {
transition: background-color ${dt('transition.duration')}, color ${dt('transition.duration')};
border-radius: ${dt('border.radius.sm')};
transition: background ${dt('transition.duration')}, color ${dt('transition.duration')};
border-radius: ${dt('megamenu.item.border.radius')};
color: ${dt('megamenu.item.color')};
}
@ -32,8 +43,10 @@ const theme = ({ dt }) => `
overflow: hidden;
position: relative;
color: inherit;
padding: 0.5rem 0.75rem;
padding: ${dt('megamenu.item.padding')};
gap: ${dt('megamenu.item.gap')};
user-select: none;
outline: 0 none;
}
.p-megamenu-item-label {
@ -42,7 +55,13 @@ const theme = ({ dt }) => `
.p-megamenu-item-icon {
color: ${dt('megamenu.item.icon.color')};
margin-right: 0.5rem;
}
.p-megamenu-submenu-icon {
color: ${dt('megamenu.submenu.icon.color')};
font-size: ${dt('megamenu.submenu.icon.size')};
width: ${dt('megamenu.submenu.icon.size')};
height: ${dt('megamenu.submenu.icon.size')};
}
.p-megamenu-item.p-focus > .p-megamenu-item-content {
@ -50,9 +69,12 @@ const theme = ({ dt }) => `
background: ${dt('megamenu.item.focus.background')};
}
.p-megamenu-item.p-focus > .p-megamenu-item-content .p-megamenu-item-icon,
.p-megamenu-item.p-focus > .p-megamenu-item-content .p-megamenu-item-icon {
color: ${dt('megamenu.item.icon.focus.color')};
}
.p-megamenu-item.p-focus > .p-megamenu-item-content .p-megamenu-submenu-icon {
color: ${dt('megamenu.item.icon.hover.color')};
color: ${dt('megamenu.submenu.icon.focus.color')};
}
.p-megamenu-item:not(.p-disabled) > .p-megamenu-item-content:hover {
@ -60,87 +82,77 @@ const theme = ({ dt }) => `
background: ${dt('megamenu.item.focus.background')};
}
.p-megamenu-item:not(.p-disabled) > .p-megamenu-item-content:hover .p-megamenu-item-icon,
.p-megamenu-item:not(.p-disabled) > .p-megamenu-item-content:hover .p-megamenu-item-icon {
color: ${dt('megamenu.item.icon.focus.color')};
}
.p-megamenu-item:not(.p-disabled) > .p-megamenu-item-content:hover .p-megamenu-submenu-icon {
color: ${dt('megamenu.item.icon.hover.color')};
color: ${dt('megamenu.submenu.icon.focus.color')};
}
.p-megamenu-item-active > .p-megamenu-item-content {
color: ${dt('megamenu.item.focus.color')};
background: ${dt('megamenu.item.focus.background')};
color: ${dt('megamenu.item.active.color')};
background: ${dt('megamenu.item.active.background')};
}
.p-megamenu-item-active > .p-megamenu-item-content .p-megamenu-item-icon {
color: ${dt('megamenu.item.icon.active.color')};
}
.p-megamenu-item-active > .p-megamenu-item-content .p-megamenu-item-icon,
.p-megamenu-item-active > .p-megamenu-item-content .p-megamenu-submenu-icon {
color: ${dt('megamenu.item.icon.hover.color')};
color: ${dt('megamenu.submenu.icon.active.color')};
}
.p-megamenu-submenu-icon {
color: ${dt('megamenu.item.icon.color')};
margin-left: 0.5rem;
font-size: 0.875rem;
width: 0.875rem;
height: 0.875rem;
}
.p-megamenu-panel {
.p-megamenu-overlay {
display: none;
position: absolute;
width: auto;
z-index: 1;
left: 0;
min-width: 100%;
background: ${dt('megamenu.background')};
color: ${dt('megamenu.color')};
border: 1px solid ${dt('megamenu.border.color')};
border-radius: ${dt('border.radius.md')};
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)
padding: ${dt('megamenu.overlay.padding')};
background: ${dt('megamenu.overlay.background')};
color: ${dt('megamenu.overlay.color')};
border: 1px solid ${dt('megamenu.overlay.border.color')};
border-radius: ${dt('megamenu.overlay.border.radius')};
box-shadow: ${dt('megamenu.overlay.shadow')};
}
.p-megamenu-root-list > .p-megamenu-item-active > .p-megamenu-panel {
.p-megamenu-root-list > .p-megamenu-item-active > .p-megamenu-overlay {
display: block;
}
.p-megamenu-submenu {
margin: 0;
list-style: none;
padding: 0.25rem 0.25rem;
padding: ${dt('megamenu.submenu.padding')};
min-width: 12.5rem;
display: flex;
flex-direction: column;
gap: ${dt('megamenu.submenu.gap')}
}
.p-megamenu-submenu .p-megamenu-item {
margin: 2px 0;
.p-megamenu-submenu-label {
padding: ${dt('megamenu.submenu.label.padding')};
color: ${dt('megamenu.submenu.label.color')};
font-weight: ${dt('megamenu.submenu.label.font.weight')};
background: ${dt('megamenu.submenu.label.background')};
}
.p-megamenu-submenu .p-megamenu-item:first-child {
margin-top: 0;
}
.p-megamenu-submenu .p-megamenu-item:last-child {
margin-bottom: 0;
}
.p-megamenu-submenu .p-megamenu-submenu-item {
margin: 0;
padding: 0.5rem 0.75rem;
color: ${dt('megamenu.submenu.item.color')};
font-weight: 600;
margin-bottom: 2px;
}
.p-megamenu-submenu .p-menuitem-separator {
.p-megamenu-separator {
border-top: 1px solid ${dt('megamenu.separator.border.color')};
margin: 2px 0;
}
.p-megamenu-horizontal {
align-items: center;
padding: ${dt('megamenu.horizontal.orientation.padding')};
}
.p-megamenu-horizontal .p-megamenu-root-list {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: ${dt('megamenu.horizontal.orientation.gap')};
}
.p-megamenu-horizontal .p-megamenu-end {
@ -150,16 +162,19 @@ const theme = ({ dt }) => `
.p-megamenu-vertical {
display: inline-flex;
flex-direction: column;
min-width: 12.5rem;
padding: 0.25rem 0.25rem;
flex-direction: column;
align-items: stretch;
padding: ${dt('megamenu.vertical.orientation.padding')};
}
.p-megamenu-vertical .p-megamenu-root-list {
align-items: stretch;
flex-direction: column;
gap: ${dt('megamenu.vertical.orientation.gap')};
}
.p-megamenu-vertical .p-megamenu-root-list > .p-megamenu-item-active > .p-megamenu-panel {
.p-megamenu-vertical .p-megamenu-root-list > .p-megamenu-item-active > .p-megamenu-overlay {
left: 100%;
top: 0;
}
@ -178,7 +193,7 @@ const theme = ({ dt }) => `
.p-megamenu-col-6,
.p-megamenu-col-12 {
flex: 0 0 auto;
padding: 0.5rem;
padding: ${dt('megamenu.overlay.gap')};
}
.p-megamenu-col-2 {
@ -206,25 +221,26 @@ const theme = ({ dt }) => `
justify-content: center;
align-items: center;
cursor: pointer;
width: 1.75rem;
height: 1.75rem;
width: ${dt('megamenu.mobile.button.size')};
height: ${dt('megamenu.mobile.button.size')};
position: relative;
color: ${dt('megamenu.mobile.toggle.color')};
color: ${dt('megamenu.mobile.button.color')};
border: 0 none;
background: transparent;
border-radius: 50%;
transition: background-color ${dt('transition.duration')}, color ${dt('transition.duration')}, outline-color ${dt('transition.duration')};
border-radius: ${dt('megamenu.mobile.button.border.radius')};
transition: background ${dt('transition.duration')}, color ${dt('transition.duration')}, outline-color ${dt('transition.duration')}, ox-shadow ${dt('transition.duration')};
outline-color: transparent;
}
.p-megamenu-button:hover {
color: ${dt('megamenu.mobile.toggle.hover.color')};
background: ${dt('megamenu.mobile.toggle.hover.background')};
color: ${dt('megamenu.mobile.button.hover.color')};
background: ${dt('megamenu.mobile.button.hover.background')};
}
.p-megamenu-button:focus-visible {
outline: ${dt('focus.ring.width')} ${dt('focus.ring.style')} ${dt('focus.ring.color')};
outline-offset: ${dt('focus.ring.offset')};
box-shadow: ${dt('megamenu.mobile.button.focus.ring.shadow')};
outline: ${dt('megamenu.mobile.button.focus.ring.width')} ${dt('megamenu.mobile.button.focus.ring.style')} ${dt('megamenu.mobile.button.focus.ring.color')};
outline-offset: ${dt('megamenu.mobile.button.focus.ring.offset')};
}
.p-megamenu-mobile {
@ -243,11 +259,11 @@ const theme = ({ dt }) => `
left: 0;
z-index: 1;
width: 100%;
padding: 0.25rem 0.25rem;
background: ${dt('megamenu.background')};
border: 1px solid ${dt('megamenu.border.color')};
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
gap: 2px;
padding: ${dt('megamenu.submenu.padding')};
gap: ${dt('megamenu.submenu.gap')};
background: ${dt('megamenu.overlay.background')};
border: 1px solid ${dt('megamenu.overlay.border.color')};
box-shadow: ${dt('menubar.overlay.shadow')};
}
.p-megamenu-mobile-active .p-megamenu-root-list {
@ -259,7 +275,7 @@ const theme = ({ dt }) => `
position: static;
}
.p-megamenu-mobile .p-megamenu-panel {
.p-megamenu-mobile .p-megamenu-overlay {
position: static;
border: 0 none;
border-radius: 0;
@ -299,8 +315,8 @@ const classes = {
start: 'p-megamenu-start',
button: 'p-megamenu-button',
rootList: 'p-megamenu-root-list',
submenuItem: ({ instance, processedItem }) => [
'p-megamenu-submenu-item',
submenuLabel: ({ instance, processedItem }) => [
'p-megamenu-submenu-label',
{
'p-disabled': instance.isItemDisabled(processedItem)
}
@ -318,7 +334,7 @@ const classes = {
itemIcon: 'p-megamenu-item-icon',
itemLabel: 'p-megamenu-item-label',
submenuIcon: 'p-megamenu-submenu-icon',
panel: 'p-megamenu-panel',
overlay: 'p-megamenu-overlay',
grid: 'p-megamenu-grid',
column: ({ instance, processedItem }) => {
let length = instance.isItemGroup(processedItem) ? processedItem.items.length : 0;
@ -352,7 +368,6 @@ const classes = {
return columnClass;
},
submenu: 'p-megamenu-submenu',
submenuItemLabel: 'p-megamenu-submenu-item-label',
separator: 'p-megamenu-separator',
end: 'p-megamenu-end'
};

View File

@ -2,26 +2,76 @@ export default {
root: {
background: '{content.background}',
borderColor: '{content.border.color}',
color: '{content.color}'
borderRadius: '{content.border.radius}',
color: '{content.color}',
gap: '0.5rem',
verticalOrientation: {
padding: '{navigation.list.padding}',
gap: '0'
},
horizontalOrientation: {
padding: '0.5rem 0.75rem'
}
},
baseItem: {
borderRadius: '{content.border.radius}',
padding: '{navigation.item.padding}'
},
item: {
focusBackground: '{navigation.item.focus.background}',
activeBackground: '{navigation.item.active.background}',
color: '{navigation.item.color}',
focusColor: '{navigation.item.focus.color}',
activeColor: '{navigation.item.active.color}',
padding: '{navigation.item.padding}',
borderRadius: '{navigation.item.border.radius}',
gap: '{navigation.item.gap}',
icon: {
color: '{navigation.item.icon.color}',
hoverColor: '{navigation.item.icon.hover.color}'
focusColor: '{navigation.item.icon.focus.color}',
activeColor: '{navigation.item.icon.active.color}'
}
},
submenuItem: {
color: '{navigation.submenu.color}'
overlay: {
padding: '0',
background: '{content.background}',
borderColor: '{content.border.color}',
borderRadius: '{content.border.radius}',
color: '{content.color}',
shadow: '{overlay.navigation.shadow}',
gap: '0.5rem'
},
submenu: {
padding: '{navigation.list.padding}',
gap: '{navigation.list.gap}'
},
submenuLabel: {
padding: '{navigation.submenu.label.padding}',
fontWeight: '{navigation.submenu.label.font.weight}',
background: '{navigation.submenu.label.background.}',
color: '{navigation.submenu.label.color}'
},
submenuIcon: {
size: '{navigation.submenu.icon.size}',
color: '{navigation.submenu.icon.color}',
focusColor: '{navigation.submenu.icon.focus.color}',
activeColor: '{navigation.submenu.icon.active.color}'
},
separator: {
borderColor: '{content.border.color}'
},
mobileToggle: {
mobileButton: {
borderRadius: '50%',
size: '1.75rem',
color: '{text.muted.color}',
hoverColor: '{text.muted.hover.color}',
hoverBackground: '{content.hover.background}'
hoverBackground: '{content.hover.background}',
focusRing: {
width: '{focus.ring.width}',
style: '{focus.ring.style}',
color: '{focus.ring.color}',
offset: '{focus.ring.offset}',
shadow: '{focus.ring.shadow}'
}
}
};

View File

@ -1,27 +1,88 @@
export default {
root: {
background: '{content.background}',
borderColor: '{content.border.color}',
color: '{content.color}'
borderColor: 'transparent',
borderRadius: '{content.border.radius}',
color: '{content.color}',
gap: '0.5rem',
verticalOrientation: {
padding: '{navigation.list.padding}',
gap: '0'
},
horizontalOrientation: {
padding: '0.75rem 1rem'
}
},
baseItem: {
borderRadius: '{content.border.radius}',
padding: '0.75rem 1rem'
},
item: {
focusBackground: '{navigation.item.focus.background}',
activeBackground: '{navigation.item.active.background}',
color: '{navigation.item.color}',
focusColor: '{navigation.item.focus.color}',
activeColor: '{navigation.item.active.color}',
padding: '{navigation.item.padding}',
borderRadius: '{navigation.item.border.radius}',
gap: '{navigation.item.gap}',
icon: {
color: '{navigation.item.icon.color}',
hoverColor: '{navigation.item.icon.hover.color}'
focusColor: '{navigation.item.icon.focus.color}',
activeColor: '{navigation.item.icon.active.color}'
}
},
submenuItem: {
color: '{navigation.submenu.color}'
overlay: {
padding: '0',
background: '{content.background}',
borderColor: '{content.border.color}',
borderRadius: '{content.border.radius}',
color: '{content.color}',
shadow: '{overlay.navigation.shadow}',
gap: '0.5rem'
},
submenu: {
padding: '{navigation.list.padding}',
gap: '{navigation.list.gap}'
},
submenuLabel: {
padding: '{navigation.submenu.label.padding}',
fontWeight: '{navigation.submenu.label.font.weight}',
background: '{navigation.submenu.label.background.}',
color: '{navigation.submenu.label.color}'
},
submenuIcon: {
size: '{navigation.submenu.icon.size}',
color: '{navigation.submenu.icon.color}',
focusColor: '{navigation.submenu.icon.focus.color}',
activeColor: '{navigation.submenu.icon.active.color}'
},
separator: {
borderColor: '{content.border.color}'
},
mobileToggle: {
mobileButton: {
borderRadius: '50%',
size: '2rem',
color: '{text.muted.color}',
hoverColor: '{text.muted.hover.color}',
hoverBackground: '{content.hover.background}'
hoverBackground: '{content.hover.background}',
focusRing: {
width: '{focus.ring.width}',
style: '{focus.ring.style}',
color: '{focus.ring.color}',
offset: '{focus.ring.offset}',
shadow: '{focus.ring.shadow}'
}
},
colorScheme: {
light: {
root: {
background: '{surface.100}'
}
},
dark: {
root: {
background: '{surface.800}'
}
}
}
};