Skip to content

Commit

Permalink
feat: create mobile menu
Browse files Browse the repository at this point in the history
  • Loading branch information
piro0919 committed Nov 13, 2024
1 parent 7b56499 commit 6124f82
Show file tree
Hide file tree
Showing 10 changed files with 177 additions and 3 deletions.
1 change: 1 addition & 0 deletions apps/user/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"react": "19.0.0-rc-02c0e824-20241028",
"react-dom": "19.0.0-rc-02c0e824-20241028",
"ress": "5.0.2",
"use-show-window-size": "0.0.1",
"zod": "3.23.8"
},
"name": "user",
Expand Down
16 changes: 16 additions & 0 deletions apps/user/src/app/_components/Header/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Lobster } from "next/font/google";
import styles from "./style.module.css";

const lobster = Lobster({
display: "swap",
subsets: ["latin"],
weight: "400",
});

export default function Header(): JSX.Element {
return (
<header className={styles.header}>
<div className={`${styles.title} ${lobster.className}`}>Vmate</div>
</header>
);
}
12 changes: 12 additions & 0 deletions apps/user/src/app/_components/Header/style.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.header {
align-items: center;
background: #fff;
border-bottom: 1px solid #e8eaee;
display: flex;
height: 48px;
justify-content: center;
}

.title {
font-size: 3rem;
}
28 changes: 28 additions & 0 deletions apps/user/src/app/_components/Layout/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"use client";
import { ReactNode } from "react";
import useShowWindowSize from "use-show-window-size";
import Header from "../Header";
import MobileNavigation from "../MobileNavigation";
import styles from "./style.module.css";

export type LayoutProps = {
children: ReactNode;
};

export default function Layout({ children }: LayoutProps): JSX.Element {
useShowWindowSize({
disable: process.env.NODE_ENV === "production",
});

return (
<div>
<div className={styles.header}>
<Header />
</div>
<main className={styles.main}>{children}</main>
<aside className={styles.mobileNavigation}>
<MobileNavigation />
</aside>
</div>
);
}
13 changes: 13 additions & 0 deletions apps/user/src/app/_components/Layout/style.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.header {
inset: 0 0 auto;
position: fixed;
}

.main {
margin: 48px 0 0;
}

.mobileNavigation {
inset: auto 0 0;
position: fixed;
}
40 changes: 40 additions & 0 deletions apps/user/src/app/_components/MobileNavigation/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import Link from "next/link";
import { useMemo } from "react";
import styles from "./style.module.css";

export default function MobileNavigation(): JSX.Element {
const items = useMemo(
() =>
[
{
path: "/",
text: "ホーム",
},
{
path: "community/",
text: "コミュニティ",
},
{
path: "/schedule",
text: "スケジュール",
},
{
path: "/pypage",
text: "マイページ",
},
].map(({ path, text }) => (
<li key={path}>
<Link className={styles.link} href="/">
{text}
</Link>
</li>
)),
[],
);

return (
<nav className={styles.nav}>
<ul className={styles.list}>{items}</ul>
</nav>
);
}
15 changes: 15 additions & 0 deletions apps/user/src/app/_components/MobileNavigation/style.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.nav {
background: #fff;
border-top: 1px solid #e8eaee;
height: 48px;
}

.list {
display: grid;
grid-template: auto / repeat(4, 1fr);
height: 100%;
}

.link {
display: block;
}
4 changes: 4 additions & 0 deletions apps/user/src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ html {
}
}

body {
background: #f4f7fa;
}

* {
outline: none;
}
Expand Down
5 changes: 4 additions & 1 deletion apps/user/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// eslint-disable-next-line filenames/match-exported
import type { Metadata } from "next";
import "ress";
import Layout from "./_components/Layout";
import "./globals.css";

export const metadata: Metadata = {
Expand All @@ -15,7 +16,9 @@ export default function RootLayout({
}>): JSX.Element {
return (
<html lang="ja">
<body>{children}</body>
<body>
<Layout>{children}</Layout>
</body>
</html>
);
}
46 changes: 44 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6124f82

Please sign in to comment.