From a9c44b64a35499d0850f59eebbc32ab39f2fc84e Mon Sep 17 00:00:00 2001 From: XLor Date: Thu, 12 Sep 2024 23:39:51 +0800 Subject: [PATCH] feat(web): layouts --- .../web/app/components/Sidebar/atom.ts | 3 + .../web/app/components/Sidebar/index.ts | 3 + .../web/app/components/Sidebar/sidebar.tsx | 10 +++ apps/frontend/web/app/layouts/Layout.tsx | 36 +++++--- apps/frontend/web/app/layouts/index.ts | 3 + .../web/app/routes/resources.$page/route.tsx | 80 +++++++++--------- .../web/app/routes/resources/route.tsx | 83 +++++++++++-------- apps/frontend/web/app/styles/main.css | 5 ++ 8 files changed, 140 insertions(+), 83 deletions(-) create mode 100644 apps/frontend/web/app/components/Sidebar/atom.ts create mode 100644 apps/frontend/web/app/components/Sidebar/index.ts create mode 100644 apps/frontend/web/app/components/Sidebar/sidebar.tsx create mode 100644 apps/frontend/web/app/layouts/index.ts diff --git a/apps/frontend/web/app/components/Sidebar/atom.ts b/apps/frontend/web/app/components/Sidebar/atom.ts new file mode 100644 index 000000000..fd87f499a --- /dev/null +++ b/apps/frontend/web/app/components/Sidebar/atom.ts @@ -0,0 +1,3 @@ +import { atom } from 'jotai'; + +export const isOpenSidebar = atom(false); diff --git a/apps/frontend/web/app/components/Sidebar/index.ts b/apps/frontend/web/app/components/Sidebar/index.ts new file mode 100644 index 000000000..a783bfec1 --- /dev/null +++ b/apps/frontend/web/app/components/Sidebar/index.ts @@ -0,0 +1,3 @@ +export * from './atom'; + +export { Sidebar } from './sidebar'; diff --git a/apps/frontend/web/app/components/Sidebar/sidebar.tsx b/apps/frontend/web/app/components/Sidebar/sidebar.tsx new file mode 100644 index 000000000..c98b30927 --- /dev/null +++ b/apps/frontend/web/app/components/Sidebar/sidebar.tsx @@ -0,0 +1,10 @@ +import { useAtom } from "jotai" +import { isOpenSidebar } from "./atom" + +export function Sidebar() { + const [isOpen] = useAtom(isOpenSidebar); + + if (!isOpen) return
+ + return
+} \ No newline at end of file diff --git a/apps/frontend/web/app/layouts/Layout.tsx b/apps/frontend/web/app/layouts/Layout.tsx index 4abf18d93..65783e90d 100644 --- a/apps/frontend/web/app/layouts/Layout.tsx +++ b/apps/frontend/web/app/layouts/Layout.tsx @@ -1,4 +1,5 @@ import Search from '@/components/Search'; +import { Sidebar } from '@/components/Sidebar'; import { NavLink } from '@remix-run/react'; import { atom, useAtom } from 'jotai'; import { useEffect, useRef, useState } from 'react'; @@ -10,8 +11,6 @@ const MaxPaddingTop = 152; const MaxPaddingBottom = 36; const SearchHeight = NavHeight; -// const heroHeightAtom = atom((get) => NavHeight + MaxTitleHeight); - export const useHero = () => { const { y } = useDocumentScroll(); @@ -31,8 +30,10 @@ export default function Layout(props: { children?: React.ReactNode }) {
-
-
{props.children}
+ +
+
{props.children}
+
); @@ -43,12 +44,9 @@ function Hero(props: { height: number, paddingTop: number; paddingBottom: number return (
- -
- 🌸 Anime Garden +
+
+ 🌸 Anime Garden
@@ -59,3 +57,21 @@ function Hero(props: { height: number, paddingTop: number; paddingBottom: number
); } + +function Header() { + return +} \ No newline at end of file diff --git a/apps/frontend/web/app/layouts/index.ts b/apps/frontend/web/app/layouts/index.ts new file mode 100644 index 000000000..8b24d17d7 --- /dev/null +++ b/apps/frontend/web/app/layouts/index.ts @@ -0,0 +1,3 @@ +import Layout from './Layout'; + +export default Layout; diff --git a/apps/frontend/web/app/routes/resources.$page/route.tsx b/apps/frontend/web/app/routes/resources.$page/route.tsx index 8fa7937bf..136c67425 100644 --- a/apps/frontend/web/app/routes/resources.$page/route.tsx +++ b/apps/frontend/web/app/routes/resources.$page/route.tsx @@ -1,48 +1,52 @@ import type { MetaFunction } from "@remix-run/node"; +import Layout from '~/layouts/Layout'; + export const meta: MetaFunction = () => { return [ - { title: "New Remix App" }, - { name: "description", content: "Welcome to Remix!" }, + { title: "Anime Garden 動漫花園資源網第三方镜像站" }, + { name: "description", content: "}Anime Garden 動漫花園資源網第三方镜像站" }, ]; }; export default function Resources() { return ( -
-

Welcome to Remix

- -
+ +
+

Welcome to Remix

+ +
+
); -} +} \ No newline at end of file diff --git a/apps/frontend/web/app/routes/resources/route.tsx b/apps/frontend/web/app/routes/resources/route.tsx index 696a45d07..136c67425 100644 --- a/apps/frontend/web/app/routes/resources/route.tsx +++ b/apps/frontend/web/app/routes/resources/route.tsx @@ -1,39 +1,52 @@ +import type { MetaFunction } from "@remix-run/node"; + +import Layout from '~/layouts/Layout'; + +export const meta: MetaFunction = () => { + return [ + { title: "Anime Garden 動漫花園資源網第三方镜像站" }, + { name: "description", content: "}Anime Garden 動漫花園資源網第三方镜像站" }, + ]; +}; + export default function Resources() { return ( -
-

Welcome to Remix

- -
+ +
+

Welcome to Remix

+ +
+
); } \ No newline at end of file diff --git a/apps/frontend/web/app/styles/main.css b/apps/frontend/web/app/styles/main.css index bfe246f18..922624722 100644 --- a/apps/frontend/web/app/styles/main.css +++ b/apps/frontend/web/app/styles/main.css @@ -1,2 +1,7 @@ @import '@onekuma/preset.css'; @import '@onekuma/reset/tailwind.css'; + +.main { + /* prettier-ignore */ + @apply: mx-auto lg:w-[80vw] md:w-[46rem] lt-md:w-[95vw]; +}