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

docs: Hide nav and add hamburger to collapse side nav #2386

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
4b1084f
initial integration
scotttjob Jan 29, 2025
79d4323
merged with master
scotttjob Feb 5, 2025
04d144f
Merge branch 'master' into scott_t/triton-integration-test
scotttjob Feb 6, 2025
05d0f51
Merge branch 'master' of github.com:GetJobber/atlantis into JOB-11016…
edison-cy-yang Feb 10, 2025
bb6e64f
docs: Create top nav (#2364)
edison-cy-yang Feb 12, 2025
9aa917e
hide NavMenu below 768
edison-cy-yang Feb 13, 2025
441b241
menu button and jobber logo in top nav below 768
edison-cy-yang Feb 13, 2025
0f7dfb4
style layout and search button in small viewport
edison-cy-yang Feb 14, 2025
522f943
shrink search and triton button in small viewport
edison-cy-yang Feb 14, 2025
a585150
simple left drawer for responsive nav menu
edison-cy-yang Feb 18, 2025
6a0e476
move mobile menu open state into atlantis site context
edison-cy-yang Feb 18, 2025
7261c51
Layout host separate mobile and desktop nav menu
edison-cy-yang Feb 18, 2025
495acc4
keep responsive menu display inside single NavMenu component
edison-cy-yang Feb 18, 2025
981c75c
close mobile nav menu on navigate
edison-cy-yang Feb 19, 2025
c7c80c4
one scrollbar
edison-cy-yang Feb 19, 2025
374569f
close menu for section header click
edison-cy-yang Feb 19, 2025
05c1cfa
jobber logo in drawer header in mobile viewport:
edison-cy-yang Feb 20, 2025
c6967bd
fixed view in storybook link not showing up in mobile viewport
edison-cy-yang Feb 20, 2025
f4f7154
cleanup
edison-cy-yang Feb 20, 2025
ee51867
consolidate mobile menu state handler by removing closeMobileMenu
edison-cy-yang Feb 20, 2025
5478750
only toggleMobileMenu when viewport is medium and up
edison-cy-yang Feb 20, 2025
04a366a
docs: Add Triton to SideDrawer (#2380)
taylorvnoj Feb 21, 2025
1a70642
Merge branch 'master' of github.com:GetJobber/atlantis into JOB-11016…
edison-cy-yang Feb 21, 2025
a3e3a2d
Merge branch 'JOB-110161-integrate-triton-to-next-gen-docs' of github…
edison-cy-yang Feb 21, 2025
7c30129
remove overlay as the drawer covers the whole viewport
edison-cy-yang Feb 21, 2025
5f55171
one more overlay css
edison-cy-yang Feb 21, 2025
8de864c
padding adjustment
edison-cy-yang Feb 21, 2025
35a66da
remove onClick for Jobber logo that only appears in desktop mode
edison-cy-yang Feb 21, 2025
46c003d
mobileNavContainer class is not needed as the visibility of mobile me…
edison-cy-yang Feb 21, 2025
451e98b
get rid of open prop in LeftDrawer
edison-cy-yang Feb 22, 2025
0473d6f
dont attach toggleMobileMenu if mobile viewport
edison-cy-yang Feb 22, 2025
54b339b
use mediumAndUp to display mobile menu button and logo
edison-cy-yang Feb 22, 2025
7c97aa2
Merge branch 'master' of github.com:GetJobber/atlantis into JOB-11016…
edison-cy-yang Feb 24, 2025
4f2d6c3
Merge branch 'JOB-110161-integrate-triton-to-next-gen-docs' of github…
edison-cy-yang Feb 24, 2025
8d65d07
Merge branch 'master' of github.com:GetJobber/atlantis into JOB-11521…
edison-cy-yang Feb 24, 2025
cbd9b25
simple slide out animation for LeftDrawer
edison-cy-yang Feb 24, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ tokens.

## Design & usage guidelines

Both the web and mobile components have the exact same API, except for one
minor difference in how you update the theme.
Both the web and mobile components have the exact same API, except for one minor
difference in how you update the theme.

Each platform provides a `useAtlantisTheme` hook that you may use to access the
`theme` and `tokens` in your components.
Expand Down Expand Up @@ -80,7 +80,10 @@ function ThemedComponent() {
### Usage for mobile

```tsx
import { AtlantisThemeContextProvider, useAtlantisTheme } from "@jobber/components/AtlantisThemeContext";
import {
AtlantisThemeContextProvider,
useAtlantisTheme,
} from "@jobber/components/AtlantisThemeContext";

function App() {
return (
Expand Down
5 changes: 4 additions & 1 deletion packages/site/src/layout/AnimatedPresenceDisclosure.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { AnimatedPresence, Button, Typography } from "@jobber/components";
import React, { useEffect, useMemo, useState } from "react";
import { Link, useLocation } from "react-router-dom";
import styles from "./NavMenu.module.css";
import { useAtlantisSite } from "../providers/AtlantisSiteProvider";

interface AnimatedPresenceDisclosureProps {
readonly children: React.ReactNode;
Expand All @@ -23,6 +24,8 @@ function AnimatedPresenceDisclosure({
[children],
);

const { toggleMobileMenu } = useAtlantisSite();

// Determine if any child is selected based on the current URL
const hasSelectedChild = childrenArray.some(
child => React.isValidElement(child) && pathname === child.props.to,
Expand Down Expand Up @@ -63,7 +66,7 @@ function AnimatedPresenceDisclosure({
isTitleSelected ? styles.selected : ""
} stickySectionHeader`}
>
<Link to={to ?? "/"} tabIndex={0}>
<Link to={to ?? "/"} tabIndex={0} onClick={toggleMobileMenu}>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these onClick handlers on Link are responsible for closing mobile menu when a route is clicked on

<Typography fontWeight="semiBold" size={"large"} textColor="heading">
{title}
</Typography>
Expand Down
49 changes: 49 additions & 0 deletions packages/site/src/layout/LeftDrawer.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
.drawer {
position: fixed;
top: 0;
left: 0;
height: 100%;
width: 100%;
background: var(--color-surface--background);
z-index: var(--elevation-modal);
display: flex;
flex-direction: column;
animation: slideIn 200ms ease-out;
}

@media screen and (min-width: 768px) {
.drawer {
display: none;
}
}

.drawerClosing {
animation: slideOut 200ms ease-out;
}

.header {
padding: var(--space-base);
}

.content {
flex: 1;
overflow-y: hidden;
}

@keyframes slideIn {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking we should also do a slide out animation so it feels a bit less abrupt on the way out

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that looks & feels much better!

from {
transform: translateX(-100%);
}
to {
transform: translateX(0);
}
}

@keyframes slideOut {
from {
transform: translateX(0);
}
to {
transform: translateX(-100%);
}
}
37 changes: 37 additions & 0 deletions packages/site/src/layout/LeftDrawer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Box, Button } from "@jobber/components";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LeftDrawer is a simpler version of our SideDrawer, until we can get SideDrawer to slide out from different directions

import { PropsWithChildren, useState } from "react";
import styles from "./LeftDrawer.module.css";

interface LeftDrawerProps extends PropsWithChildren {
readonly onClose: () => void;
readonly header?: React.ReactNode;
}

export function LeftDrawer({ children, onClose, header }: LeftDrawerProps) {
const [isClosing, setIsClosing] = useState(false);

const handleClose = () => {
setIsClosing(true);
setTimeout(() => {
onClose();
}, 200);
};

return (
<div
className={`${styles.drawer} ${isClosing ? styles.drawerClosing : ""}`}
>
<Box padding="base" direction="row" alignItems="center" gap="small">
<Button
icon="cross"
ariaLabel="Close"
type="tertiary"
variation="subtle"
onClick={handleClose}
/>
{header}
</Box>
<div className={styles.content}>{children}</div>
</div>
);
}
24 changes: 22 additions & 2 deletions packages/site/src/layout/NavMenu.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
--navItemHeight: 40px;
display: flex;
flex-direction: column;
padding: 35px 0 0 0;
height: 100dvh;
height: 100%;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

height of NavMenu in mobile viewport should not be 100dvh since it lives inside the LeftDrawer with header on top

min-width: var(--sideBarWidth);
box-sizing: border-box;

@media screen and (min-width: 768px) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--medium-screens-and-up css variable isn't working properly due to missing post-media plugin. There's also a couple other issues with css import that I spotted along the way. Will get another ticket started to deal with it.

padding: 35px 0 0 0;
height: 100dvh;
}
}

.navMenuContainer>* {
Expand Down Expand Up @@ -130,4 +134,20 @@ a.navFooterLink {
margin-top: auto;
font-size: var(--typography--fontSize-small);
color: var(--color-text--secondary);
}

.desktopNavContainer {
display: none;

@media screen and (min-width: 768px) {
display: block;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to explicitly be setting display: block on divs? they should just do that naturally

then we could reduce our style rules to only be applying the thing we want to change, when we want to apply them

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did this to follow the design guideline to style mobile first, also for when the --medium-screens-and-up css variable is added back.

}
}

.navMenuHeaderLogo {
display: none;

@media screen and (min-width: 768px) {
display: block;
}
}
39 changes: 34 additions & 5 deletions packages/site/src/layout/NavMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { Box, Button, Typography } from "@jobber/components";
import { Link, useLocation } from "react-router-dom";
import { Fragment, PropsWithChildren, useRef } from "react";
import { useBreakpoints } from "@jobber/hooks";
import AnimatedPresenceDisclosure from "./AnimatedPresenceDisclosure";
import styles from "./NavMenu.module.css";
import { LeftDrawer } from "./LeftDrawer";
import { routes } from "../routes";
import { JobberLogo } from "../assets/JobberLogo.svg";
import { useAtlantisSite } from "../providers/AtlantisSiteProvider";
import { VisibleWhenFocused } from "../components/VisibleWhenFocused";

interface NavMenuProps {
export interface NavMenuProps {
readonly mainContentRef: React.RefObject<HTMLDivElement>;
}

Expand All @@ -17,7 +19,7 @@ interface NavMenuProps {
* @returns ReactNode
*/
export const NavMenu = ({ mainContentRef }: NavMenuProps) => {
const { isMinimal } = useAtlantisSite();
const { isMinimal, isMobileMenuOpen, toggleMobileMenu } = useAtlantisSite();
const { pathname } = useLocation();
const selectedRef = useRef<HTMLAnchorElement | null>(null);

Expand Down Expand Up @@ -67,19 +69,20 @@ export const NavMenu = ({ mainContentRef }: NavMenuProps) => {

const skipToContent = () => {
mainContentRef.current?.focus();
toggleMobileMenu();
};

return (
const menuContent = (
<nav className={styles.navMenuContainer}>
<div className={styles.navMenuHeader}>
<VisibleWhenFocused>
<Button label="Skip to Content" onClick={skipToContent} />
</VisibleWhenFocused>
<Box>
<div className={styles.navMenuHeaderLogo}>
<Link to="/">
<JobberLogo />
</Link>
</Box>
</div>
</div>
<div className={styles.navMenu}>
<MenuList>
Expand Down Expand Up @@ -118,6 +121,26 @@ export const NavMenu = ({ mainContentRef }: NavMenuProps) => {
</a>
</nav>
);

return (
<>
<div className={styles.desktopNavContainer}>{menuContent}</div>
{isMobileMenuOpen && (
<LeftDrawer
onClose={toggleMobileMenu}
header={
<Box padding={{ top: "smaller" }}>
<Link to="/" onClick={toggleMobileMenu}>
<JobberLogo />
</Link>
</Box>
}
>
{menuContent}
</LeftDrawer>
)}
</>
);
};

const getLinkClassName = (
Expand All @@ -143,12 +166,15 @@ export const StyledLink = ({
isSelected,
styles.selected,
);
const { toggleMobileMenu } = useAtlantisSite();
const { mediumAndUp } = useBreakpoints();

return (
<Link
to={to ?? "/"}
className={className}
ref={isSelected ? selectedRef : null}
onClick={mediumAndUp ? undefined : toggleMobileMenu}
>
{children}
</Link>
Expand All @@ -170,12 +196,15 @@ export const StyledSubLink = ({
isSelected,
styles.selected,
);
const { toggleMobileMenu } = useAtlantisSite();
const { mediumAndUp } = useBreakpoints();

return (
<Link
to={to ?? "/"}
className={className}
ref={isSelected ? selectedRef : null}
onClick={mediumAndUp ? undefined : toggleMobileMenu}
>
{children}
</Link>
Expand Down
61 changes: 34 additions & 27 deletions packages/site/src/layout/SearchButton.module.css
Original file line number Diff line number Diff line change
@@ -1,40 +1,47 @@
.searchButton {
display: flex;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file is mostly just spacing diff

align-items: center;
border: var(--border-base) solid var(--color-border--interactive);
border-radius: var(--radius-base);
padding: var(--space-small);
background: var(--color-surface);
outline: transparent;
cursor: pointer;
transition: all var(--timing-base) ease-out;
display: flex;
align-items: center;
border: var(--border-base) solid var(--color-border--interactive);
border-radius: var(--radius-base);
padding: var(--space-small);
background: var(--color-surface);
outline: transparent;
cursor: pointer;
transition: all var(--timing-base) ease-out;

&:focus-visible {
box-shadow: var(--shadow-focus);
background-color: var(--color-surface--background--hover);
}
&:focus-visible {
box-shadow: var(--shadow-focus);
background-color: var(--color-surface--background--hover);
}
}

.searchButton:hover {
background: var(--color-surface--background--hover);
border: var(--border-base) solid var(--color-interactive--subtle--hover);
background: var(--color-surface--background--hover);
border: var(--border-base) solid var(--color-interactive--subtle--hover);
}

.searchButtonText {
margin: 0 var(--space-small);
flex: 1;
text-align: start;
margin: 0 var(--space-small);
display: none;
flex: 1;
text-align: start;
@media screen and (min-width: 768px) {
display: block;
}
}

.searchKeyIndicator {
background: var(--color-surface--background);
width: 20px;
height: 20px;
font-size: var(--typography--fontSize-large);
color: var(--color-text);
background: var(--color-surface--background);
width: 20px;
height: 20px;
font-size: var(--typography--fontSize-large);
color: var(--color-text);
display: none;
align-items: center;
justify-content: center;
border-radius: var(--radius-small);
box-shadow: var(--shadow-low);
@media screen and (min-width: 768px) {
display: flex;
align-items: center;
justify-content: center;
border-radius: var(--radius-small);
box-shadow: var(--shadow-low);
}
}
Loading