Skip to content

Commit

Permalink
feat(cxl-ui): fixed styles matching for menu components
Browse files Browse the repository at this point in the history
  • Loading branch information
freudFlintstone committed Oct 5, 2023
1 parent 9bdb0f7 commit 464ea19
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 23 deletions.
18 changes: 11 additions & 7 deletions packages/cxl-lumo-styles/scss/themes/vaadin-context-menu-item.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
:host([theme~="cxl-marketing-nav"].section-header) {
:host([theme~="menu-bar-item"].section-header) {
font-weight: 600;
color: var(--lumo-body-text-color);
text-transform: uppercase;
Expand All @@ -8,22 +8,22 @@
}
}

:host([theme~="cxl-marketing-nav"].has-description) {
:host([theme~="menu-bar-item"].has-description) {
[part="content"] ::slotted(.vaadin-context-menu-item--description) {
font-weight: 400;
}
}

:host([theme~="cxl-marketing-nav"]:not(.section-header):hover),
:host([theme~="cxl-marketing-nav"]:not(.section-header)[expanded]) {
:host([theme~="menu-bar-item"]:not(.section-header):hover),
:host([theme~="menu-bar-item"]:not(.section-header)[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) {
:host([theme~="menu-bar-item"].vaadin-menu-item.vaadin-context-menu-parent-item) {
padding-block: 0;

&::after {
Expand All @@ -33,12 +33,12 @@
}

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

:host([theme~="cxl-marketing-nav"]) [part="checkmark"][aria-hidden="true"] {
:host([theme~="menu-bar-item"]) [part="checkmark"][aria-hidden="true"] {
display: none;
}

Expand Down Expand Up @@ -67,4 +67,8 @@
font-weight: 400;
color: var(--lumo-secondary-text-color);
}

::slotted(.vaadin-context-menu-item--label) {
margin-top: 0 !important;
}
}
9 changes: 9 additions & 0 deletions packages/cxl-lumo-styles/scss/themes/vaadin-overlay.scss
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,12 @@
display: none;
}
}

:host([theme~="cxl-navigation"]) {

&::part(overlay) {
box-shadow: 0 0 0 1px var(--lumo-shade-5pct),
0 2px 6px -1px var(--lumo-shade-5pct),
0 8px 24px -4px var(--lumo-shade-5pct);
}
}
31 changes: 22 additions & 9 deletions packages/cxl-ui/scss/cxl-navigation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,39 @@
}

nav {
box-sizing: border-box;
display: flex;
justify-content: center;
align-items: center;
max-width: 100vw;
width: 100%;
padding: 0 var(--lumo-space-m);

.container {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
max-width: var(--cxl-content-max-width-wide, none);
}

vaadin-menu-bar {
max-width: 100%;
width: 100%;
}

::part(menu-bar-button), ::slotted(.menu-item) {
white-space: nowrap;
}

::slotted(.menu-item-split-nav) {
margin-left: auto;
}

/* stylelint-disable-next-line selector-no-qualifying-type */
&#menu-global-items {
background-color: var(--lumo-shade);
::part(menu-bar-button) {

::part(menu-bar-button), ::slotted(.menu-item) {
color: var(--lumo-tint);
}
}
Expand All @@ -27,12 +47,5 @@
&#menu-primary-items {
background-color: var(--lumo-base-color);
}

vaadin-context-menu-overlay {

h5 {
margin-top: 0;
}
}
}
}
27 changes: 22 additions & 5 deletions packages/cxl-ui/src/components/cxl-navigation.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable import/no-extraneous-dependencies */
import { LitElement, html } from 'lit';
import { customElement, property, state } from 'lit/decorators.js';
import '@conversionxl/cxl-lumo-styles';
import { registerGlobalStyles } from '@conversionxl/cxl-lumo-styles/src/utils';
import cxlNavigationStyles from '../styles/cxl-navigation-css.js';
import cxlMarketingNavGlobalStyles from '../styles/global/cxl-marketing-nav-css.js';
Expand Down Expand Up @@ -47,14 +48,20 @@ export class CXLNavigationElement extends LitElement {
this.requestUpdate('groups')
}

static createItem({ text, description, sectionheader, component, href }) {
static createItem({ text, description, sectionheader, component, icon, href, children, depth }) {
const item = document.createElement('vaadin-context-menu-item');

if (component === 'hr') {
return document.createElement('hr');
}

if (href) {
if (icon) {
const vaadinIcon = document.createElement('vaadin-icon');
vaadinIcon.setAttribute('icon', `lumo:${icon}`);
item.appendChild(vaadinIcon);
}

if (href && !children) {
const link = document.createElement('a');
link.href = href;
link.innerText = text;
Expand All @@ -74,6 +81,13 @@ export class CXLNavigationElement extends LitElement {
descriptiondiv.appendChild(document.createTextNode(description));
item.appendChild(descriptiondiv);
}

if (children?.length && depth === 0) {
const vaadinIcon = document.createElement('vaadin-icon');
vaadinIcon.setAttribute('icon', 'lumo:dropdown');
item.appendChild(vaadinIcon);
}

return item;
}

Expand All @@ -93,9 +107,12 @@ export class CXLNavigationElement extends LitElement {
const { name, items } = group;
return html`
<nav id="menu-${name}-items">
<slot name="${name}-before"></slot>
<vaadin-menu-bar theme="tertiary" .items=${items}></vaadin-menu-bar>
<slot name="${name}-after"></slot>
<div class="container">
<slot name="${name}-before"></slot>
<vaadin-menu-bar theme="tertiary cxl-navigation" .items=${items}></vaadin-menu-bar>
<slot name="${name}-after"></slot>
<slot name="${name}-end"></slot>
</div>
</nav>
`
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,23 @@ export const CXLNavigation = (args) => {
}
</style>
<cxl-navigation .contextMenuItems=${contextMenuItems}>
<vaadin-context-menu-item slot="global-before">
<vaadin-menu-bar-button slot="global-before">
<a href="https://cxl.com">
<vaadin-icon icon="cxl:logo" style="width: var(--lumo-icon-size-xl, 48px);"></vaadin-icon>
</a>
</vaadin-context-menu-item>
</vaadin-menu-bar-button>
<vaadin-menu-bar-button class="menu-item" slot="global-after">
<a href="https://speero.com/case-studies">Agency case studies</a>
</vaadin-menu-bar-button>
<vaadin-menu-bar-button class="menu-item" slot="global-after">
<a href="https://cxl.com/blog/">Blog</a>
</vaadin-menu-bar-button>
<vaadin-menu-bar-button class="menu-item" slot="global-after">
<a href="https://cxl.com/live/">CXL Live 2023
<vaadin-icon icon="cxl:live" style="color: var(--lumo-primary-color)"></vaadin-icon>
</a
></vaadin-menu-bar-button>
<vaadin-menu-bar-button class="menu-item menu-item-split-nav" slot="global-end"><a>Help</a></vaadin-menu-bar-button>
</cxl-navigation>
<div id="wp-admin-bar" ?hidden=${!args?.loggedIn}>
wp-admin bar: test nav menu placement
Expand Down

0 comments on commit 464ea19

Please sign in to comment.