Skip to content

Commit

Permalink
Update Nav design (#2514)
Browse files Browse the repository at this point in the history
  • Loading branch information
julieg18 authored Jun 7, 2021
1 parent c9ac62a commit f032de7
Show file tree
Hide file tree
Showing 24 changed files with 849 additions and 323 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
);
z-index: 10;
position: sticky;
top: var(--layout-header-height-collapsed);
top: var(--layout-header-height);

@media (--xs-scr) {
position: relative;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.menu {
position: sticky;
top: calc(var(--layout-header-height-collapsed) + 60px);
height: calc(100vh - var(--layout-header-height-collapsed) - 60px);
top: calc(var(--layout-header-height) + 60px);
height: calc(100vh - var(--layout-header-height) - 60px);
overflow-y: hidden;
-webkit-overflow-scrolling: touch;

Expand Down
2 changes: 1 addition & 1 deletion src/components/Documentation/RightPanel/styles.module.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.container {
position: sticky;
top: var(--layout-header-height-collapsed);
top: var(--layout-header-height);
flex-shrink: 0;
box-sizing: border-box;
width: 170px;
Expand Down
1 change: 0 additions & 1 deletion src/components/HamburgerIcon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const HamburgerIcon: React.FC<IHamburgerProps> = ({ opened }) => (
<div className={cn(styles.wrapper, opened && styles.opened)}>
<div className={cn(styles.line, styles.first)} />
<div className={cn(styles.line, styles.second)} />
<div className={cn(styles.line, styles.third)} />
</div>
)

Expand Down
24 changes: 14 additions & 10 deletions src/components/HamburgerIcon/styles.module.css
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
.wrapper {
display: inline-block;
cursor: pointer;

&.opened {
transform: translateX(-4px);
}
}

.line {
width: 30px;
height: 3px;
background-color: #173042;
width: 22px;
height: 4px;
background-color: #2e3137;
border-radius: 10px;
margin: 5px 0;
transition: 0.4s;

.opened & {
background-color: #fff;
background-color: var(--color-gray-light);
border-radius: 20px;
width: 27px;
height: 3px;

&.first {
transform: rotate(-45deg) translate(-7px, 6px);
transform: rotate(-45deg) translateY(6px);
}

&.second {
opacity: 0;
}

&.third {
transform: rotate(45deg) translate(-5px, -5px);
transform: rotate(45deg) translateY(-6px);
}
}
}
53 changes: 27 additions & 26 deletions src/components/HamburgerMenu/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import cn from 'classnames'
import React, {
useEffect,
useState,
useCallback,
MouseEvent,
KeyboardEvent
} from 'react'
import React, { useEffect, useState, useCallback, MouseEvent } from 'react'

import HamburgerIcon from '../HamburgerIcon'
import Link from '../Link'
Expand All @@ -24,26 +18,23 @@ export type HamburgerHelpers = {
opened: boolean
setOpened: (newState: boolean) => void
handleToggle: () => void
handleKeyDown: (e: KeyboardEvent) => void
handleClose: () => void
handleItemClick: (name: string) => (e: MouseEvent) => void
handleItemClick: (name?: string) => (e: MouseEvent) => void
}

export const useHamburgerMenu: () => HamburgerHelpers = () => {
const [opened, setOpened] = useState(false)

const handleToggle = useCallback(() => setOpened(!opened), [opened])
const handleKeyDown = useCallback(e => {
if (e.which === 13) {
handleToggle()
}
}, [])

const handleClose = useCallback(() => setOpened(false), [opened])

const handleItemClick = useCallback(
item => (): void => {
close()
logEvent('hamburger', item)
handleClose()
if (item) {
logEvent('hamburger', item)
}
},
[]
)
Expand All @@ -57,26 +48,34 @@ export const useHamburgerMenu: () => HamburgerHelpers = () => {
opened,
setOpened,
handleToggle,
handleKeyDown,
handleClose,
handleItemClick
}
}

export const HamburgerMenu: React.FC<
Pick<
HamburgerHelpers,
'opened' | 'handleItemClick' | 'handleKeyDown' | 'handleToggle'
> & {
Pick<HamburgerHelpers, 'opened' | 'handleItemClick' | 'handleToggle'> & {
collapsed: boolean
}
> = ({ opened, handleItemClick }) => {
return (
<div className={cn(styles.wrapper, opened && styles.opened)}>
<div className={styles.logoRow}>
<Link href="/" className={styles.logo} aria-label="Home">
<Link
onClick={handleItemClick()}
href="/"
className={styles.logo}
aria-label="Home"
>
<LogoSVG />
</Link>
<Link
className={styles.company}
href="https://iterative.ai/"
target="_blank"
>
by <span className={styles.companyName}>iterative.ai</span>
</Link>
</div>
<ul className={styles.sections}>
<li className={styles.section}>
Expand Down Expand Up @@ -252,12 +251,14 @@ export const HamburgerButton: React.FC<{
opened: boolean
collapsed: boolean
handleClick: (e: MouseEvent) => void
handleKeyDown: (e: KeyboardEvent) => void
}> = ({ opened, collapsed, handleClick, handleKeyDown }) => (
}> = ({ opened, collapsed, handleClick }) => (
<button
className={cn(styles.toggleButton, collapsed || styles.expanded)}
className={cn(
styles.toggleButton,
collapsed || styles.expanded,
opened && styles.opened
)}
onClick={handleClick}
onKeyDown={handleKeyDown}
aria-label="Toggle Mobile Menu"
>
<HamburgerIcon opened={opened} />
Expand Down
115 changes: 97 additions & 18 deletions src/components/HamburgerMenu/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
}

.wrapper {
display: block;
display: none;
visibility: hidden;
padding: 25px 15px 15px;
padding: 12px 16px;
position: fixed;
z-index: 11;
transform: translateX(100%);
transition: transform 0.4s ease;
transition: transform 0.4s ease, visibility 0.4s;
will-change: transform;
left: 0;
right: 0;
Expand All @@ -20,40 +20,107 @@
overflow-y: auto;

@media (--xs-scr) {
visibility: visible;
display: block;
}

&.opened {
visibility: visible;
transform: translateX(0);

a:focus {
outline-color: #fff;
}
}
}

.toggleButton {
@mixin hover;

position: fixed;
display: none;
visibility: hidden;
z-index: 999;
right: 15px;
top: 25px;
right: 16px;
top: 12px;
padding: 0;
border: none;
width: 40px;
height: 40px;
align-items: center;
justify-content: center;
background: transparent;
transition: 0.5s all;
outline: none;
transition: 0.5s all, opacity 0.2s, outline-offset 0s, outline-width 0s,
outline-color 0s;

&:hover {
cursor: pointer;
}

&.opened {
outline-color: #fff;
}

&.expanded {
top: 60px;
top: 47px;
}

@media (--xs-scr) {
display: block;
display: flex;
visibility: visible;
}
}

.logoRow {
display: flex;
}

.logo {
display: block;
width: 34px;
margin-top: 5px;
@mixin hover;
@mixin active;

width: 40px;
height: 40px;
display: flex;
align-items: center;
justify-content: center;

&:focus path {
fill: var(--color-orange);
}
}

.company {
@mixin active;
@mixin hover;

font-size: 15px;
line-height: 20px;
font-weight: 500;
text-decoration: none;
white-space: nowrap;
background: linear-gradient(
270deg,
var(--color-purple) 0%,
var(--color-orange-bright) 100%
);
background-size: 100%;
background-clip: text;
-webkit-background-clip: text;
-moz-background-clip: text;
-webkit-text-fill-color: transparent;
-moz-text-fill-color: transparent;
margin-right: auto;
padding: 10px 0;
margin-left: 12px;

&:focus {
opacity: 0.7;
}

.companyName {
font-weight: 800;
}
}

.sections,
Expand All @@ -68,6 +135,10 @@
}

.sectionLink {
@mixin hover;
@mixin active;
@mixin focus;

display: block;
padding: 15px 0;
font-family: var(--font-brandon);
Expand All @@ -77,10 +148,6 @@
text-transform: uppercase;
text-decoration: none;
color: #fff;

&:hover {
opacity: 0.7;
}
}

.subSections {
Expand All @@ -97,13 +164,16 @@
}

.subSectionLink {
@mixin hover;
@mixin active;

display: flex;
flex-direction: column;
align-items: center;
cursor: pointer;
text-decoration: none;

&:hover {
&:focus {
opacity: 0.7;
}
}
Expand All @@ -124,6 +194,8 @@
}

.linkButton {
@mixin active;

display: block;
margin-top: 15px;
height: 38px;
Expand All @@ -135,8 +207,15 @@
text-align: center;
text-decoration: none;
color: #24292e;
transition: background-color 0.2s ease-in, opacity 0.2s ease-in;

&:hover {
opacity: 0.7;
cursor: pointer;
background-color: rgba(255, 255, 255, 0.7);
}

&:focus {
background-color: var(--color-orange);
color: #fff;
}
}
4 changes: 4 additions & 0 deletions src/components/LayoutFooter/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
background-color: #40364d;
}

.div {
background-image: url(../../../static/img/cml-icon.svg);
}

.container {
margin: 0 auto;
padding: 24px 32px;
Expand Down
Loading

0 comments on commit f032de7

Please sign in to comment.