Skip to content

Commit

Permalink
feat: update navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
Hener Hoop committed Jul 8, 2023
1 parent 3bdb785 commit 5463dca
Show file tree
Hide file tree
Showing 11 changed files with 342 additions and 125 deletions.
2 changes: 1 addition & 1 deletion packages/cxl-lumo-styles/scss/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ html {
0 #{$cxl-box-shadow-width} 0 0 #{$cxl-box-shadow-color} inset;

// cxl-marketing-nav height on desktop
--cxl-marketing-nav-height: 88px;
--cxl-marketing-nav-height: 76px;
}

// @see https://github.com/conversionxl/aybolit/blob/490e58e71f13c2e8a398959f91b938f9309b41f8/packages/cxl-ui/src/components/cxl-marketing-nav.js#L46
Expand Down
30 changes: 28 additions & 2 deletions packages/cxl-lumo-styles/scss/themes/vaadin-context-menu-item.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,36 @@
:host([theme~="cxl-marketing-nav"]:not(.has-description)) {
padding-top: 0;
padding-bottom: 0;
}

:host([theme~="cxl-marketing-nav"]:hover),
:host([theme~="cxl-marketing-nav"][expanded]) {
color: var(--lumo-primary-color);

&::after {
color: var(--lumo-primary-color);
}
}

:host([theme~="cxl-marketing-nav"].vaadin-menu-item.vaadin-context-menu-parent-item)::after {
margin-right: 0;
font-size: var(--lumo-icon-size);
}

@media screen and (min-width: 750px) {
:host([theme~="cxl-marketing-nav"].vaadin-menu-item.back-button-menu-item) {
display: none;
}
}

::slotted(a) {
// Increase link click surface.
display: block;

color: inherit !important; /* stylelint-disable-line declaration-no-important */
text-decoration: none !important; /* stylelint-disable-line declaration-no-important */
}

::slotted(a:not(:hover)) {
text-decoration: none !important; /* stylelint-disable-line declaration-no-important */
::slotted(a:hover) {
color: var(--lumo-primary-color) !important; /* stylelint-disable-line declaration-no-important */
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,15 @@
box-shadow: inset 0 0 0 ($vaadin-focus-ring-thickness * 0.5) var(--lumo-primary-color);
}
}

@media screen and (min-width: 783px) {
:host([theme~="cxl-marketing-nav"]) {
display: block;
width: var(--cxl-vaadin-context-menu-item-max-width);
padding: 0 8px;
}
}

:host([theme~="cxl-marketing-nav"]) [part='items'] ::slotted(.vaadin-menu-item) {
border-radius: 0;
}
23 changes: 23 additions & 0 deletions packages/cxl-lumo-styles/scss/themes/vaadin-overlay.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,26 @@

background-color: var(--lumo-shade-#{$vaadin-overlay-shade-pct * 3.5}#{"pct"});
}

:host([theme~="cxl-marketing-nav"]) [part="content"] {
padding-right: 0;
padding-left: 0;
}

@media screen and (min-width: 750px) {
:host([theme~="cxl-marketing-nav"]) {
position: relative;
top: 0 !important; /* stylelint-disable-line declaration-no-important */
right: 0;
bottom: 0;
left: 0 !important; /* stylelint-disable-line declaration-no-important */
display: block;
width: 376px;
margin: 0;
overflow: auto;
}

:host([theme~="cxl-marketing-nav"]) [part="overlay"] {
box-shadow: none;
}
}
3 changes: 2 additions & 1 deletion packages/cxl-lumo-styles/scss/themes/vaadin-tab.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
:host([theme~="cxl-marketing-nav"]) ::slotted(a[href]:hover) {
text-decoration: underline !important; /* stylelint-disable-line declaration-no-important */
// text-decoration: underline !important; /* stylelint-disable-line declaration-no-important */
color: var(--lumo-primary-color) !important; /* stylelint-disable-line declaration-no-important */
}

:host([theme~="cxl-marketing-nav"][hidden]) {
Expand Down
28 changes: 26 additions & 2 deletions packages/cxl-ui/scss/cxl-marketing-nav.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,19 @@
bottom: 0;
position: fixed;
}
*/
*/

#overlays-wrapper {
position: fixed;
display: flex;
border: 1px solid #d2d5da;
border-radius: 6px;
box-shadow: 0 8px 24px 0 rgba(0, 0, 0, 0.25);

vaadin-context-menu-overlay + vaadin-context-menu-overlay {
border-left: 1px solid var(--lumo-shade-20pct);
}
}

/**
* Menu bar containers configuration.
Expand All @@ -39,12 +51,17 @@
#menu-shadow-items,
::slotted(#menu-global-items) {
background-color: var(--lumo-base-color);

:host([wide]) & {
height: 32px;
background-color: var(--lumo-shade);
}
}

// Light on dark.
::slotted(#menu-primary-items) {
--lumo-tertiary-text-color: var(--lumo-base-color);
background-color: var(--lumo-shade);
background-color: var(--lumo-base-color);
}

/**
Expand All @@ -62,6 +79,13 @@ $menu-item-menu-toggle-index: 2;
display: none;
}

.vaadin-context-menu-item--description {
margin-top: var(--lumo-space-s);
font-family: var(--lumo-font-family);
font-size: var(--lumo-font-size-s);
color: var(--lumo-secondary-text-color);
}

/**
* headroom.js
*/
Expand Down
20 changes: 17 additions & 3 deletions packages/cxl-ui/scss/global/cxl-marketing-nav.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
cxl-marketing-nav {
#menu-global-items {
min-height: 0;
}

#menu-global-items .menu-item {
color: var(--lumo-shade);
}

#menu-primary-items .menu-item {
color: var(--lumo-tint);
color: var(--lumo-shade);
}

&[wide] {
#menu-global-items .menu-item {
color: var(--lumo-base-color);
}
}

&:not([wide]) {
Expand Down Expand Up @@ -71,13 +85,13 @@ vaadin-context-menu-item[theme~="cxl-marketing-nav"] {
.vaadin-context-menu-item--description {
margin-top: var(--lumo-space-s);
font-family: var(--lumo-font-family);
font-size: var(--lumo-font-size-s);
font-size: var(--lumo-font-size-xxs);
color: var(--lumo-secondary-text-color);
}

// Restricts menu item description width to max of parent width.
vaadin-context-menu-list-box {
--cxl-vaadin-context-menu-item-max-width: fit-content;
--cxl-vaadin-context-menu-item-max-width: 360px;
}

/**
Expand Down
57 changes: 19 additions & 38 deletions packages/cxl-ui/src/components/cxl-marketing-nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ export class CXLMarketingNavElement extends LitElement {
<nav>
<slot></slot>
</nav>
<div id="overlays-wrapper"></div>
`;
}

Expand Down Expand Up @@ -157,24 +159,6 @@ export class CXLMarketingNavElement extends LitElement {
*/
// eslint-disable-next-line no-param-reassign
contextMenu.closeOn = 'backBtnClose';

/**
* @todo Needs docblock.
*/
contextMenu.addEventListener('opened-changed', () => {
const listBox = document.querySelector('vaadin-context-menu-list-box');
let listBoxWidth = parseFloat(getComputedStyle(listBox).getPropertyValue('width'));

const vaadinMenuItemComputedStyle = getComputedStyle(
listBox.querySelector('.vaadin-menu-item')
);

listBoxWidth -=
parseFloat(vaadinMenuItemComputedStyle.paddingLeft) +
parseFloat(vaadinMenuItemComputedStyle.paddingRight) * 2;

listBox.style.setProperty('--cxl-vaadin-context-menu-item-max-width', `${listBoxWidth}px`);
});
});

/**
Expand Down Expand Up @@ -236,27 +220,23 @@ export class CXLMarketingNavElement extends LitElement {
_onOverlayOpen(e) {
const overlay = e.target;

/**
* Vertically align context menu panels.
* Check if the child overlay is larger than the top level overlay.
*
* @since 2023.02.11
*/
const overlays = document.querySelectorAll(
'vaadin-context-menu-overlay[theme="cxl-marketing-nav"]'
);
if (window.matchMedia(this._wideMediaQuery).matches) {
const target = this.shadowRoot.querySelector('#overlays-wrapper');
const firstOverlay = document.querySelector(
'vaadin-context-menu-overlay[theme="cxl-marketing-nav"]'
);

if (overlays.length > 1) {
const topLevelOverlay = overlays[0];
const listBox = overlay.querySelector('vaadin-context-menu-list-box');
const previousOverlay = overlays[overlays.length - 2];
const previousListBox = previousOverlay.querySelector('vaadin-context-menu-list-box');
if (target) {
target.style.top = target?.style?.top ? target.style.top : firstOverlay.style.top;
target.style.left = target?.style?.left ? target.style.left : firstOverlay.style.left;
target.style.maxHeight = `${window.innerHeight - (target?.style?.top ? target.offsetTop : firstOverlay.offsetTop)}px`;

requestAnimationFrame(() => {
if (listBox.offsetHeight > previousListBox.offsetHeight) {
overlay.style.top = topLevelOverlay.style.top;
}
});
target.appendChild(overlay);

// to fix wrong overlay error after changing the parent
overlay._placeholder = null;
overlay._exitModalState();
}
}

/**
Expand Down Expand Up @@ -334,7 +314,7 @@ export class CXLMarketingNavElement extends LitElement {
const link = document.createElement('a');

link.href = item.href;
link.text = item.text;
link.innerHTML = item.text;

menuItem.appendChild(link);

Expand All @@ -350,6 +330,7 @@ export class CXLMarketingNavElement extends LitElement {
render(html`${unsafeHTML(item.description)}`, descriptionItem);

menuItem.appendChild(descriptionItem);
menuItem.classList.add('has-description');
}

// eslint-disable-next-line no-param-reassign
Expand Down
Loading

0 comments on commit 5463dca

Please sign in to comment.