primevue-mirror/components/lib/megamenu/style/MegaMenuStyle.js

381 lines
10 KiB
JavaScript
Raw Normal View History

import BaseStyle from 'primevue/base/style';
const theme = ({ dt }) => `
.p-megamenu {
position: relative;
2024-05-11 08:33:40 +00:00
display: flex;
align-items: center;
background: ${dt('megamenu.background')};
border: 1px solid ${dt('megamenu.border.color')};
2024-05-11 08:33:40 +00:00
border-radius: ${dt('megamenu.border.radius')};
color: ${dt('megamenu.color')};
}
.p-megamenu-root-list {
margin: 0;
padding: 0;
list-style: none;
2024-05-11 08:33:40 +00:00
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 {
2024-05-11 08:33:40 +00:00
transition: background ${dt('transition.duration')}, color ${dt('transition.duration')};
border-radius: ${dt('megamenu.item.border.radius')};
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;
2024-05-11 08:33:40 +00:00
padding: ${dt('megamenu.item.padding')};
gap: ${dt('megamenu.item.gap')};
user-select: none;
2024-05-11 08:33:40 +00:00
outline: 0 none;
}
.p-megamenu-item-label {
line-height: 1;
}
.p-megamenu-item-icon {
color: ${dt('megamenu.item.icon.color')};
2024-05-11 08:33:40 +00:00
}
.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 {
2024-05-05 15:51:29 +00:00
color: ${dt('megamenu.item.focus.color')};
background: ${dt('megamenu.item.focus.background')};
}
2024-05-11 08:33:40 +00:00
.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 {
2024-05-11 08:33:40 +00:00
color: ${dt('megamenu.submenu.icon.focus.color')};
}
.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-11 08:33:40 +00:00
.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 {
2024-05-11 08:33:40 +00:00
color: ${dt('megamenu.submenu.icon.focus.color')};
}
.p-megamenu-item-active > .p-megamenu-item-content {
2024-05-11 08:33:40 +00:00
color: ${dt('megamenu.item.active.color')};
background: ${dt('megamenu.item.active.background')};
}
2024-05-11 08:33:40 +00:00
.p-megamenu-item-active > .p-megamenu-item-content .p-megamenu-item-icon {
color: ${dt('megamenu.item.icon.active.color')};
}
2024-05-11 08:33:40 +00:00
.p-megamenu-item-active > .p-megamenu-item-content .p-megamenu-submenu-icon {
color: ${dt('megamenu.submenu.icon.active.color')};
}
2024-05-11 08:33:40 +00:00
.p-megamenu-overlay {
display: none;
position: absolute;
width: auto;
z-index: 1;
left: 0;
min-width: 100%;
2024-05-11 08:33:40 +00:00
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')};
}
2024-05-11 08:33:40 +00:00
.p-megamenu-root-list > .p-megamenu-item-active > .p-megamenu-overlay {
display: block;
}
.p-megamenu-submenu {
margin: 0;
list-style: none;
2024-05-11 08:33:40 +00:00
padding: ${dt('megamenu.submenu.padding')};
min-width: 12.5rem;
2024-05-11 08:33:40 +00:00
display: flex;
flex-direction: column;
gap: ${dt('megamenu.submenu.gap')}
}
2024-05-11 08:33:40 +00:00
.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')};
}
2024-05-11 08:33:40 +00:00
.p-megamenu-separator {
border-top: 1px solid ${dt('megamenu.separator.border.color')};
}
.p-megamenu-horizontal {
align-items: center;
2024-05-11 08:33:40 +00:00
padding: ${dt('megamenu.horizontal.orientation.padding')};
}
.p-megamenu-horizontal .p-megamenu-root-list {
display: flex;
align-items: center;
flex-wrap: wrap;
2024-05-11 08:33:40 +00:00
gap: ${dt('megamenu.horizontal.orientation.gap')};
}
.p-megamenu-horizontal .p-megamenu-end {
margin-left: auto;
align-self: center;
}
.p-megamenu-vertical {
display: inline-flex;
min-width: 12.5rem;
2024-05-11 08:33:40 +00:00
flex-direction: column;
align-items: stretch;
padding: ${dt('megamenu.vertical.orientation.padding')};
}
.p-megamenu-vertical .p-megamenu-root-list {
2024-05-11 08:33:40 +00:00
align-items: stretch;
flex-direction: column;
2024-05-11 08:33:40 +00:00
gap: ${dt('megamenu.vertical.orientation.gap')};
}
2024-05-11 08:33:40 +00:00
.p-megamenu-vertical .p-megamenu-root-list > .p-megamenu-item-active > .p-megamenu-overlay {
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;
2024-05-11 08:33:40 +00:00
padding: ${dt('megamenu.overlay.gap')};
}
.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;
2024-05-11 08:33:40 +00:00
width: ${dt('megamenu.mobile.button.size')};
height: ${dt('megamenu.mobile.button.size')};
position: relative;
2024-05-11 08:33:40 +00:00
color: ${dt('megamenu.mobile.button.color')};
border: 0 none;
background: transparent;
2024-05-11 08:33:40 +00:00
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 {
2024-05-11 08:33:40 +00:00
color: ${dt('megamenu.mobile.button.hover.color')};
background: ${dt('megamenu.mobile.button.hover.background')};
}
.p-megamenu-button:focus-visible {
2024-05-11 08:33:40 +00:00
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 {
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%;
2024-05-11 08:33:40 +00:00
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 {
display: flex;
}
.p-megamenu-mobile .p-megamenu-root-list .p-megamenu-item {
width: 100%;
position: static;
}
2024-05-11 08:33:40 +00:00
.p-megamenu-mobile .p-megamenu-overlay {
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);
}
`;
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,
'p-megamenu-mobile-active': instance.mobileActive,
'p-megamenu-horizontal': instance.horizontal,
'p-megamenu-vertical': instance.vertical
}
],
start: 'p-megamenu-start',
button: 'p-megamenu-button',
rootList: 'p-megamenu-root-list',
2024-05-11 08:33:40 +00:00
submenuLabel: ({ instance, processedItem }) => [
'p-megamenu-submenu-label',
{
'p-disabled': instance.isItemDisabled(processedItem)
}
],
item: ({ instance, processedItem }) => [
2024-04-09 13:51:16 +00:00
'p-megamenu-item',
{
2024-04-09 13:51:16 +00:00
'p-megamenu-item-active': instance.isItemActive(processedItem),
'p-focus': instance.isItemFocused(processedItem),
'p-disabled': instance.isItemDisabled(processedItem)
}
],
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',
2024-05-11 08:33:40 +00:00
overlay: 'p-megamenu-overlay',
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;
}
}
return columnClass;
},
2024-04-09 13:51:16 +00:00
submenu: 'p-megamenu-submenu',
separator: 'p-megamenu-separator',
end: 'p-megamenu-end'
};
export default BaseStyle.extend({
name: 'megamenu',
theme,
classes,
inlineStyles
});