From e4d4cc388052540e0b9414067614d228ad5d51ed Mon Sep 17 00:00:00 2001 From: P-man2976 Date: Sun, 15 Oct 2023 18:52:23 +0900 Subject: [PATCH] Move router to top level, functional sidebar --- .../components/channel/NavigateToMusicdex.tsx | 17 ++ .../react/src/components/header/header.tsx | 18 +- .../react/src/components/layout/Frame.tsx | 49 ++-- .../react/src/components/sidebar/sidebar.tsx | 139 +++++++---- packages/react/src/main.tsx | 29 ++- packages/react/src/routes/about.tsx | 12 + packages/react/src/routes/channel.tsx | 12 + packages/react/src/routes/login.tsx | 2 +- packages/react/src/routes/router.tsx | 234 ++++++++---------- packages/react/src/routes/settings.tsx | 9 + 10 files changed, 304 insertions(+), 217 deletions(-) create mode 100644 packages/react/src/components/channel/NavigateToMusicdex.tsx create mode 100644 packages/react/src/routes/about.tsx create mode 100644 packages/react/src/routes/channel.tsx create mode 100644 packages/react/src/routes/settings.tsx diff --git a/packages/react/src/components/channel/NavigateToMusicdex.tsx b/packages/react/src/components/channel/NavigateToMusicdex.tsx new file mode 100644 index 000000000..ad4d25fe3 --- /dev/null +++ b/packages/react/src/components/channel/NavigateToMusicdex.tsx @@ -0,0 +1,17 @@ +import { Navigate, useParams } from "react-router-dom"; + +export function NavigateToMusicdex() { + const { id } = useParams(); + const isStaging = location.origin.includes("staging"); + + return ( + + ); +} diff --git a/packages/react/src/components/header/header.tsx b/packages/react/src/components/header/header.tsx index a6e8b1516..762b02cc3 100644 --- a/packages/react/src/components/header/header.tsx +++ b/packages/react/src/components/header/header.tsx @@ -2,6 +2,8 @@ import { darkAtom } from "@/hooks/useTheme"; import { Button } from "@/shadcn/ui/button"; import { userAtom } from "@/store/auth"; import { useAtom, useAtomValue } from "jotai"; +import { useTranslation } from "react-i18next"; +import { Link } from "react-router-dom"; interface HeaderProps { onClick: () => void; @@ -9,6 +11,7 @@ interface HeaderProps { } export function Header({ onClick, id }: HeaderProps) { + const { t } = useTranslation(); const [dark, toggle] = useAtom(darkAtom); const user = useAtomValue(userAtom); @@ -17,18 +20,15 @@ export function Header({ onClick, id }: HeaderProps) { id={id} className="bg-base-2 flex items-center px-8 py-auto gap-4 sticky top-0 z-40" > - +
Hololive
+ )} ); diff --git a/packages/react/src/components/layout/Frame.tsx b/packages/react/src/components/layout/Frame.tsx index c093a9167..a5532279c 100644 --- a/packages/react/src/components/layout/Frame.tsx +++ b/packages/react/src/components/layout/Frame.tsx @@ -1,19 +1,28 @@ -import './Frame.scss' -import { RouterProvider } from 'react-router-dom' -import router from '@/routes/router' -import { ReactPropTypes, useEffect } from 'react' -import { Sidebar } from '@/components/sidebar/sidebar' -import { isFloatingAtom, isMobileAtom, onResizeAtom, sidebarOpenAtom, sidebarShouldBeFullscreenAtom, toggleAtom } from '@/hooks/useFrame' +import "./Frame.scss"; +import { Navigate, Outlet, useLocation, useNavigate } from "react-router-dom"; +import { ReactPropTypes, useEffect } from "react"; +import { Sidebar } from "@/components/sidebar/sidebar"; +import { + isFloatingAtom, + isMobileAtom, + onResizeAtom, + sidebarOpenAtom, + sidebarShouldBeFullscreenAtom, + toggleAtom, +} from "@/hooks/useFrame"; import { useAtomValue, useSetAtom } from "jotai/react"; -import { darkAtom } from '@/hooks/useTheme' -import { Header } from "@/components/header/header" -import { Toaster } from '@/shadcn/ui/toaster' -import clsx from 'clsx' +import { darkAtom } from "@/hooks/useTheme"; +import { Header } from "@/components/header/header"; +import { Toaster } from "@/shadcn/ui/toaster"; +import clsx from "clsx"; +import { orgAtom } from "@/store/org"; export function Frame() { + const location = useLocation(); const toggle = useSetAtom(toggleAtom); const resize = useSetAtom(onResizeAtom); const dark = useAtomValue(darkAtom); + const org = useAtomValue(orgAtom); useEffect(() => { window.addEventListener("resize", resize); @@ -26,15 +35,17 @@ export function Frame() { const fs = useAtomValue(sidebarShouldBeFullscreenAtom); console.log(fs); + if (location.pathname === "/") return ; + const mainClasses = clsx({ - 'mobile-footer': isMobile, - 'sidebar-static': !floating, - 'sidebar-floating': floating, - 'sidebar-open': open, - 'sidebar-closed': !open, - 'sidebar-fullscreen': fs, - 'dark': dark, - }) + "mobile-footer": isMobile, + "sidebar-static": !floating, + "sidebar-floating": floating, + "sidebar-open": open, + "sidebar-closed": !open, + "sidebar-fullscreen": fs, + dark: dark, + }); return (
@@ -43,7 +54,7 @@ export function Frame() {