feat: Add support for flyout menu mode in MegaMenu
- Introduced `MegaMenuMode` type and `normalizeMegaMenuMode` function to handle menu modes. - Updated `MegaMenuApplicationCustomizer` to accept `menuMode` property. - Enhanced `MegaMenuRenderer` to render flyout menus based on the selected mode. - Created new HTML previews for both flyout and mega menu modes. - Removed unused mock services and user custom action service interfaces.
This commit is contained in:
@@ -1,482 +1,396 @@
|
||||
@import '~@microsoft/sp-office-ui-fabric-core/dist/sass/SPFabricCore.scss';
|
||||
|
||||
/*
|
||||
Global override example:
|
||||
:root {
|
||||
--themePrimary: #00407f;
|
||||
--themeLighterAlt: #f0f5fa;
|
||||
--themeLighter: #c5d8eb;
|
||||
--themeLight: #98b8d9;
|
||||
--themeTertiary: #477db3;
|
||||
--themeSecondary: #11508f;
|
||||
--themeDarkAlt: #003973;
|
||||
--themeDark: #003061;
|
||||
--themeDarker: #002447;
|
||||
--neutralLighterAlt: #faf9f8;
|
||||
--neutralLighter: #f3f2f1;
|
||||
--neutralLight: #edebe9;
|
||||
--neutralQuaternaryAlt: #e1dfdd;
|
||||
--neutralQuaternary: #d0d0d0;
|
||||
--neutralTertiaryAlt: #c8c6c4;
|
||||
--neutralTertiary: #a19f9d;
|
||||
--neutralSecondary: #605e5c;
|
||||
--neutralSecondaryAlt: #8a8886;
|
||||
--neutralPrimaryAlt: #3b3a39;
|
||||
--neutralPrimary: #323130;
|
||||
--neutralDark: #201f1e;
|
||||
--black: #000000;
|
||||
--white: #ffffff;
|
||||
|
||||
--megaMenuNavBackground: #5f6f74;
|
||||
--megaMenuNavHoverBackground: #6f8085;
|
||||
--megaMenuNavOpenBackground: #728388;
|
||||
--megaMenuNavTextColor: #ffffff;
|
||||
--megaMenuNavDividerColor: rgba(255, 255, 255, 0.22);
|
||||
--megaMenuPanelWidth: 1280px;
|
||||
--megaMenuZIndex: 6000;
|
||||
}
|
||||
*/
|
||||
|
||||
$mm-white: var(--white, #{$ms-color-white});
|
||||
$mm-panel-surface: var(--white, #{$ms-color-white});
|
||||
$mm-panel-border: var(--neutralLight, #{$ms-color-neutralLight});
|
||||
$mm-panel-divider: var(--neutralQuaternaryAlt, #{$ms-color-neutralQuaternaryAlt});
|
||||
$mm-text: var(--neutralPrimary, #{$ms-color-neutralPrimary});
|
||||
$mm-text-muted: var(--neutralSecondary, #{$ms-color-neutralSecondary});
|
||||
$mm-nav-background: var(--megaMenuNavBackground, #5f6f74);
|
||||
$mm-nav-hover-background: var(--megaMenuNavHoverBackground, #6f8085);
|
||||
$mm-nav-open-background: var(--megaMenuNavOpenBackground, #728388);
|
||||
$mm-nav-divider: var(--megaMenuNavDividerColor, rgba(255, 255, 255, 0.22));
|
||||
$mm-nav-text: var(--megaMenuNavTextColor, #ffffff);
|
||||
$mm-focus-accent: var(--themePrimary, #{$ms-color-themePrimary});
|
||||
$mm-focus-soft: var(--themeLighterAlt, #{$ms-color-themeLighterAlt});
|
||||
$mm-panel-shadow: var(--megaMenuPanelShadow, 0 14px 28px rgba(0, 0, 0, 0.18));
|
||||
$mm-panel-width: var(--megaMenuPanelWidth, 1280px);
|
||||
$mm-nav-height: var(--megaMenuTopNavHeight, 34px);
|
||||
$mm-nav-inline-padding: var(--megaMenuNavInlinePadding, 8px);
|
||||
$mm-item-inline-padding: var(--megaMenuItemInlinePadding, 12px);
|
||||
$mm-column-padding-x: var(--megaMenuColumnPaddingX, 18px);
|
||||
$mm-column-padding-y: var(--megaMenuColumnPaddingY, 16px);
|
||||
$mm-link-radius: var(--megaMenuLinkRadius, 2px);
|
||||
$mm-layer-index: var(--megaMenuZIndex, 6000);
|
||||
$white: var(--white, #{$ms-color-white});
|
||||
$neutral-lighter: var(--neutralLighter, #{$ms-color-neutralLighter});
|
||||
$neutral-light: var(--neutralLight, #{$ms-color-neutralLight});
|
||||
$neutral-tertiary: var(--neutralTertiary, #{$ms-color-neutralTertiary});
|
||||
$neutral-secondary: var(--neutralSecondary, #{$ms-color-neutralSecondary});
|
||||
$neutral-primary: var(--neutralPrimary, #{$ms-color-neutralPrimary});
|
||||
$theme-primary: var(--themePrimary, #{$ms-color-themePrimary});
|
||||
$theme-dark: var(--themeDark, #{$ms-color-themeDark});
|
||||
$theme-lighter-alt: var(--themeLighterAlt, #{$ms-color-themeLighterAlt});
|
||||
$menu-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
|
||||
$menu-layer: var(--megaMenuZIndex, 6000);
|
||||
|
||||
:global {
|
||||
:root {
|
||||
--megaMenuNavBackground: #5f6f74;
|
||||
--megaMenuNavHoverBackground: #6f8085;
|
||||
--megaMenuNavOpenBackground: #728388;
|
||||
--megaMenuNavTextColor: #ffffff;
|
||||
--megaMenuNavDividerColor: rgba(255, 255, 255, 0.22);
|
||||
--megaMenuTopNavHeight: 34px;
|
||||
--megaMenuPanelWidth: 1280px;
|
||||
--megaMenuPanelShadow: 0 14px 28px rgba(0, 0, 0, 0.18);
|
||||
--megaMenuZIndex: 6000;
|
||||
--megaMenuNavInlinePadding: 8px;
|
||||
--megaMenuItemInlinePadding: 12px;
|
||||
--megaMenuColumnPaddingX: 18px;
|
||||
--megaMenuColumnPaddingY: 16px;
|
||||
--megaMenuLinkRadius: 2px;
|
||||
--megaMenuColumnCount: 4;
|
||||
}
|
||||
|
||||
.skip-link {
|
||||
position: absolute;
|
||||
top: -40px;
|
||||
left: 6px;
|
||||
background: $mm-focus-accent;
|
||||
color: $mm-white;
|
||||
padding: 8px 12px;
|
||||
text-decoration: none;
|
||||
font-weight: 600;
|
||||
border-radius: 4px;
|
||||
z-index: 10000;
|
||||
transition: top 0.2s ease;
|
||||
}
|
||||
|
||||
.skip-link:focus {
|
||||
top: 6px;
|
||||
}
|
||||
|
||||
#CustomNavigation {
|
||||
position: relative;
|
||||
overflow: visible;
|
||||
z-index: $mm-layer-index;
|
||||
}
|
||||
|
||||
.mega-menu-status {
|
||||
padding: 8px 14px;
|
||||
border-bottom: 1px solid $mm-panel-border;
|
||||
background: $mm-focus-soft;
|
||||
color: $mm-text;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.mega-menu-main {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
background-color: #5f6f74;
|
||||
background-color: $mm-nav-background;
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.18);
|
||||
box-shadow: none;
|
||||
overflow: visible;
|
||||
z-index: $mm-layer-index;
|
||||
}
|
||||
|
||||
.mega-menu-main > ul,
|
||||
.mega-menu-top-level {
|
||||
margin: 0 auto;
|
||||
max-width: $mm-panel-width;
|
||||
background-color: inherit;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
list-style: none;
|
||||
padding: 0 $mm-nav-inline-padding;
|
||||
padding-inline-start: $mm-nav-inline-padding;
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
justify-content: flex-start;
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.mega-menu-main > ul > li,
|
||||
.mega-menu-top-item {
|
||||
position: static;
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
flex: 0 0 auto;
|
||||
border-right: 1px solid $mm-nav-divider;
|
||||
}
|
||||
|
||||
.mega-menu-main > ul > li:last-child,
|
||||
.mega-menu-top-item:last-child {
|
||||
border-right: 0;
|
||||
}
|
||||
|
||||
.mega-menu-main > ul > li > a,
|
||||
.mega-menu-main > ul > li > .menu-item-text,
|
||||
.menu-item-link,
|
||||
.menu-item-text {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-height: $mm-nav-height;
|
||||
padding: 0 $mm-item-inline-padding;
|
||||
color: $mm-nav-text;
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
line-height: 1;
|
||||
text-decoration: none;
|
||||
background: transparent;
|
||||
border: 0;
|
||||
transition: background-color 0.14s ease, color 0.14s ease;
|
||||
outline: none;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.menu-item-text {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.menu-item-has-children::after {
|
||||
content: '';
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
margin-left: 8px;
|
||||
border-right: 1px solid currentColor;
|
||||
border-bottom: 1px solid currentColor;
|
||||
transform: translateY(-1px) rotate(45deg);
|
||||
transition: transform 0.14s ease;
|
||||
}
|
||||
|
||||
.menu-item-has-children[aria-expanded="true"]::after {
|
||||
transform: translateY(1px) rotate(-135deg);
|
||||
}
|
||||
|
||||
.mega-menu-top-item.is-active > a,
|
||||
.mega-menu-top-item.is-active > span,
|
||||
.menu-item-link.is-active,
|
||||
.menu-item-text.is-active {
|
||||
background: $mm-nav-open-background;
|
||||
}
|
||||
|
||||
.mega-menu-top-item.is-current > a,
|
||||
.mega-menu-top-item.is-current > span,
|
||||
.menu-item-link.is-current,
|
||||
.menu-item-text.is-current {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.mega-menu-main > ul > li:hover > a,
|
||||
.mega-menu-main > ul > li:hover > .menu-item-text,
|
||||
.mega-menu-main > ul > li > a[aria-expanded="true"],
|
||||
.mega-menu-main > ul > li > span[aria-expanded="true"],
|
||||
.menu-item-link:hover,
|
||||
.menu-item-text:hover {
|
||||
color: $mm-nav-text;
|
||||
background: $mm-nav-hover-background;
|
||||
}
|
||||
|
||||
.mega-menu-main > ul > li > a[aria-expanded="true"],
|
||||
.mega-menu-main > ul > li > span[aria-expanded="true"] {
|
||||
background: $mm-nav-open-background;
|
||||
}
|
||||
|
||||
.mega-menu-main > ul > li > a:focus,
|
||||
.mega-menu-main > ul > li > .menu-item-text:focus,
|
||||
.menu-item-link:focus,
|
||||
.menu-item-text:focus {
|
||||
color: $mm-nav-text;
|
||||
background: $mm-nav-open-background;
|
||||
box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.65);
|
||||
}
|
||||
|
||||
.mega-menu {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 100%;
|
||||
display: none;
|
||||
visibility: hidden;
|
||||
opacity: 0;
|
||||
background-color: #ffffff;
|
||||
background-color: $mm-panel-surface;
|
||||
background-image: none;
|
||||
mix-blend-mode: normal;
|
||||
border: 1px solid $mm-panel-border;
|
||||
border-top: 0;
|
||||
box-shadow: $mm-panel-shadow;
|
||||
max-height: calc(100vh - #{$mm-nav-height});
|
||||
isolation: isolate;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
z-index: calc(#{$mm-layer-index} + 1);
|
||||
transition: opacity 0.16s ease, visibility 0.16s ease;
|
||||
}
|
||||
|
||||
.mega-menu-main > ul > li:hover .mega-menu,
|
||||
.mega-menu.js-open {
|
||||
visibility: visible;
|
||||
opacity: 1;
|
||||
display: block;
|
||||
background-color: #ffffff;
|
||||
background-color: $mm-panel-surface;
|
||||
background-image: none;
|
||||
}
|
||||
|
||||
.mega-menu-grid {
|
||||
max-width: $mm-panel-width;
|
||||
background-color: inherit;
|
||||
margin: 0 auto;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(var(--megaMenuColumnCount, 4), minmax(0, 1fr));
|
||||
gap: 0;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.mega-menu-category {
|
||||
min-width: 0;
|
||||
padding: $mm-column-padding-y $mm-column-padding-x 14px;
|
||||
border-right: 1px solid $mm-panel-divider;
|
||||
}
|
||||
|
||||
.mega-menu-grid > .mega-menu-category:last-child {
|
||||
border-right: 0;
|
||||
}
|
||||
|
||||
.mega-menu-category > h3,
|
||||
.mega-menu-category-title {
|
||||
margin: 0 0 10px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.mega-menu-category > h3 > span,
|
||||
.mega-menu-category > h3 > a {
|
||||
display: block;
|
||||
color: $mm-text;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
line-height: 18px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.mega-menu-category.is-active > h3 > span,
|
||||
.mega-menu-category.is-active > h3 > a,
|
||||
.mega-menu-category > h3 > span.is-active,
|
||||
.mega-menu-category > h3 > a.is-active {
|
||||
color: $mm-text;
|
||||
}
|
||||
|
||||
.mega-menu-category.is-current > h3 > a,
|
||||
.mega-menu-category > h3 > a.is-current {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.mega-menu-category > h3 > a:hover {
|
||||
color: $mm-text;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.mega-menu-category > h3 > a:focus {
|
||||
background: $mm-focus-soft;
|
||||
color: $mm-text;
|
||||
border-radius: 2px;
|
||||
box-shadow: 0 0 0 2px $mm-focus-accent;
|
||||
padding: 1px 4px;
|
||||
margin: -1px -4px;
|
||||
}
|
||||
|
||||
.mega-menu-category ul,
|
||||
.mega-menu-links {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding-inline-start: 0;
|
||||
}
|
||||
|
||||
.mega-menu-category ul li,
|
||||
.mega-menu-links li {
|
||||
margin: 0 0 6px;
|
||||
}
|
||||
|
||||
.mega-menu-category ul li:last-child,
|
||||
.mega-menu-links li:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.mega-menu-category ul li a,
|
||||
.mega-menu-links li a {
|
||||
display: block;
|
||||
margin: 0;
|
||||
padding: 1px 2px;
|
||||
border-radius: $mm-link-radius;
|
||||
color: $mm-text-muted;
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
line-height: 18px;
|
||||
text-decoration: none;
|
||||
transition: background-color 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
|
||||
}
|
||||
|
||||
.mega-menu-category ul li.is-active > a,
|
||||
.mega-menu-links li.is-active > a,
|
||||
.mega-menu-category ul li a.is-active,
|
||||
.mega-menu-links li a.is-active {
|
||||
color: $mm-text;
|
||||
}
|
||||
|
||||
.mega-menu-category ul li.is-current > a,
|
||||
.mega-menu-links li.is-current > a,
|
||||
.mega-menu-category ul li a.is-current,
|
||||
.mega-menu-links li a.is-current {
|
||||
color: $mm-text;
|
||||
font-weight: 600;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.mega-menu-category ul li a:hover,
|
||||
.mega-menu-links li a:hover {
|
||||
background: transparent;
|
||||
color: $mm-text;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.mega-menu-category ul li a:focus,
|
||||
.mega-menu-links li a:focus {
|
||||
background: $mm-focus-soft;
|
||||
color: $mm-text;
|
||||
box-shadow: 0 0 0 2px $mm-focus-accent;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
padding: 0;
|
||||
margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
.mega-menu-grid {
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
:root {
|
||||
--megaMenuBarHeight: 44px;
|
||||
--megaMenuContentWidth: 1200px;
|
||||
--megaMenuFlyoutWidth: 288px;
|
||||
--megaMenuZIndex: 6000;
|
||||
}
|
||||
|
||||
.mega-menu-category {
|
||||
padding: 14px 16px 12px;
|
||||
#CustomNavigation {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
overflow: visible;
|
||||
z-index: $menu-layer;
|
||||
font-family: 'Segoe UI', 'Segoe UI Web (West European)', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', sans-serif;
|
||||
}
|
||||
|
||||
.mega-menu-status {
|
||||
box-sizing: border-box;
|
||||
padding: 10px 24px;
|
||||
border-bottom: 1px solid $neutral-light;
|
||||
background: $theme-lighter-alt;
|
||||
color: $neutral-primary;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.mega-menu-main {
|
||||
position: relative;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
min-height: var(--megaMenuBarHeight, 44px);
|
||||
overflow: visible;
|
||||
border-top: 1px solid $neutral-light;
|
||||
border-bottom: 1px solid $neutral-light;
|
||||
background: $white;
|
||||
color: $neutral-primary;
|
||||
z-index: $menu-layer;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.mega-menu-main > ul,
|
||||
.mega-menu-top-level {
|
||||
padding: 0 6px;
|
||||
padding-inline-start: 6px;
|
||||
flex-wrap: wrap;
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
max-width: var(--megaMenuContentWidth, 1200px);
|
||||
min-height: var(--megaMenuBarHeight, 44px);
|
||||
margin: 0 auto;
|
||||
padding: 0 24px;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.mega-menu-main > ul > li,
|
||||
.mega-menu-top-item {
|
||||
border-right: 0;
|
||||
position: static;
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.mega-menu-mode-flyout .mega-menu-top-item {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.mega-menu-main > ul > li > a,
|
||||
.mega-menu-main > ul > li > .menu-item-text,
|
||||
.menu-item-link,
|
||||
.menu-item-text {
|
||||
min-height: 36px;
|
||||
padding: 0 10px;
|
||||
font-size: 12px;
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
box-sizing: border-box;
|
||||
min-height: var(--megaMenuBarHeight, 44px);
|
||||
padding: 0 16px;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: $neutral-primary;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
line-height: 20px;
|
||||
text-decoration: none;
|
||||
white-space: nowrap;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.menu-item-has-children::after {
|
||||
content: '';
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
margin: -3px 0 0 10px;
|
||||
border-right: 1px solid currentColor;
|
||||
border-bottom: 1px solid currentColor;
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
|
||||
.menu-item-link:hover,
|
||||
.menu-item-text:hover,
|
||||
.menu-item-link[aria-expanded='true'],
|
||||
.menu-item-text[aria-expanded='true'] {
|
||||
background: $neutral-lighter;
|
||||
color: $neutral-primary;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.mega-menu-top-item.is-active > .menu-item-link::before,
|
||||
.mega-menu-top-item.is-active > .menu-item-text::before,
|
||||
.mega-menu-top-item.is-current > .menu-item-link::before,
|
||||
.mega-menu-top-item.is-current > .menu-item-text::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
right: 12px;
|
||||
bottom: 0;
|
||||
left: 12px;
|
||||
height: 2px;
|
||||
background: $theme-primary;
|
||||
}
|
||||
|
||||
.mega-menu-top-item.is-current > .menu-item-link,
|
||||
.mega-menu-top-item.is-current > .menu-item-text {
|
||||
color: $theme-dark;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.menu-item-link:focus,
|
||||
.menu-item-text:focus,
|
||||
.mega-menu-category a:focus,
|
||||
.flyout-link:focus {
|
||||
outline: 2px solid $theme-primary;
|
||||
outline-offset: -2px;
|
||||
}
|
||||
|
||||
.mega-menu {
|
||||
border-left: 0;
|
||||
border-right: 0;
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
left: 0;
|
||||
right: 0;
|
||||
display: none;
|
||||
box-sizing: border-box;
|
||||
visibility: hidden;
|
||||
opacity: 0;
|
||||
border: 1px solid $neutral-light;
|
||||
border-top: 0;
|
||||
background: $white;
|
||||
box-shadow: $menu-shadow;
|
||||
color: $neutral-primary;
|
||||
z-index: calc(#{$menu-layer} + 1);
|
||||
}
|
||||
|
||||
.mega-menu.js-open {
|
||||
display: block;
|
||||
visibility: visible;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.mega-menu-grid {
|
||||
grid-template-columns: 1fr;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(var(--megaMenuColumnCount, 4), minmax(0, 1fr));
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
max-width: var(--megaMenuContentWidth, 1200px);
|
||||
margin: 0 auto;
|
||||
padding: 24px;
|
||||
gap: 24px 32px;
|
||||
background: $white;
|
||||
}
|
||||
|
||||
.mega-menu-category {
|
||||
padding: 14px 12px;
|
||||
border-right: 0;
|
||||
border-bottom: 1px solid $mm-panel-divider;
|
||||
min-width: 0;
|
||||
padding: 0 0 8px;
|
||||
}
|
||||
|
||||
.mega-menu-grid > .mega-menu-category:last-child {
|
||||
border-bottom: 0;
|
||||
.mega-menu-category-title {
|
||||
margin: 0 0 10px;
|
||||
padding: 0 0 8px;
|
||||
border-bottom: 1px solid $neutral-light;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.skip-link,
|
||||
.menu-item-has-children::after,
|
||||
.mega-menu-main > ul > li > a,
|
||||
.mega-menu-main > ul > li > .menu-item-text,
|
||||
.menu-item-link,
|
||||
.menu-item-text,
|
||||
.mega-menu,
|
||||
.mega-menu-category ul li a,
|
||||
.mega-menu-links li a {
|
||||
transition: none;
|
||||
.mega-menu-category-title > a,
|
||||
.mega-menu-category-title > span {
|
||||
display: block;
|
||||
color: $neutral-primary;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
line-height: 20px;
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-contrast: high) {
|
||||
.mega-menu-main > ul > li > a:focus,
|
||||
.mega-menu-main > ul > li > .menu-item-text:focus,
|
||||
.menu-item-link:focus,
|
||||
.menu-item-text:focus,
|
||||
.mega-menu-category > h3 > a:focus,
|
||||
.mega-menu-category ul li a:focus,
|
||||
.mega-menu-links li a:focus {
|
||||
outline: 2px solid;
|
||||
outline-offset: 2px;
|
||||
box-shadow: none;
|
||||
.mega-menu-category-title > a:hover {
|
||||
color: $theme-primary;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.mega-menu-links {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.mega-menu-links li {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.mega-menu-links a {
|
||||
display: block;
|
||||
margin: 0 -8px;
|
||||
padding: 6px 8px;
|
||||
border-radius: 2px;
|
||||
color: $neutral-secondary;
|
||||
font-size: 14px;
|
||||
line-height: 20px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.mega-menu-links a:hover {
|
||||
background: $neutral-lighter;
|
||||
color: $neutral-primary;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.mega-menu-links a.is-current,
|
||||
.mega-menu-links li.is-current > a {
|
||||
color: $theme-dark;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.mega-menu-flyout {
|
||||
right: auto;
|
||||
width: var(--megaMenuFlyoutWidth, 288px);
|
||||
min-width: 240px;
|
||||
border-top: 1px solid $neutral-light;
|
||||
}
|
||||
|
||||
.flyout-list {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
padding: 8px 0;
|
||||
background: $white;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.flyout-item {
|
||||
position: relative;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.flyout-link {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
min-height: 36px;
|
||||
padding: 8px 36px 8px 16px;
|
||||
border: 0;
|
||||
background: $white;
|
||||
color: $neutral-primary;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
line-height: 20px;
|
||||
text-decoration: none;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.flyout-link:hover,
|
||||
.flyout-item:focus-within > .flyout-link,
|
||||
.flyout-item.is-active > .flyout-link {
|
||||
background: $neutral-lighter;
|
||||
color: $neutral-primary;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.flyout-item.is-current > .flyout-link {
|
||||
color: $theme-dark;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.flyout-link-has-children::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
right: 18px;
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
margin-top: -4px;
|
||||
border-top: 1px solid currentColor;
|
||||
border-right: 1px solid currentColor;
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
|
||||
.flyout-level-3 {
|
||||
position: absolute;
|
||||
top: -9px;
|
||||
left: 100%;
|
||||
display: none;
|
||||
width: var(--megaMenuFlyoutWidth, 288px);
|
||||
border: 1px solid $neutral-light;
|
||||
box-shadow: $menu-shadow;
|
||||
z-index: calc(#{$menu-layer} + 2);
|
||||
}
|
||||
|
||||
.flyout-item:hover > .flyout-level-3,
|
||||
.flyout-item:focus-within > .flyout-level-3 {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
padding: 0;
|
||||
margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
.mega-menu-top-level {
|
||||
padding: 0 12px;
|
||||
}
|
||||
|
||||
.mega-menu-grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
padding: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.mega-menu-top-level {
|
||||
flex-wrap: wrap;
|
||||
padding: 0 8px;
|
||||
}
|
||||
|
||||
.menu-item-link,
|
||||
.menu-item-text {
|
||||
min-height: 40px;
|
||||
padding: 0 12px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.mega-menu-grid {
|
||||
grid-template-columns: 1fr;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.mega-menu-mode-flyout .mega-menu-flyout {
|
||||
position: fixed;
|
||||
right: 8px;
|
||||
left: 8px;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.flyout-level-3 {
|
||||
position: static;
|
||||
display: block;
|
||||
width: 100%;
|
||||
border: 0;
|
||||
box-shadow: none;
|
||||
padding: 0 0 4px 16px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.mega-menu,
|
||||
.menu-item-link,
|
||||
.menu-item-text,
|
||||
.flyout-link {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (forced-colors: active) {
|
||||
.menu-item-link:focus,
|
||||
.menu-item-text:focus,
|
||||
.mega-menu-category a:focus,
|
||||
.flyout-link:focus {
|
||||
outline: 2px solid CanvasText;
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* End :global */
|
||||
|
||||
@@ -15,6 +15,7 @@ import { TaxonomyNavigationService } from '../../services/TaxonomyNavigationServ
|
||||
import { MegaMenuRenderer } from './MegaMenuRenderer';
|
||||
import { IMenuItem } from '../../services/IMenuItem';
|
||||
import { debugError, debugLog, debugWarn } from '../../services/MegaMenuDebug';
|
||||
import { MegaMenuMode, normalizeMegaMenuMode } from './MegaMenuMode';
|
||||
|
||||
import './MegaMenu.module.scss';
|
||||
|
||||
@@ -26,6 +27,7 @@ export interface IMegaMenuApplicationCustomizerProperties {
|
||||
termSetId?: string;
|
||||
cacheMinutes?: number;
|
||||
debug?: boolean;
|
||||
menuMode?: MegaMenuMode;
|
||||
}
|
||||
|
||||
export default class MegaMenuApplicationCustomizer
|
||||
@@ -40,7 +42,7 @@ export default class MegaMenuApplicationCustomizer
|
||||
const debug: boolean = this._isDebugEnabled();
|
||||
debugLog(debug, LOG_SOURCE, 'onInit started.', {
|
||||
componentId: UserCustomActionMegaMenuId,
|
||||
version: '2.0.1',
|
||||
version: '2.1.0',
|
||||
properties: this.properties || {},
|
||||
pageUrl: window.location.href,
|
||||
webUrl: this.context.pageContext.web.absoluteUrl,
|
||||
@@ -92,7 +94,8 @@ export default class MegaMenuApplicationCustomizer
|
||||
|
||||
debugLog(debug, LOG_SOURCE, 'Starting MegaMenu rendering.', {
|
||||
termSetIdentifier: termSetIdentifier,
|
||||
cacheMinutes: this._getCacheMinutes()
|
||||
cacheMinutes: this._getCacheMinutes(),
|
||||
menuMode: this._getMenuMode()
|
||||
});
|
||||
this._renderMegaMenu(termSetIdentifier, debug);
|
||||
} else {
|
||||
@@ -127,7 +130,8 @@ export default class MegaMenuApplicationCustomizer
|
||||
|
||||
this._renderer = new MegaMenuRenderer(
|
||||
menuItems,
|
||||
debug
|
||||
debug,
|
||||
this._getMenuMode()
|
||||
);
|
||||
|
||||
this._menuContainer = this._getOrCreateContainer('CustomHeader', this._topPlaceholder);
|
||||
@@ -205,6 +209,10 @@ export default class MegaMenuApplicationCustomizer
|
||||
return isFinite(value) ? Math.min(Math.max(Math.floor(value), 1), 1440) : 15;
|
||||
}
|
||||
|
||||
private _getMenuMode(): MegaMenuMode {
|
||||
return normalizeMegaMenuMode(this.properties && this.properties.menuMode);
|
||||
}
|
||||
|
||||
private _renderStatus(message: string): void {
|
||||
if (!this._topPlaceholder) {
|
||||
return;
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
export type MegaMenuMode = 'megaMenu' | 'flyout';
|
||||
|
||||
export function normalizeMegaMenuMode(value?: string): MegaMenuMode {
|
||||
return value && value.toLowerCase() === 'flyout' ? 'flyout' : 'megaMenu';
|
||||
}
|
||||
@@ -5,8 +5,7 @@
|
||||
|
||||
import { IMenuItem } from '../../services/IMenuItem';
|
||||
import { debugLog } from '../../services/MegaMenuDebug';
|
||||
|
||||
import styles from './MegaMenu.module.scss'; // tslint:disable-line:no-unused-variable
|
||||
import { MegaMenuMode } from './MegaMenuMode';
|
||||
|
||||
const LOG_SOURCE: string = 'MegaMenuRenderer';
|
||||
|
||||
@@ -20,7 +19,8 @@ export class MegaMenuRenderer {
|
||||
|
||||
constructor(
|
||||
private menuItems: IMenuItem[],
|
||||
private debug: boolean = false
|
||||
private debug: boolean = false,
|
||||
private menuMode: MegaMenuMode = 'megaMenu'
|
||||
) { }
|
||||
|
||||
public render(container: HTMLElement): void {
|
||||
@@ -36,7 +36,8 @@ export class MegaMenuRenderer {
|
||||
|
||||
const nav = document.createElement('nav');
|
||||
nav.id = 'Mega-Menu';
|
||||
nav.className = 'mega-menu-main';
|
||||
nav.className = this.joinClasses('mega-menu-main', 'mega-menu-mode-' + this.menuMode);
|
||||
nav.setAttribute('data-menu-mode', this.menuMode);
|
||||
nav.setAttribute('aria-label', 'Hauptnavigation');
|
||||
|
||||
const topLevelUl = document.createElement('ul');
|
||||
@@ -99,8 +100,10 @@ export class MegaMenuRenderer {
|
||||
li.appendChild(topElement);
|
||||
|
||||
if (hasChildren) {
|
||||
const megaMenu = this.createMegaMenu(item);
|
||||
li.appendChild(megaMenu);
|
||||
const childMenu = this.menuMode === 'flyout'
|
||||
? this.createFlyoutMenu(item)
|
||||
: this.createMegaMenu(item);
|
||||
li.appendChild(childMenu);
|
||||
}
|
||||
|
||||
return li;
|
||||
@@ -246,6 +249,88 @@ export class MegaMenuRenderer {
|
||||
return categoryDiv;
|
||||
}
|
||||
|
||||
private createFlyoutMenu(parentItem: IMenuItem): HTMLDivElement {
|
||||
const flyout = document.createElement('div');
|
||||
flyout.className = 'mega-menu mega-menu-flyout';
|
||||
flyout.setAttribute('aria-expanded', 'false');
|
||||
flyout.setAttribute('aria-label', parentItem.label + ' Untermenü');
|
||||
|
||||
const list = document.createElement('ul');
|
||||
list.className = 'flyout-list flyout-level-2';
|
||||
|
||||
if (parentItem.items) {
|
||||
parentItem.items.forEach(secondLevelItem => {
|
||||
list.appendChild(this.createFlyoutItem(secondLevelItem));
|
||||
});
|
||||
}
|
||||
|
||||
flyout.appendChild(list);
|
||||
return flyout;
|
||||
}
|
||||
|
||||
private createFlyoutItem(item: IMenuItem): HTMLLIElement {
|
||||
const li = document.createElement('li');
|
||||
const hasChildren = item.hasChildren() && item.items && item.items.length > 0;
|
||||
const isActive = this.isItemActive(item);
|
||||
const isCurrent = this.isCurrentUrl(item.url);
|
||||
|
||||
li.className = this.joinClasses(
|
||||
'flyout-item',
|
||||
hasChildren ? 'has-children' : undefined,
|
||||
isActive ? 'is-active' : undefined,
|
||||
isCurrent ? 'is-current' : undefined
|
||||
);
|
||||
|
||||
const element = this.createFlyoutElement(item, hasChildren, isActive, isCurrent);
|
||||
li.appendChild(element);
|
||||
|
||||
if (hasChildren && item.items) {
|
||||
const childList = document.createElement('ul');
|
||||
childList.className = 'flyout-list flyout-level-3';
|
||||
childList.setAttribute('aria-label', item.label + ' Untermenü');
|
||||
|
||||
item.items.forEach(thirdLevelItem => {
|
||||
childList.appendChild(this.createFlyoutItem(thirdLevelItem));
|
||||
});
|
||||
|
||||
li.appendChild(childList);
|
||||
}
|
||||
|
||||
return li;
|
||||
}
|
||||
|
||||
private createFlyoutElement(item: IMenuItem, hasChildren: boolean, isActive: boolean, isCurrent: boolean): HTMLElement {
|
||||
const element: HTMLElement = item.url
|
||||
? document.createElement('a')
|
||||
: document.createElement('span');
|
||||
|
||||
if (item.url) {
|
||||
(element as HTMLAnchorElement).href = item.url;
|
||||
} else {
|
||||
element.setAttribute('tabindex', '0');
|
||||
}
|
||||
|
||||
element.textContent = item.label;
|
||||
element.className = this.joinClasses(
|
||||
'flyout-link',
|
||||
hasChildren ? 'flyout-link-has-children' : undefined,
|
||||
isActive ? 'is-active' : undefined,
|
||||
isCurrent ? 'is-current' : undefined
|
||||
);
|
||||
|
||||
if (hasChildren) {
|
||||
element.setAttribute('aria-haspopup', 'true');
|
||||
}
|
||||
if (isCurrent && item.url) {
|
||||
element.setAttribute('aria-current', 'page');
|
||||
}
|
||||
if (item.hoverText) {
|
||||
element.title = item.hoverText;
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
private attachEventListeners(): void {
|
||||
const headings = document.querySelectorAll('#Mega-Menu > ul > li > a, #Mega-Menu > ul > li > .menu-item-text');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user