2023-10-02 10:46:09 +00:00
|
|
|
import BaseStyle from 'primevue/base/style';
|
|
|
|
|
2024-05-01 08:26:48 +00:00
|
|
|
const theme = ({ dt }) => `
|
|
|
|
.p-megamenu {
|
|
|
|
display: flex;
|
|
|
|
position: relative;
|
|
|
|
padding: 0.5rem 0.5rem;
|
|
|
|
background: ${dt('megamenu.background')};
|
|
|
|
color: ${dt('megamenu.color')};
|
|
|
|
border: 1px solid ${dt('megamenu.border.color')};
|
|
|
|
border-radius: ${dt('rounded.base')};
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-root-list {
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
2024-05-02 10:56:41 +00:00
|
|
|
outline: 0;
|
2024-05-01 08:26:48 +00:00
|
|
|
list-style: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-item-content {
|
|
|
|
transition: background-color ${dt('transition.duration')}, color ${dt('transition.duration')};
|
|
|
|
border-radius: ${dt('rounded.sm')};
|
|
|
|
color: ${dt('megamenu.item.color')};
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-item-link {
|
|
|
|
cursor: pointer;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
text-decoration: none;
|
|
|
|
overflow: hidden;
|
|
|
|
position: relative;
|
|
|
|
color: inherit;
|
|
|
|
padding: 0.5rem 0.75rem;
|
|
|
|
user-select: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-item-label {
|
|
|
|
line-height: 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-item-icon {
|
|
|
|
color: ${dt('megamenu.item.icon.color')};
|
|
|
|
margin-right: 0.5rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-item.p-focus > .p-megamenu-item-content {
|
2024-05-05 15:51:29 +00:00
|
|
|
color: ${dt('megamenu.item.focus.color')};
|
|
|
|
background: ${dt('megamenu.item.focus.background')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-item.p-focus > .p-megamenu-item-content .p-megamenu-item-icon,
|
|
|
|
.p-megamenu-item.p-focus > .p-megamenu-item-content .p-megamenu-submenu-icon {
|
2024-05-04 17:06:51 +00:00
|
|
|
color: ${dt('megamenu.item.icon.hover.color')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-item:not(.p-disabled) > .p-megamenu-item-content:hover {
|
2024-05-05 15:51:29 +00:00
|
|
|
color: ${dt('megamenu.item.focus.color')};
|
|
|
|
background: ${dt('megamenu.item.focus.background')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.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-submenu-icon {
|
2024-05-04 17:06:51 +00:00
|
|
|
color: ${dt('megamenu.item.icon.hover.color')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-item-active > .p-megamenu-item-content {
|
2024-05-05 15:51:29 +00:00
|
|
|
color: ${dt('megamenu.item.focus.color')};
|
|
|
|
background: ${dt('megamenu.item.focus.background')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-item-active > .p-megamenu-item-content .p-megamenu-item-icon,
|
|
|
|
.p-megamenu-item-active > .p-megamenu-item-content .p-megamenu-submenu-icon {
|
2024-05-04 17:06:51 +00:00
|
|
|
color: ${dt('megamenu.item.icon.hover.color')};
|
2024-05-01 08:26:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.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 {
|
|
|
|
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('rounded.base')};
|
|
|
|
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-root-list > .p-megamenu-item-active > .p-megamenu-panel {
|
|
|
|
display: block;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-submenu {
|
|
|
|
margin: 0;
|
|
|
|
list-style: none;
|
|
|
|
padding: 0.25rem 0.25rem;
|
|
|
|
min-width: 12.5rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-submenu .p-megamenu-item {
|
|
|
|
margin: 2px 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.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;
|
2024-05-04 17:06:51 +00:00
|
|
|
color: ${dt('megamenu.submenu.item.color')};
|
2024-05-01 08:26:48 +00:00
|
|
|
font-weight: 600;
|
|
|
|
margin-bottom: 2px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-submenu .p-menuitem-separator {
|
|
|
|
border-top: 1px solid ${dt('megamenu.separator.border.color')};
|
|
|
|
margin: 2px 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-horizontal {
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-horizontal .p-megamenu-root-list {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
flex-wrap: wrap;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-horizontal .p-megamenu-end {
|
|
|
|
margin-left: auto;
|
|
|
|
align-self: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-vertical {
|
|
|
|
display: inline-flex;
|
|
|
|
flex-direction: column;
|
|
|
|
min-width: 12.5rem;
|
|
|
|
padding: 0.25rem 0.25rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-vertical .p-megamenu-root-list {
|
|
|
|
flex-direction: column;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-vertical .p-megamenu-root-list > .p-megamenu-item-active > .p-megamenu-panel {
|
|
|
|
left: 100%;
|
|
|
|
top: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-vertical .p-megamenu-root-list > .p-megamenu-item > .p-megamenu-item-content .p-megamenu-submenu-icon {
|
|
|
|
margin-left: auto;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-grid {
|
|
|
|
display: flex;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-col-2,
|
|
|
|
.p-megamenu-col-3,
|
|
|
|
.p-megamenu-col-4,
|
|
|
|
.p-megamenu-col-6,
|
|
|
|
.p-megamenu-col-12 {
|
|
|
|
flex: 0 0 auto;
|
|
|
|
padding: 0.5rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-col-2 {
|
|
|
|
width: 16.6667%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-col-3 {
|
|
|
|
width: 25%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-col-4 {
|
|
|
|
width: 33.3333%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-col-6 {
|
|
|
|
width: 50%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-col-12 {
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-button {
|
|
|
|
display: none;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
cursor: pointer;
|
|
|
|
width: 1.75rem;
|
|
|
|
height: 1.75rem;
|
|
|
|
position: relative;
|
|
|
|
color: ${dt('megamenu.mobile.toggle.color')};
|
|
|
|
border: 0 none;
|
|
|
|
background: transparent;
|
|
|
|
border-radius: 50%;
|
|
|
|
transition: background-color ${dt('transition.duration')}, color ${dt('transition.duration')}, outline-color ${dt('transition.duration')};
|
|
|
|
outline-color: transparent;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-button:hover {
|
|
|
|
color: ${dt('megamenu.mobile.toggle.hover.color')};
|
|
|
|
background: ${dt('megamenu.mobile.toggle.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')};
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-mobile {
|
|
|
|
display: flex;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-mobile .p-megamenu-button {
|
|
|
|
display: flex;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-mobile .p-megamenu-root-list {
|
|
|
|
position: absolute;
|
|
|
|
display: none;
|
|
|
|
flex-direction: column;
|
|
|
|
top: 100%;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-mobile-active .p-megamenu-root-list {
|
|
|
|
display: flex;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-mobile .p-megamenu-root-list .p-megamenu-item {
|
|
|
|
width: 100%;
|
|
|
|
position: static;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-mobile .p-megamenu-panel {
|
|
|
|
position: static;
|
|
|
|
border: 0 none;
|
|
|
|
border-radius: 0;
|
|
|
|
box-shadow: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-mobile .p-megamenu-grid {
|
|
|
|
flex-wrap: wrap;
|
|
|
|
overflow: auto;
|
|
|
|
max-height: 90%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-mobile .p-megamenu-root-list > .p-megamenu-item > .p-megamenu-item-content .p-megamenu-submenu-icon {
|
|
|
|
margin-left: auto;
|
|
|
|
transition: transform 0.2s;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-megamenu-mobile .p-megamenu-root-list > .p-megamenu-item-active > .p-megamenu-item-content .p-megamenu-submenu-icon {
|
|
|
|
transform: rotate(-180deg);
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2023-10-02 10:46:09 +00:00
|
|
|
const inlineStyles = {
|
|
|
|
submenu: ({ instance, processedItem }) => ({ display: instance.isItemActive(processedItem) ? 'block' : 'none' })
|
|
|
|
};
|
|
|
|
|
|
|
|
const classes = {
|
|
|
|
root: ({ instance }) => [
|
|
|
|
'p-megamenu p-component',
|
|
|
|
{
|
2023-11-15 10:16:57 +00:00
|
|
|
'p-megamenu-mobile': instance.queryMatches,
|
2023-11-15 11:30:23 +00:00
|
|
|
'p-megamenu-mobile-active': instance.mobileActive,
|
2023-10-02 10:46:09 +00:00
|
|
|
'p-megamenu-horizontal': instance.horizontal,
|
|
|
|
'p-megamenu-vertical': instance.vertical
|
|
|
|
}
|
|
|
|
],
|
|
|
|
start: 'p-megamenu-start',
|
2024-04-30 13:02:03 +00:00
|
|
|
button: 'p-megamenu-button',
|
|
|
|
rootList: 'p-megamenu-root-list',
|
|
|
|
submenuItem: ({ instance, processedItem }) => [
|
2024-04-09 13:51:16 +00:00
|
|
|
'p-megamenu-submenu-item',
|
2023-10-02 10:46:09 +00:00
|
|
|
{
|
|
|
|
'p-disabled': instance.isItemDisabled(processedItem)
|
|
|
|
}
|
|
|
|
],
|
2024-04-30 13:02:03 +00:00
|
|
|
item: ({ instance, processedItem }) => [
|
2024-04-09 13:51:16 +00:00
|
|
|
'p-megamenu-item',
|
2023-10-02 10:46:09 +00:00
|
|
|
{
|
2024-04-09 13:51:16 +00:00
|
|
|
'p-megamenu-item-active': instance.isItemActive(processedItem),
|
2023-10-02 10:46:09 +00:00
|
|
|
'p-focus': instance.isItemFocused(processedItem),
|
|
|
|
'p-disabled': instance.isItemDisabled(processedItem)
|
|
|
|
}
|
|
|
|
],
|
2024-04-30 13:02:03 +00:00
|
|
|
itemContent: 'p-megamenu-item-content',
|
|
|
|
itemLink: 'p-megamenu-item-link',
|
|
|
|
itemIcon: 'p-megamenu-item-icon',
|
2024-05-06 13:10:13 +00:00
|
|
|
itemLabel: 'p-megamenu-item-label',
|
2024-04-09 13:51:16 +00:00
|
|
|
submenuIcon: 'p-megamenu-submenu-icon',
|
2023-10-02 10:46:09 +00:00
|
|
|
panel: 'p-megamenu-panel',
|
|
|
|
grid: 'p-megamenu-grid',
|
|
|
|
column: ({ instance, processedItem }) => {
|
|
|
|
let length = instance.isItemGroup(processedItem) ? processedItem.items.length : 0;
|
|
|
|
let columnClass;
|
|
|
|
|
2023-11-15 10:16:57 +00:00
|
|
|
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;
|
|
|
|
}
|
2023-10-02 10:46:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return columnClass;
|
|
|
|
},
|
2024-04-09 13:51:16 +00:00
|
|
|
submenu: 'p-megamenu-submenu',
|
2024-04-30 13:02:03 +00:00
|
|
|
submenuItemLabel: 'p-megamenu-submenu-item-label',
|
2024-04-09 13:51:16 +00:00
|
|
|
separator: 'p-megamenu-separator',
|
2023-10-02 10:46:09 +00:00
|
|
|
end: 'p-megamenu-end'
|
|
|
|
};
|
|
|
|
|
|
|
|
export default BaseStyle.extend({
|
|
|
|
name: 'megamenu',
|
2024-05-01 08:26:48 +00:00
|
|
|
theme,
|
2023-10-02 10:46:09 +00:00
|
|
|
classes,
|
|
|
|
inlineStyles
|
|
|
|
});
|