-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update navbar, add quick center menu, & dark theme
- Loading branch information
andrianfaa
committed
Sep 5, 2023
1 parent
1213a48
commit 3c9474c
Showing
27 changed files
with
579 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
106 changes: 106 additions & 0 deletions
106
src/components/Navigation/NavigationBar/NavigationBar.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import { Portal } from "@/components/Portal"; | ||
import clsx from "clsx"; | ||
import Image from "next/image"; | ||
import { useEffect, useState } from "react"; | ||
import { FiChevronRight, FiGrid } from "react-icons/fi"; | ||
import { QuickCenter } from "../QuickCenter"; | ||
import type { NavigationBarParams } from "./NavigationBar"; | ||
|
||
import AnfaLogoSVG from "@/assets/anfa-logo.svg"; | ||
|
||
const NavigationBar = ({ testId }: NavigationBarParams) => { | ||
const [isOpen, setIsOpen] = useState<boolean>(false); | ||
const [openQuickCenter, setOpenQuickCenter] = useState<boolean>(false); | ||
|
||
useEffect(() => { | ||
if (typeof window === "undefined") return; | ||
|
||
window.addEventListener("keydown", (event) => { | ||
const { key, code } = event; | ||
|
||
if (openQuickCenter && (key === "Escape" || code === "Escape")) { | ||
setOpenQuickCenter(false); | ||
} | ||
}); | ||
}, [openQuickCenter]); | ||
|
||
return ( | ||
<> | ||
<Portal> | ||
<QuickCenter isOpen={openQuickCenter} onClickClose={() => setOpenQuickCenter(false)} /> | ||
</Portal> | ||
|
||
<div | ||
className={clsx("border-b border-b-slate-200 dark:border-slate-900", "fixed top-0 left-0 z-30", "w-full")} | ||
data-testid={testId?.parent} | ||
> | ||
<div className={clsx("container", "p-4 mx-auto lg:p-6", "flex flex-row items-center justify-between")}> | ||
<div className={clsx("flex flex-row items-center gap-x-6")}> | ||
<a href="" className={clsx("flex flex-row items-center justify-start")}> | ||
<Image | ||
data-testid={testId?.logo} | ||
src={AnfaLogoSVG} | ||
alt="Anfa Logo" | ||
className={clsx("w-10 h-10 lg:w-12 lg:h-12")} | ||
width={32} | ||
height={32} | ||
/> | ||
</a> | ||
|
||
<button | ||
type="button" | ||
accessKey="q" | ||
className={clsx( | ||
"text-sm font-semibold", | ||
"button button-primary", | ||
"px-4 py-2.5", | ||
"flex flex-row items-center gap-x-2", | ||
"rounded-md" | ||
)} | ||
title="Open quick center" | ||
onClick={() => { | ||
setOpenQuickCenter((state) => !state); | ||
}} | ||
> | ||
<FiGrid className={clsx("h-4 w-4")} /> | ||
<span>Quick center</span> | ||
|
||
<FiChevronRight className={clsx("h-4 w-4", "lg:hidden")} /> | ||
<span | ||
className={clsx( | ||
"text-xs leading-none text-white font-normal", | ||
"bg-primary rounded-md", | ||
"px-1.5 py-1", | ||
"hidden lg:flex" | ||
)} | ||
> | ||
alt+Q | ||
</span> | ||
</button> | ||
</div> | ||
|
||
<button | ||
type="button" | ||
className={clsx("navigation-toggler", "lg:hidden", isOpen ? "" : "")} | ||
data-testid={testId?.toggler} | ||
onClick={() => setIsOpen((state) => !state)} | ||
> | ||
<span className="icon"></span> | ||
<span className="icon"></span> | ||
<span className="icon"></span> | ||
</button> | ||
|
||
{/* <nav data-testid={testId?.navigation}> | ||
<ul> | ||
<li> | ||
<a href="">About</a> | ||
</li> | ||
</ul> | ||
</nav> */} | ||
</div> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default NavigationBar; |
12 changes: 12 additions & 0 deletions
12
src/components/Navigation/NavigationBar/NavigationBar.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export interface NavigationBarParams { | ||
/** | ||
* Jest Testing ID | ||
*/ | ||
testId?: { | ||
parent?: string; | ||
title?: string; | ||
logo?: string; | ||
navigation?: string; | ||
toggler?: string; | ||
}; | ||
} |
33 changes: 33 additions & 0 deletions
33
src/components/Navigation/NavigationBar/NavigationBar.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { render, screen } from "@testing-library/react"; | ||
import NavigationBar from "./NavigationBar.component"; | ||
|
||
describe("test `<Navigation />` component", () => { | ||
it("should be rendered", () => { | ||
render( | ||
<NavigationBar | ||
testId={{ | ||
parent: "navigation-parent" | ||
}} | ||
/> | ||
); | ||
|
||
const text = screen.getByTestId("navigation-parent"); | ||
|
||
expect(text).toBeVisible(); | ||
}); | ||
|
||
it("should render navigation toggler", () => { | ||
render( | ||
<NavigationBar | ||
testId={{ | ||
toggler: "navigation-toggler" | ||
}} | ||
/> | ||
); | ||
|
||
const navigationToggler = screen.getByTestId("navigation-toggler"); | ||
|
||
expect(navigationToggler).toBeVisible(); | ||
expect(navigationToggler).toBeValid(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as NavigationBar } from "./NavigationBar.component"; |
Oops, something went wrong.