Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(megamenu): megamenu desktop web component #4384

Merged
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7824c59
feat(megamenu): initial megamenu web component
Nov 2, 2020
7879e88
feat(megamenu): adjust mastheadmenuitem iterface values
Nov 2, 2020
7669636
Merge branch 'master' into feat/megamenu-web-component
Nov 2, 2020
14c64cc
feat(megamenu): styles for megamenu
Nov 2, 2020
1cd7d43
feat(megamenu): header menu styles for megamenu
Nov 3, 2020
9c88970
Merge branch 'master' into feat/megamenu-web-component
Nov 3, 2020
619746d
chore(snapshot): update snapshot
Nov 3, 2020
9ccef0d
feat(megamenu): remove unneccessary stableselector mixin and classnames
Nov 3, 2020
2a7db32
feat(megamenu): create separate megamenu-top-nav-menu component
Nov 3, 2020
4e51d32
Merge branch 'master' into feat/megamenu-web-component
Nov 4, 2020
ec58b06
feat(megamenu): various adjustments to megamenu components
Nov 4, 2020
692d050
feat(megamenu): add overlay on megamenu open
Nov 4, 2020
5e7d13b
feat(megamenu): working collapse animation
Nov 5, 2020
895ef38
feat(megamenu): fixing autoids for category links
Nov 5, 2020
1a942d6
chore(merge): resolve merge conflict
Nov 5, 2020
76d6799
Merge branch 'master' into feat/megamenu-web-component
Nov 5, 2020
c982b7d
fix(megamenu): remove stale style file path
Nov 5, 2020
96b39f4
fix(megamenu): remove unused titleEnglish field from interface
Nov 5, 2020
581eceb
feat(megamenu): remove tabindex -1 to make megamenu tabbable
Nov 5, 2020
efecebf
Merge branch 'master' into feat/megamenu-web-component
annawen1 Nov 5, 2020
f65a582
Merge branch 'feat/megamenu-web-component' of https://github.com/anna…
Nov 5, 2020
3955af1
chore(snapshots): update snapshots
Nov 5, 2020
c4355d2
fix(megamenu): remove overflow styles on animation to fix shifting
Nov 5, 2020
d23e56d
feat(megamenu): disable body scroll when menu is expanded
Nov 5, 2020
28416b1
fix(megamenu): remove unnecessary outline for megamenu links
Nov 5, 2020
3530a42
Merge branch 'master' into feat/megamenu-web-component
annawen1 Nov 5, 2020
26b2ce3
feat(megamenu): unit-tests for megamenu
Nov 6, 2020
df61a9b
Merge branch 'feat/megamenu-web-component' of https://github.com/anna…
Nov 6, 2020
195f1f6
chore(merge): resolve merge conflicts
Nov 6, 2020
d0246a0
feat(megamenu): readme documentation
Nov 6, 2020
7556a0d
chore(unit-test): update unit tests for megamenu and update snapshot
Nov 6, 2020
c3012de
chore(snapshots): update snapshots
Nov 6, 2020
f45b22d
Merge branch 'master' into feat/megamenu-web-component
annawen1 Nov 9, 2020
27d6da0
Merge branch 'master' into feat/megamenu-web-component
kodiakhq[bot] Nov 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 12 additions & 24 deletions packages/react/src/__tests__/__snapshots__/storyshots.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -52428,13 +52428,10 @@ exports[`Storyshots Components|Dotcom Shell With L1 1`] = `
key=".$Lorem ipsum dolor sit amet"
role="none"
>
<NavigationGroup
hasHighlights={false}
>
<NavigationGroup>
<section
className="bx--masthead__megamenu"
data-autoid="dds--masthead__megamenu"
tabIndex={-1}
>
<div
className="bx--masthead__megamenu__container"
Expand All @@ -52444,6 +52441,7 @@ exports[`Storyshots Components|Dotcom Shell With L1 1`] = `
>
<RightNavigation
autoid="dds--masthead-alt__l1-nav0"
hasHighlights={false}
>
<div
className="bx--masthead__megamenu__categories-section"
Expand Down Expand Up @@ -52720,13 +52718,10 @@ exports[`Storyshots Components|Dotcom Shell With L1 1`] = `
key=".$Consectetur adipiscing elit"
role="none"
>
<NavigationGroup
hasHighlights={false}
>
<NavigationGroup>
<section
className="bx--masthead__megamenu"
data-autoid="dds--masthead__megamenu"
tabIndex={-1}
>
<div
className="bx--masthead__megamenu__container"
Expand All @@ -52736,6 +52731,7 @@ exports[`Storyshots Components|Dotcom Shell With L1 1`] = `
>
<RightNavigation
autoid="dds--masthead-alt__l1-nav1"
hasHighlights={false}
>
<div
className="bx--masthead__megamenu__categories-section"
Expand Down Expand Up @@ -53245,13 +53241,10 @@ exports[`Storyshots Components|Dotcom Shell With L1 1`] = `
key=".$Fusce nec tellus sed augue semper porta"
role="none"
>
<NavigationGroup
hasHighlights={false}
>
<NavigationGroup>
<section
className="bx--masthead__megamenu"
data-autoid="dds--masthead__megamenu"
tabIndex={-1}
>
<div
className="bx--masthead__megamenu__container"
Expand All @@ -53261,6 +53254,7 @@ exports[`Storyshots Components|Dotcom Shell With L1 1`] = `
>
<RightNavigation
autoid="dds--masthead-alt__l1-nav3"
hasHighlights={false}
>
<div
className="bx--masthead__megamenu__categories-section"
Expand Down Expand Up @@ -105571,13 +105565,10 @@ exports[`Storyshots Components|Masthead With L 1 1`] = `
key=".$Lorem ipsum dolor sit amet"
role="none"
>
<NavigationGroup
hasHighlights={false}
>
<NavigationGroup>
<section
className="bx--masthead__megamenu"
data-autoid="dds--masthead__megamenu"
tabIndex={-1}
>
<div
className="bx--masthead__megamenu__container"
Expand All @@ -105587,6 +105578,7 @@ exports[`Storyshots Components|Masthead With L 1 1`] = `
>
<RightNavigation
autoid="dds--masthead-alt__l1-nav0"
hasHighlights={false}
>
<div
className="bx--masthead__megamenu__categories-section"
Expand Down Expand Up @@ -105863,13 +105855,10 @@ exports[`Storyshots Components|Masthead With L 1 1`] = `
key=".$Consectetur adipiscing elit"
role="none"
>
<NavigationGroup
hasHighlights={false}
>
<NavigationGroup>
<section
className="bx--masthead__megamenu"
data-autoid="dds--masthead__megamenu"
tabIndex={-1}
>
<div
className="bx--masthead__megamenu__container"
Expand All @@ -105879,6 +105868,7 @@ exports[`Storyshots Components|Masthead With L 1 1`] = `
>
<RightNavigation
autoid="dds--masthead-alt__l1-nav1"
hasHighlights={false}
>
<div
className="bx--masthead__megamenu__categories-section"
Expand Down Expand Up @@ -106388,13 +106378,10 @@ exports[`Storyshots Components|Masthead With L 1 1`] = `
key=".$Fusce nec tellus sed augue semper porta"
role="none"
>
<NavigationGroup
hasHighlights={false}
>
<NavigationGroup>
<section
className="bx--masthead__megamenu"
data-autoid="dds--masthead__megamenu"
tabIndex={-1}
>
<div
className="bx--masthead__megamenu__container"
Expand All @@ -106404,6 +106391,7 @@ exports[`Storyshots Components|Masthead With L 1 1`] = `
>
<RightNavigation
autoid="dds--masthead-alt__l1-nav3"
hasHighlights={false}
>
<div
className="bx--masthead__megamenu__categories-section"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const MegaMenu = ({ data, ...rest }) => {
const hasHighlights = highlightedItems.length !== 0;

return (
<NavigationGroup hasHighlights={hasHighlights}>
<NavigationGroup>
{hasHighlights && (
<LeftNavigation>
{highlightedItems.map((item, i) => (
Expand All @@ -53,6 +53,7 @@ const MegaMenu = ({ data, ...rest }) => {
</LeftNavigation>
)}
<RightNavigation
hasHighlights={hasHighlights}
viewAllLinkHref={viewAllLink?.url}
viewAllLinkTitle={viewAllLink?.title}
autoid={rest.autoid}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* 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 classnames from 'classnames';
import ddsSettings from '@carbon/ibmdotcom-utilities/es/utilities/settings/settings';
import PropTypes from 'prop-types';
import React from 'react';
Expand All @@ -16,12 +15,9 @@ const { prefix } = settings;
/**
* MegaMenu panel
*/
const NavigationGroup = ({ hasHighlights, children, ...rest }) => (
const NavigationGroup = ({ children, ...rest }) => (
<section
tabIndex={-1}
className={classnames(`${prefix}--masthead__megamenu`, {
[`${prefix}--masthead__megamenu__container--hasHighlights`]: hasHighlights,
})}
className={`${prefix}--masthead__megamenu`}
data-autoid={`${stablePrefix}--masthead__megamenu`}
{...rest}>
<div className={`${prefix}--masthead__megamenu__container`}>
Expand All @@ -33,11 +29,6 @@ const NavigationGroup = ({ hasHighlights, children, ...rest }) => (
);

NavigationGroup.propTypes = {
/**
* Determines whether to render the Highlight Section (Left Navigation)
*/
hasHighlights: PropTypes.bool,

/**
* children elements
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import ArrowRight16 from '@carbon/icons-react/es/arrow--right/16';
import classnames from 'classnames';
import LinkWithIcon from '../../LinkWithIcon/LinkWithIcon';
import PropTypes from 'prop-types';
import React from 'react';
Expand All @@ -19,10 +20,14 @@ const RightNavigation = ({
children,
viewAllLinkHref,
viewAllLinkTitle,
hasHighlights,
...rest
}) => (
<div className={`${prefix}--masthead__megamenu__categories-section`}>
<div className={`${prefix}--masthead__megamenu__categories`}>
<div
className={classnames(`${prefix}--masthead__megamenu__categories`, {
[`${prefix}--masthead__megamenu--hasHighlights`]: hasHighlights,
})}>
{children}
</div>
{viewAllLinkHref && (
Expand All @@ -43,6 +48,11 @@ RightNavigation.propTypes = {
*/
children: PropTypes.node.isRequired,

/**
* Determines whether to render the Highlight Section (Left Navigation)
*/
hasHighlights: PropTypes.bool,

/**
* Megamenu view all cta url
*/
Expand Down
2 changes: 2 additions & 0 deletions packages/services-store/src/types/translateAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export interface MegapanelContent {
export interface MastheadMenuItem {
title: string;
url?: string;
highlighted?: boolean;
megaPanelViewAll?: boolean;
megapanelContent?: MegapanelContent;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Copyright IBM Corp. 2016, 2020
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* This locks the scroll on the body element when the megamenu is expanded.
* When using the megamenu web component, adopters will need to load this file in their application for
* the scroll locking to work.
*/
.#{$prefix}--body__lock-scroll {
position: relative;
overflow: hidden;
}
Loading