Skip to content

Commit

Permalink
fix(cloud-mega-menu): add style and polish the Cloud mega menu & keep…
Browse files Browse the repository at this point in the history
… platform visible on all bps (#5853)

### Related Ticket(s)

DDS Ticket: N/A
HC JIRA Ticket: https://jsw.ibm.com/browse/HC-1813

### Description
- This PR implements styles and any other remaining polishing items for the Mega Menu design enhancements that are part of the "Unified Cloud Masthead + Mega Menu Project" (see project overview doc - https://ibm.ent.box.com/notes/775640792107).
- This is a follow-up PR to @annawen1's work for adding the baseline tabbing functionality to the cloud mega menu component - #5751 

### Design Spec
https://ibm.ent.box.com/file/774092317795

### Changelog

![Screen Shot 2021-04-21 at 9 58 17 AM](https://user-images.githubusercontent.com/1815714/115566285-1cf4f680-a288-11eb-90ec-d6d9f9dae4a7.png)

**New Components**

- `<dds-cloud-megamenu>` – an extended component of `<dds-megamenu>` that allows us to apply styles to the host component that's cloud design specific.
- `<dds-cloud-top-nav-name>` - – an extended component of `<dds-top-nav-name>` that allows us to apply styles to the host component that's cloud design specific, thus making this top nav name visible on all breakpoints.
-
**Removed**

- N/A

**Notes**
- There's a known issue within the mobile hamburger menu where the regular dropdown menu items are not showing up correctly. @annawen1 has opened a fix PR for this issue and the PR can be reviewed here - #5839

**Testing Instructions**
- Visit the `Cloud Masthead` Storybook variant - `/?path=/story/components-cloud-masthead--default`
- Ensure that the mega menu component matches with the design specs for all breakpoints.

<!-- React and Web Component deploy previews are enabled by default. -->
<!-- To enable additional available deploy previews, apply the following -->
<!-- labels for the corresponding package: -->
<!-- *** "package: services": Services -->
<!-- *** "package: utilities": Utilities -->
<!-- *** "package: styles": Carbon Expressive -->
<!-- *** "RTL": React / Web Components (RTL) -->
<!-- *** "feature flag": React / Web Components (experimental) -->
  • Loading branch information
proeung authored Apr 27, 2021
1 parent 37a8410 commit c0ec381
Show file tree
Hide file tree
Showing 6 changed files with 184 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
.#{$prefix}--header__menu-title[role='menuitem'][aria-expanded='false']
+ .#{$prefix}--header__menu {
::slotted(#{$dds-prefix}-megamenu),
::slotted(#{$dds-prefix}-cloud-megamenu),
.#{$prefix}--masthead__megamenu {
animation: $transition--expansion motion(standard, expressive) collapse;
}
Expand All @@ -78,6 +79,7 @@
width: var(--#{$dds-prefix}-ce--viewport-width, 100vw);

::slotted(#{$dds-prefix}-megamenu),
::slotted(#{$dds-prefix}-cloud-megamenu),
.#{$prefix}--masthead__megamenu {
animation: $transition--expansion motion(standard, expressive) expand;
}
Expand All @@ -99,6 +101,7 @@
}

:host(#{$dds-prefix}-megamenu),
:host(#{$dds-prefix}-cloud-megamenu),
.#{$prefix}--masthead__megamenu {
display: block;
overflow-y: overlay;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import './cloud-button-cta';
import './cloud-left-nav-item';
import './cloud-masthead-global-bar';
import './cloud-masthead-profile';
import './cloud-top-nav-name';
import './cloud-megamenu';
import './cloud-megamenu-tabs';
import './cloud-megamenu-tab';
import './cloud-megamenu-left-navigation';
Expand Down Expand Up @@ -86,7 +88,7 @@ class DDSCloudMastheadComposite extends DDSMastheadComposite {
});

return html`
<dds-megamenu>
<dds-cloud-megamenu>
<dds-cloud-megamenu-left-navigation
view-all-href="${ifNonNull(viewAllLink?.url)}"
view-all-title="${ifNonNull(viewAllLink?.title)}"
Expand Down Expand Up @@ -122,7 +124,7 @@ class DDSCloudMastheadComposite extends DDSMastheadComposite {
`;
})}
</dds-cloud-megamenu-right-navigation>
</dds-megamenu>
</dds-cloud-megamenu>
`;
}

Expand Down Expand Up @@ -190,7 +192,7 @@ class DDSCloudMastheadComposite extends DDSMastheadComposite {
${!platform
? undefined
: html`
<dds-top-nav-name href="${ifNonNull(platformUrl)}">${platform}</dds-top-nav-name>
<dds-cloud-top-nav-name href="${ifNonNull(platformUrl)}">${platform}</dds-cloud-top-nav-name>
`}
${l1Data
? undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,38 @@
}

.bx--btn {
padding: calc(0.875rem - 3px) 15px;
padding: calc(0.875rem - 3px) carbon--rem(15px);
}

.bx--btn--ghost {
color: $text-01;
}
}

:host(#{$dds-prefix}-cloud-top-nav-name) {
outline: none;

a.#{$prefix}--header__name {
@include masthead-top-nav-name;

@include carbon--breakpoint-down(800px) {
display: flex;
}
}
}

// Cloud Megamenu.

:host(#{$dds-prefix}-cloud-megamenu),
.#{$prefix}--masthead__megamenu {
.#{$prefix}--masthead__megamenu__container--row {
// Override flex-direction: column set in _masthead-megamenu.scss.
@include carbon--breakpoint-between(800px, 1055px) {
flex-direction: inherit;
}
}
}

:host(#{$dds-prefix}-cloud-megamenu-left-navigation) {
@include carbon--make-col(4, 16);

Expand All @@ -52,13 +76,15 @@
}

:host(#{$dds-prefix}-cloud-megamenu-right-navigation) {
padding-top: $spacing-06;
margin-bottom: $spacing-07;
}

:host(#{$dds-prefix}-cloud-megamenu-tabs) {
display: flex;
flex-direction: column;
margin-top: rem(18px);
margin-top: carbon--rem(18px);
margin-bottom: carbon--rem(18px);

.#{$prefix}--tabs-trigger {
display: none;
Expand All @@ -73,7 +99,7 @@
width: 100%;
border: none;
text-align: left;
padding: 6px $spacing-05;
padding: carbon--rem(6px) $spacing-05;
background-color: $ui-background;
cursor: pointer;

Expand All @@ -83,7 +109,7 @@
}

&:focus {
outline: 1px solid $focus;
outline: carbon--rem(2px) solid $focus;
}
}

Expand All @@ -93,27 +119,89 @@

:host(#{$dds-prefix}-cloud-megamenu-category-link-group) {
display: block;
column-count: 3;
column-count: 2;
column-gap: 0;
column-fill: auto;

@include carbon--breakpoint('xlg') {
column-count: 3;
}
}

:host(#{$dds-prefix}-cloud-megamenu-category-link) a {
display: inline-block;
padding: $spacing-04 $spacing-05;
p {
@include carbon--type-style('expressive-heading-01');
:host(#{$dds-prefix}-cloud-megamenu-category-link) {
display: block;
page-break-inside: avoid;
break-inside: avoid;

a {
display: block;
padding: $spacing-04 $spacing-05;

color: $text-01;
p {
@include carbon--type-style('expressive-heading-01');

color: $text-01;
}

span {
@include carbon--type-style('body-long-01');

color: $text-02;
display: block;
width: 90%;
}

&:hover {
text-decoration: none;
background-color: $hover-ui;
}

&:focus {
outline: carbon--rem(2px) solid $focus;
outline-offset: carbon--rem(-2px);
}
}
span {
@include carbon--type-style('body-long-01');
}

color: $text-02;
:host(#{$dds-prefix}-cloud-megamenu-category-heading) {
display: block;
padding: 0 $spacing-05;
margin-bottom: $spacing-07;
width: 66.66%;

@include carbon--breakpoint('lg') {
width: 50%;
}

&:hover {
text-decoration: none;
background-color: $hover-ui;
h2 {
display: flex;
margin-bottom: $spacing-03;

a {
color: $text-01;
text-decoration: none;
align-self: center;

svg {
margin: 0 $spacing-03;
padding-top: $spacing-02;
fill: $link-01;
}

&:hover {
text-decoration: underline;

svg {
fill: $hover-primary-text;
}
}
}
}

span {
@include carbon--type-style('body-short-01');

color: $text-02;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class DDSCloudMegaMenuCategoryHeading extends LitElement {

render() {
return html`
<h2><a href="${this.href}">${this.title}</a> ${ArrowRight32()}</h2>
<h2><a href="${this.href}">${this.title} ${ArrowRight32()}</a></h2>
<span><slot></slot></span>
`;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* @license
*
* Copyright IBM Corp. 2020, 2021
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

import { html, customElement } from 'lit-element';
import settings from 'carbon-components/es/globals/js/settings';
import ddsSettings from '@carbon/ibmdotcom-utilities/es/utilities/settings/settings.js';
import DDSMegaMenu from '../megamenu';
import styles from './cloud-masthead.scss';

const { prefix } = settings;
const { stablePrefix: ddsPrefix } = ddsSettings;

/**
* Cloud MegaMenu.
*
* @element dds-cloud-megamenu
*/
@customElement(`${ddsPrefix}-cloud-megamenu`)
class DDSCloudMegaMenu extends DDSMegaMenu {
render() {
return html`
<div class="${prefix}--masthead__megamenu__container">
<div class="${prefix}--masthead__megamenu__container--row">
<slot></slot>
</div>
</div>
`;
}

static get stableSelector() {
return `${ddsPrefix}--masthead__megamenu`;
}

static styles = styles; // `styles` here is a `CSSResult` generated by custom WebPack loader
}

export default DDSCloudMegaMenu;
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @license
*
* Copyright IBM Corp. 2021
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

import { customElement } from 'lit-element';
import ddsSettings from '@carbon/ibmdotcom-utilities/es/utilities/settings/settings.js';
import DDSTopNavName from '../top-nav-name';
import styles from './cloud-masthead.scss';

const { stablePrefix: ddsPrefix } = ddsSettings;

/**
* Cloud's brand name UI in top nav.
*
* @element dds-cloud-top-nav-name
*/
@customElement(`${ddsPrefix}-cloud-top-nav-name`)
class DDSCloudTopNavName extends DDSTopNavName {
static styles = styles;
}

export default DDSCloudTopNavName;

0 comments on commit c0ec381

Please sign in to comment.