1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2026-04-21 12:05:30 -04:00

CSS modules ➡️ Stitches 🧵 (#799)

This commit is contained in:
2022-03-03 09:18:26 -05:00
committed by GitHub
parent ac7ac71c10
commit c2dde042b7
93 changed files with 2392 additions and 3000 deletions
+40 -10
View File
@@ -1,27 +1,57 @@
import { memo } from "react";
import { useRouter } from "next/router";
import classNames from "classnames";
import MenuItem from "../MenuItem/MenuItem";
import { styled } from "../../lib/styles/stitches.config";
import { menuItems } from "../../lib/config/menu";
import type { ComponentProps } from "react";
import styles from "./Menu.module.css";
const Wrapper = styled("ul", {
display: "inline-flex",
padding: 0,
margin: 0,
export type MenuProps = {
className?: string;
};
"@mobile": {
width: "100%",
justifyContent: "space-between",
marginLeft: "1em",
},
const Menu = ({ className }: MenuProps) => {
"@superNarrow": {
marginLeft: "1.4em",
},
});
const Item = styled("li", {
listStyle: "none",
display: "inline-flex",
marginLeft: "1em",
"@mobile": {
marginLeft: 0,
},
"@superNarrow": {
// the home icon is kinda redundant when space is SUPER tight
"&:first-of-type": {
display: "none",
},
},
});
export type MenuProps = ComponentProps<typeof Wrapper>;
const Menu = ({ ...rest }: MenuProps) => {
const router = useRouter();
return (
<ul className={classNames(styles.menu, className)}>
<Wrapper {...rest}>
{menuItems.map((item, index) => (
<li key={index} className={styles.item}>
<Item key={index}>
{/* kinda weird/hacky way to determine if the *first part* of the current path matches this href */}
<MenuItem {...item} current={item.href === `/${router.pathname.split("/")[1]}`} />
</li>
</Item>
))}
</ul>
</Wrapper>
);
};