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

Pieti kinnunen/nav update #403

Merged
merged 6 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
1 change: 0 additions & 1 deletion components/DropdownMenu/DropdownMenu.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
.body {
box-sizing: border-box;
display: block;
padding: 0 0 var(--m-2);
}

.withSubMenus {
Expand Down
57 changes: 0 additions & 57 deletions components/Header/HeaderCTA.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,60 +33,3 @@
margin-right: var(--m-2);
}
}

.downloadsLink {
text-decoration: none;
font-weight: 700;
font-size: var(--fs-text-md);
color: var(--color-code);
padding-left: 10px;
padding-right: 10px;
@media (--lg-scr) {
padding-left: var(--m-3);
padding-right: var(--m-3);
}
@media (--sm-scr) {
display: none;
}
&:focus,
&:hover {
color: var(--color-dark-purple);
}
}

.searchWrapper {
padding: var(--m-1) var(--m-1) 0 var(--m-2);
@media (--sm-scr) {
display: none;
}
}

.group {
position: relative;
padding-left: var(--m-2);
@media (--sm-scr) {
padding-left: 0;
width: 100%;
}
}

.dropdown {
display: none;
z-index: 3000;

@media (--sm-scr) {
position: relative;
width: 100%;
}

@media (--md-scr) {
position: absolute;
top: var(--m-6);
right: var(--m-2);
min-width: 400px;
}

&.visible {
display: block;
}
}
94 changes: 19 additions & 75 deletions components/Header/HeaderCTA.tsx
Original file line number Diff line number Diff line change
@@ -1,83 +1,27 @@
import cn from "classnames";
import { useState, useCallback, useRef, MouseEvent } from "react";
import { useClickAway } from "react-use";
import Button from "components/Button";
import Link from "components/Link";
import {
DropdownMenuOverlay,
DropdownMenuCTA,
DropdownMenuItemCTA,
} from "../DropdownMenu";
import styles from "./HeaderCTA.module.css";

const HeaderCTA = () => {
const ref = useRef(null);

const [isSignInVisible, setIsSignInVisible] = useState<boolean>(false);
const toggleSignIn = useCallback((e: MouseEvent<HTMLElement>) => {
e.preventDefault();

setIsSignInVisible((value) => !value);
}, []);

useClickAway(ref, () => {
if (isSignInVisible) {
setIsSignInVisible(false);
}
});

return (
<>
{isSignInVisible && <DropdownMenuOverlay />}
<div className={styles.wrapper}>
<Link
className={styles.downloadsLink}
href="https://goteleport.com/download/"
data-testid="downloads"
>
Downloads
</Link>
<div className={styles.group} ref={ref}>
<Button
as="link"
href="https://teleport.sh/"
onClick={toggleSignIn}
variant="secondary"
className={styles.cta}
data-testid="sign-in"
>
Sign In
</Button>
<div
className={cn(styles.dropdown, isSignInVisible && styles.visible)}
data-testid="sign-in-menu"
>
<DropdownMenuCTA title="Sign in to Teleport">
<DropdownMenuItemCTA
href="https://teleport.sh/"
icon="clouds"
title="Teleport Cloud Login"
description="Login to your Teleport Account"
/>
<DropdownMenuItemCTA
href="https://dashboard.gravitational.com/web/login/"
icon="download"
title="Dashboard Login"
description="Legacy Login &amp; Teleport Enterprise Downloads"
/>
</DropdownMenuCTA>
</div>
</div>
<Button
as="link"
href="/signup/"
className={styles.cta}
data-testid="get-started"
>
Get Started
</Button>
</div>
</>
<div className={styles.wrapper}>
<Button
as="link"
href="/signup/enterprise/"
variant="secondary"
className={styles.cta}
data-testid="contact-sales"
>
Contact Sales
</Button>
<Button
as="link"
href="/signup/"
className={styles.cta}
data-testid="get-started"
>
Get Started
</Button>
</div>
);
};

Expand Down
2 changes: 1 addition & 1 deletion components/Menu/Category.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
align-items: center;
justify-content: center;
z-index: 3001;
width: 100%;
white-space: nowrap;
min-width: 0;
height: 80px;
padding: 0 var(--m-2);
Expand Down
20 changes: 20 additions & 0 deletions components/Menu/Menu.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,23 @@
max-width: none;
}
}

.signInDropdown {
display: none;
z-index: 3000;

@media (--sm-scr) {
position: relative;
width: 100%;
}

@media (--md-scr) {
position: absolute;
left: 0;
min-width: 400px;
}

&.visible {
display: block;
}
}
53 changes: 52 additions & 1 deletion components/Menu/Menu.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
import { useState } from "react";
import { useState, useRef, useCallback, MouseEvent } from "react";
import { useClickAway } from "react-use";
import MenuCategory from "./Category";
import structure from "./structure";
import styles from "./Menu.module.css";
import categoryStyles from "./Category.module.css";
import cn from "classnames";
import { DropdownMenuCTA, DropdownMenuItemCTA } from "../DropdownMenu";

const Menu = () => {
const [openedCategoryId, setOpenedCategoryId] = useState<number | null>(null);
const ref = useRef(null);

const [isSignInVisible, setIsSignInVisible] = useState<boolean>(false);
const toggleSignIn = useCallback((e: MouseEvent<HTMLElement>) => {
e.preventDefault();

setIsSignInVisible((value) => !value);
}, []);

useClickAway(ref, () => {
if (isSignInVisible) {
setIsSignInVisible(false);
}
});

return (
<nav className={styles.navItems}>
{structure.map((props, id) => (
Expand All @@ -16,6 +35,38 @@ const Menu = () => {
{...props}
/>
))}
<div style={{ position: "relative" }} ref={ref}>
<a
href="https://teleport.sh/"
onClick={toggleSignIn}
className={cn(categoryStyles.link, isSignInVisible && styles.visible)}
data-testid="sign-in"
>
Sign In
</a>
<div
className={cn(
styles.signInDropdown,
isSignInVisible && styles.visible
)}
data-testid="sign-in-menu"
>
<DropdownMenuCTA title="Sign in to Teleport">
<DropdownMenuItemCTA
href="https://teleport.sh/"
icon="clouds"
title="Teleport Cloud Login"
description="Login to your Teleport Account"
/>
PietiKinnunen marked this conversation as resolved.
Show resolved Hide resolved
<DropdownMenuItemCTA
href="https://dashboard.gravitational.com/web/login/"
icon="download"
title="Dashboard Login"
description="Legacy Login &amp; Teleport Enterprise Downloads"
/>
PietiKinnunen marked this conversation as resolved.
Show resolved Hide resolved
</DropdownMenuCTA>
</div>
</div>
</nav>
);
};
Expand Down
27 changes: 27 additions & 0 deletions components/Menu/structure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,33 @@ const menu: MenuCategoryProps[] = [
href: "/pricing/",
testId: "pricing",
},
{
title: "Community",
href: "/community/",
testId: "community",
children: [
{
title: "Getting Started with OSS",
href: "/docs/",
},
{
title: "Downloads",
href: "/download/",
},
{
title: "Community Slack",
href: "/community-slack/",
},
{
title: "GitHub Discussions",
href: "https://github.com/gravitational/teleport/discussions",
},
{
title: "Podcasts",
href: "/resources/podcast/",
},
],
},
];

export default menu;
35 changes: 27 additions & 8 deletions tests/data/navbar-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,14 +300,33 @@ export const navigationData: NavbarData = [
isExternal: true,
},
{
button: { title: "", testId: "search" },
href: "https://goteleport.com/search/",
isExternal: true,
},
{
button: { title: "Downloads", testId: "downloads" },
href: "https://goteleport.com/download/",
isExternal: true,
button: { title: "Community", testId: "community" },
menu: {
title: "Community",
testId: "community-menu",
children: [
{
title: "Getting Started with OSS",
href: "/docs/",
},
{
title: "Downloads",
href: "/download/",
},
{
title: "Community Slack",
href: "/community-slack/",
},
{
title: "GitHub Discussions",
href: "https://github.com/gravitational/teleport/discussions",
},
{
title: "Podcasts",
href: "/resources/podcast/",
},
],
},
},
{
button: { title: "Sign In", testId: "sign-in" },
Expand Down
Loading