From 179358c919a8e25d26d9aa62361238412a57dd9d Mon Sep 17 00:00:00 2001 From: Ou Date: Sat, 19 Oct 2024 13:15:29 +0800 Subject: [PATCH] feat: ui --- src/components/column/dnd.tsx | 6 +- src/components/column/index.tsx | 24 ++++-- src/components/column/navbar.tsx | 33 ------- src/components/common/toast.tsx | 35 ++++++++ .../{header.tsx => header/index.tsx} | 82 ++++-------------- src/components/header/menu.tsx | 85 +++++++++++++++++++ src/components/navbar.tsx | 30 +++++++ src/hooks/useDark.ts | 4 +- src/hooks/useOnReload.ts | 8 +- src/routes/index.tsx | 8 +- src/styles/globals.css | 4 + 11 files changed, 196 insertions(+), 123 deletions(-) delete mode 100644 src/components/column/navbar.tsx create mode 100644 src/components/common/toast.tsx rename src/components/{header.tsx => header/index.tsx} (53%) create mode 100644 src/components/header/menu.tsx create mode 100644 src/components/navbar.tsx diff --git a/src/components/column/dnd.tsx b/src/components/column/dnd.tsx index 6478785..f026b18 100644 --- a/src/components/column/dnd.tsx +++ b/src/components/column/dnd.tsx @@ -36,9 +36,13 @@ export function Dnd() { initial="hidden" animate="visible" variants={{ + hidden: { + opacity: 0, + }, visible: { + opacity: 1, transition: { - delayChildren: 0.2, + delayChildren: 0.1, staggerChildren: 0.1, }, }, diff --git a/src/components/column/index.tsx b/src/components/column/index.tsx index 9bc96fe..e0c69d8 100644 --- a/src/components/column/index.tsx +++ b/src/components/column/index.tsx @@ -1,8 +1,10 @@ import type { ColumnID } from "@shared/types" import { useAtom } from "jotai" import { useEffect } from "react" +import { useTitle } from "react-use" +import { metadata } from "@shared/metadata" +import { NavBar } from "../navbar" import { Dnd } from "./dnd" -import { NavBar } from "./navbar" import { currentColumnIDAtom } from "~/atoms" export function Column({ id }: { id: ColumnID }) { @@ -10,10 +12,18 @@ export function Column({ id }: { id: ColumnID }) { useEffect(() => { setCurrentColumnID(id) }, [id, setCurrentColumnID]) - return ( - <> - - { currentColumnID === id && } - - ) + + useTitle(`NewsNow | ${metadata[id].name}`) + if (id === currentColumnID) { + return ( + <> +
+ +
+
+ +
+ + ) + } } diff --git a/src/components/column/navbar.tsx b/src/components/column/navbar.tsx deleted file mode 100644 index f14536b..0000000 --- a/src/components/column/navbar.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import { columnIds, metadata } from "@shared/metadata" -import type { ColumnID } from "@shared/types" -import { Link } from "@tanstack/react-router" -import clsx from "clsx" -import { useTitle } from "react-use" - -export function NavBar({ id }: { id: ColumnID }) { - useTitle(`NewsNow | ${metadata[id].name}`) - return ( -
- - {columnIds.map(columnId => ( - - {metadata[columnId].name} - - ))} - -
- ) -} diff --git a/src/components/common/toast.tsx b/src/components/common/toast.tsx new file mode 100644 index 0000000..bb7f905 --- /dev/null +++ b/src/components/common/toast.tsx @@ -0,0 +1,35 @@ +import clsx from "clsx" +import { Toaster } from "sonner" + +export function Toast() { + return ( + + ) +} diff --git a/src/components/header.tsx b/src/components/header/index.tsx similarity index 53% rename from src/components/header.tsx rename to src/components/header/index.tsx index c48e427..906d084 100644 --- a/src/components/header.tsx +++ b/src/components/header/index.tsx @@ -5,76 +5,23 @@ import { useIsFetching } from "@tanstack/react-query" import clsx from "clsx" import type { SourceID } from "@shared/types" import { Homepage, Version } from "@shared/consts" -import { useLocalStorage } from "react-use" -import { useDark } from "~/hooks/useDark" +import { NavBar } from "../navbar" +import { Menu } from "./menu" import { currentSourcesAtom, goToTopAtom, refetchSourcesAtom } from "~/atoms" -function ThemeToggle() { - const { toggleDark } = useDark() - return ( - - ) - } - return ( - - ) -} - function GoTop() { const { ok, fn: goToTop } = useAtomValue(goToTopAtom) return ( - ok && ( - + ) + :