diff --git a/src/Navbar/Navbar.stories.tsx b/src/Navbar/Navbar.stories.tsx new file mode 100644 index 0000000..53e3684 --- /dev/null +++ b/src/Navbar/Navbar.stories.tsx @@ -0,0 +1,81 @@ +import type { Meta } from "@storybook/react"; + +import { Navbar, NavbarBrand, NavbarMenu } from "."; + +const meta = { + title: "Atoms/Navbar", + component: Navbar, + parameters: { + layout: "fullscreen", + }, +} satisfies Meta; + +export default meta; + +export const All = () => ( +
+ + + + White + + + + + One + + + Two + + + Three + + + + + + + + Black + + + + + One + + + Two + + + Three + + + + + + + + Gray + + + + + One + + + Two + + + Three + + + +
+); diff --git a/src/Navbar/index.scss b/src/Navbar/index.scss new file mode 100644 index 0000000..57eafe3 --- /dev/null +++ b/src/Navbar/index.scss @@ -0,0 +1,61 @@ +@use "sass:map"; + +@use "../sass/mixins"; +@use "../sass/tokens"; + +.navbar { + top: 0; + + display: flex; + align-items: center; + + font-family: map.get(tokens.$fonts, sans); + + .navbar--fixed { + position: fixed; + } + + .navbar--container { + margin: auto; + display: flex; + justify-content: space-between; + width: 80%; // TODO: make this responsive + + .navbar--brand { + display: flex; + align-items: center; + gap: 1rem; // TODO: make this responsive + } + + .navbar--menu { + display: flex; + align-items: center; + gap: 1rem; // TODO: make this responsive + } + } + + @each $color, + $scheme + in ( + "black": ( + "bg": black, + "text": white, + ), + "white": ( + "bg": white, + "text": black, + ), + "gray": ( + "bg": gray, + "text": white, + ) + ) + { + &.navbar--#{$color} { + background-color: map.get(tokens.$brand, map.get($scheme, bg)); + * { + color: map.get(tokens.$brand, map.get($scheme, text)); + } + } + } +} diff --git a/src/Navbar/index.tsx b/src/Navbar/index.tsx new file mode 100644 index 0000000..c8159a1 --- /dev/null +++ b/src/Navbar/index.tsx @@ -0,0 +1,46 @@ +import type { FC, PropsWithChildren } from "react"; + +import "./index.scss"; +import clsx from "clsx"; + +export type NavbarColor = "black" | "white" | "gray"; + +export interface NavbarProps { + /** + * Whether the navbar stays in place upon scroll. + */ + fixed?: boolean; + + /** + * The navbar's basic color scheme. + */ + color: NavbarColor; +} + +/** + * A standard navbar at the top of the page. + */ +export const Navbar: FC> = ({ + children, + fixed = false, + color, +}) => ( + +); + +export const NavbarBrand: FC = ({ children }) => ( +
{children}
+); + +export const NavbarMenu: FC = ({ children }) => ( + {children} +); diff --git a/src/sass/_mixins.scss b/src/sass/_mixins.scss index e9318c9..15f05b3 100644 --- a/src/sass/_mixins.scss +++ b/src/sass/_mixins.scss @@ -2,6 +2,11 @@ @use "tokens"; +// A helper to sprinkle around during development. Just don't commit it in actual components! +@mixin dev { + outline: 1.5px solid red; +} + @mixin light-mode { @media (prefers-color-scheme: light) { @content;