83 lines
2.4 KiB
JavaScript
83 lines
2.4 KiB
JavaScript
import BaseStyle from 'primevue/base/style';
|
|
|
|
const inlineStyles = {
|
|
submenu: ({ instance, processedItem }) => ({ display: instance.isItemActive(processedItem) ? 'block' : 'none' })
|
|
};
|
|
|
|
const classes = {
|
|
root: ({ instance }) => [
|
|
'p-megamenu p-component',
|
|
{
|
|
'p-megamenu-mobile': instance.queryMatches,
|
|
'p-megamenu-mobile-active': instance.mobileActive,
|
|
'p-megamenu-horizontal': instance.horizontal,
|
|
'p-megamenu-vertical': instance.vertical
|
|
}
|
|
],
|
|
start: 'p-megamenu-start',
|
|
menubutton: 'p-megamenu-button',
|
|
menu: 'p-megamenu-root-list',
|
|
submenuHeader: ({ instance, processedItem }) => [
|
|
'p-megamenu-submenu-header p-submenu-header',
|
|
{
|
|
'p-disabled': instance.isItemDisabled(processedItem)
|
|
}
|
|
],
|
|
menuitem: ({ instance, processedItem }) => [
|
|
'p-menuitem',
|
|
{
|
|
'p-menuitem-active p-highlight': instance.isItemActive(processedItem),
|
|
'p-focus': instance.isItemFocused(processedItem),
|
|
'p-disabled': instance.isItemDisabled(processedItem)
|
|
}
|
|
],
|
|
content: 'p-menuitem-content',
|
|
action: 'p-menuitem-link',
|
|
icon: 'p-menuitem-icon',
|
|
label: 'p-menuitem-text',
|
|
submenuIcon: 'p-submenu-icon',
|
|
panel: 'p-megamenu-panel',
|
|
grid: 'p-megamenu-grid',
|
|
column: ({ instance, processedItem }) => {
|
|
let length = instance.isItemGroup(processedItem) ? processedItem.items.length : 0;
|
|
let columnClass;
|
|
|
|
if (instance.$parentInstance.queryMatches) columnClass = 'p-megamenu-col-12';
|
|
else {
|
|
switch (length) {
|
|
case 2:
|
|
columnClass = 'p-megamenu-col-6';
|
|
break;
|
|
|
|
case 3:
|
|
columnClass = 'p-megamenu-col-4';
|
|
break;
|
|
|
|
case 4:
|
|
columnClass = 'p-megamenu-col-3';
|
|
break;
|
|
|
|
case 6:
|
|
columnClass = 'p-megamenu-col-2';
|
|
break;
|
|
|
|
default:
|
|
columnClass = 'p-megamenu-col-12';
|
|
break;
|
|
}
|
|
}
|
|
|
|
return columnClass;
|
|
},
|
|
submenu: 'p-submenu-list p-megamenu-submenu',
|
|
submenuLabel: 'p-menuitem-text',
|
|
separator: 'p-menuitem-separator',
|
|
end: 'p-megamenu-end'
|
|
};
|
|
|
|
export default BaseStyle.extend({
|
|
name: 'megamenu',
|
|
classes,
|
|
inlineStyles
|
|
});
|