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: 791-header-shell-links-removing-left-nav #848

Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
8d797b2
fix: issue 808 - removed button in ImageGallereyImage
Apr 9, 2020
e1e39eb
Revert "fix: issue 808 - removed button in ImageGallereyImage"
Apr 9, 2020
0bbbdeb
wip: mapping through nav bar
May 7, 2020
422c267
wip: progress on the header
May 8, 2020
04cf8a0
wip: header has some styling
May 8, 2020
5109b0c
wip: stuff is working yay
May 8, 2020
59de0b6
wip: header & side nav working
May 13, 2020
f760c3a
wip: header nav and left nav working in desktop & mobile--cleaned up …
May 15, 2020
66ed18f
feature: 791-header-shell-links-removing-left-nav [WIP]
May 20, 2020
69b5b68
updated title
andreancardona May 20, 2020
3d8811c
updated nav title
andreancardona May 20, 2020
be952a3
quotes changes
May 20, 2020
cf6d8b8
feature: 791-header-shell-links-removing-left-nav
May 29, 2020
2d661e5
Merge branch 'master' into 791-header-shell-links-removing-left-nav
andreancardona May 29, 2020
99bdbca
things working just need to update config option & documentation
May 29, 2020
370fa63
things working just need to update config option & documentation - maybe
May 29, 2020
dc5e76e
fixed merge conflict
May 29, 2020
a693124
feature: 791-header-shell-links-removing-left-nav - updated docs and …
May 29, 2020
473fc5f
Merge branch 'master' into 791-header-shell-links-removing-left-nav
andreancardona Jun 2, 2020
00cb9c1
Merge branch 'master' into 791-header-shell-links-removing-left-nav
andreancardona Jun 2, 2020
ed01d21
feature: 791-header-shell-links-removing-left-nav - updated variable …
Jun 2, 2020
e1b7c4a
Update packages/example/src/pages/guides/configuration.mdx
andreancardona Jun 2, 2020
888f698
feat: 791-header-shell-links-removing-left-nav - content left aligned…
Jun 3, 2020
dbbda91
Merge branch 'master' into 791-header-shell-links-removing-left-nav
andreancardona Jun 3, 2020
dc3f2b8
remove headerNav prop
Jun 4, 2020
ce037db
Merge branch '791-header-shell-links-removing-left-nav' of github.com…
Jun 4, 2020
f782c04
Update packages/gatsby-theme-carbon/src/components/HeaderNav/HeaderNa…
andreancardona Jun 8, 2020
ca7c497
updated module - style accidentally deleted
andreancardona Jun 8, 2020
a1c7140
feat: 791-header-shell-links-removing-left-nav - updated query
Jun 10, 2020
4d43056
Merge branch '791-header-shell-links-removing-left-nav' of github.com…
Jun 10, 2020
288ac8e
bug fixed
andreancardona Jun 11, 2020
093acef
feat: 791-header-shell-links-removing-left-nav
Jun 11, 2020
475b2de
feat: 791-header-shell-links-removing-left-nav - updated config docum…
Jun 11, 2020
6e7452b
Merge branch 'master' into 791-header-shell-links-removing-left-nav
andreancardona Jun 11, 2020
9e1eeea
Merge branch 'master' into 791-header-shell-links-removing-left-nav
andreancardona Jun 12, 2020
23bde16
Update packages/gatsby-theme-carbon/src/components/LeftNav/LeftNavWra…
vpicone Jun 15, 2020
2054645
pt1. updated back to default
andreancardona Jun 16, 2020
ba9b665
pt2. updated back to default
andreancardona Jun 16, 2020
29154a4
updated config option
andreancardona Jun 16, 2020
0bb20d8
updated config options
andreancardona Jun 16, 2020
94aa3c8
update
andreancardona Jun 16, 2020
f40b3d6
update for now
andreancardona Jun 16, 2020
60399f6
last and final: 791-header-shell-links-removing-left-nav
Jun 16, 2020
fd96017
Merge branch 'master' into 791-header-shell-links-removing-left-nav
andreancardona Jun 16, 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
4 changes: 3 additions & 1 deletion packages/gatsby-theme-carbon/src/components/Header/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
import { AppSwitcher20, Close20 } from '@carbon/icons-react';
import cx from 'classnames';

import HeaderNav from '../HeaderNav/HeaderNav';
import GlobalSearch from '../GlobalSearch';
import NavContext from '../../util/context/NavContext';
import useMetadata from '../../util/hooks/useMetadata';
Expand All @@ -24,7 +25,7 @@ import {
switcherButton,
} from './Header.module.scss';

const Header = ({ children }) => {
const Header = ({ children, hasHeaderNavigation }) => {
const {
leftNavIsOpen,
toggleNavState,
Expand Down Expand Up @@ -54,6 +55,7 @@ const Header = ({ children }) => {
>
{children}
</Link>
{hasHeaderNavigation && <HeaderNav />}
<HeaderGlobalBar>
{isSearchEnabled && <GlobalSearch />}
<HeaderGlobalAction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ header.header {
transition: opacity $duration--fast-02 $carbon--standard-easing;
color: $inverse-01;
text-decoration: none;
position: absolute;
andreancardona marked this conversation as resolved.
Show resolved Hide resolved
left: 3rem;
white-space: nowrap;
padding: 0 $spacing-05;
Expand Down
22 changes: 22 additions & 0 deletions packages/gatsby-theme-carbon/src/components/HeaderNav/HeaderNav.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';

import { HeaderNavigation } from 'carbon-components-react/lib/components/UIShell';
import HeaderNavItem from './HeaderNavItem';

import { useNavItems } from '../../util/NavItems';

const HeaderNav = () => {
const navItems = useNavItems();

return (
<>
<HeaderNavigation aria-label="Carbon Design System">
{navItems.map((item, i) => (
<HeaderNavItem items={item.pages} category={item.title} key={i} />
))}
</HeaderNavigation>
</>
andreancardona marked this conversation as resolved.
Show resolved Hide resolved
);
};

export default HeaderNav;
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import React, { useContext } from 'react';

import { Link } from 'gatsby';
import { Location } from '@reach/router';
import cx from 'classnames';

import {
HeaderMenu,
HeaderMenuItem,
} from 'carbon-components-react/lib/components/UIShell';
import styles from '../Header/Header.module.scss';

import NavContext from '../../util/context/NavContext';
import usePathprefix from '../../util/hooks/usePathprefix';

const HeaderNavItem = (props) => {
const { items, category } = props;
const { toggleNavState } = useContext(NavContext);
const closeLeftNav = () => toggleNavState('leftNavIsOpen', 'close');
const pathPrefix = usePathprefix();

return (
<Location>
{({ location }) => {
const pathname = pathPrefix
? location.pathname.replace(pathPrefix, '')
: location.pathname;

const isActive = items.some(
(item) => item.path.split('/')[1] === pathname.split('/')[1]
);

if (items.length === 1) {
return (
<HeaderMenuItem
onClick={closeLeftNav}
icon={<span>dummy icon</span>}
element={Link}
isActive={isActive}
to={`${items[0].path}`}
>
{category}
</HeaderMenuItem>
);
}
return (
<HeaderMenu
icon={<span>dummy icon</span>}
isActive={isActive} // TODO similar categories
defaultExpanded={isActive}
title={category}
menuLinkName={category}
>
<TabItems
onClick={closeLeftNav}
items={items}
pathname={pathname}
/>
</HeaderMenu>
);
}}
</Location>
);
};

const TabItems = ({ items, pathname, onClick }) =>
items.map((item, i) => {
const hasActiveTab =
item.path.split('/') > 3
? item.path.split('/')[3] === pathname.split('/')[3]
: item.path.split('/')[2] === pathname.split('/')[2];

return (
<HeaderMenuItem
to={`${item.path}`}
className={cx({
[styles.linkText__dark]: pathname === '/',
})}
onClick={onClick}
element={Link}
isActive={hasActiveTab}
key={i}
>
<span
className={cx(styles.linkText, {
[styles.linkText__active]: hasActiveTab,
})}
>
{item.title}
</span>
</HeaderMenuItem>
);
});

export default HeaderNavItem;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import HeaderNav from './HeaderNav';

export default HeaderNav;
12 changes: 9 additions & 3 deletions packages/gatsby-theme-carbon/src/components/Layout.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable import/no-unresolved */
import React, { useLayoutEffect } from 'react';

import LeftNav from './LeftNav';
import Meta from './Meta';
import LeftNav from './LeftNav';
import Header from './Header';
import Switcher from './Switcher';
import Footer from './Footer';
Expand All @@ -19,6 +19,7 @@ const Layout = ({
pageDescription,
pageKeywords,
tabs,
hasHeaderNavigation,
}) => {
const is404 = children.key === null;

Expand All @@ -43,9 +44,14 @@ const Layout = ({
pageDescription={pageDescription}
pageKeywords={pageKeywords}
/>
<Header />
<Header hasHeaderNavigation={hasHeaderNavigation} />
<Switcher />
<LeftNav homepage={homepage} is404Page={is404} theme={theme} />
<LeftNav
hasHeaderNavigation={hasHeaderNavigation}
homepage={homepage}
is404Page={is404}
theme={theme}
/>
<Container homepage={homepage} theme={theme}>
{children}
<Footer />
Expand Down
12 changes: 8 additions & 4 deletions packages/gatsby-theme-carbon/src/components/LeftNav/LeftNav.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useContext } from 'react';
import classnames from 'classnames';
import { SideNav, SideNavItems } from 'carbon-components-react';
import { useNavItems } from './LeftNavItemProvider';
import { useNavItems } from '../../util/NavItems';

import NavContext from '../../util/context/NavContext';
import LeftNavItem from './LeftNavItem';
Expand All @@ -17,10 +17,14 @@ const LeftNav = (props) => {

// TODO: replace old addon website styles with sass modules, move to wrapper
return (
<LeftNavWrapper expanded={leftNavIsOpen}>
<LeftNavWrapper
expanded={leftNavIsOpen}
hasHeaderNavigation={props.hasHeaderNavigation}
>
<SideNav
expanded
defaultExpanded
expanded={props.hasHeaderNavigation ? leftNavIsOpen : true}
defaultExpanded={!props.hasHeaderNavigation}
isPersistent={!props.hasHeaderNavigation}
aria-label="Side navigation"
className={classnames({
[sideNavDark]: props.theme === 'dark' || props.homepage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import cx from 'classnames';

import {
leftNavWrapper,
hasHeaderNavStyles,
expanded as expandedStyles,
} from './LeftNavWrapper.module.scss';

const LeftNavWrapper = ({ expanded, ...rest }) => {
const LeftNavWrapper = ({ hasHeaderNavigation, expanded, ...rest }) => {
const className = cx(leftNavWrapper, {
andreancardona marked this conversation as resolved.
Show resolved Hide resolved
[hasHeaderNavStyles]: hasHeaderNavigation,
[expandedStyles]: expanded,
});
return <div className={className} {...rest} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,25 @@
}

@include carbon--breakpoint('lg') {
transform: translateX(0px);
transform: translateX(
andreancardona marked this conversation as resolved.
Show resolved Hide resolved
0px
); // when this is in desktop view and doesn't have header navigation
}
}

.leftNavWrapper.hasHeaderNavStyles {
@include carbon--breakpoint('lg') {
transform: translateX(
-256px
); //when this has header navigation in desktop view
}
}

.hasHeaderNavStyles.expanded {
@include carbon--breakpoint('lg') {
transform: translateX(
-256px
); // when this has header navigation and expanded in desktop view
}
}

Expand All @@ -23,7 +41,10 @@
}

.expanded {
transform: translateX(0px);
transform: translateX(
0px
); //when this is in mobile view and expanded (for both header and non header)

box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
@include carbon--breakpoint('lg') {
box-shadow: none;
Expand Down
3 changes: 3 additions & 0 deletions packages/gatsby-theme-carbon/src/templates/Default.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ const Default = ({ pageContext, children, location, Title }) => {
};

const currentTab = getCurrentTab();

// Update hasHeaderNavigation prop in the Layout component to true to render HeaderNav.
return (
<Layout
tabs={tabs}
Expand All @@ -48,6 +50,7 @@ const Default = ({ pageContext, children, location, Title }) => {
pageDescription={description}
pageKeywords={keywords}
titleType={titleType}
hasHeaderNavigation={false}
>
<PageHeader title={Title ? <Title /> : title} label="label" tabs={tabs} />
{tabs && <PageTabs slug={slug} tabs={tabs} currentTab={currentTab} />}
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby-theme-carbon/src/templates/Homepage.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const Homepage = ({
titleType={titleType}
homepage
theme="dark"
hasHeaderNavigation
>
{Banner}
{FirstCallout}
Expand Down