From 7c8763cc7645cafb4548ef8e339183964b66635d Mon Sep 17 00:00:00 2001 From: hashrock Date: Wed, 2 Aug 2023 09:47:31 +0900 Subject: [PATCH] fix: use TabsBar style at TimeSelector (#406) I like TabsBar style that we're using on the dashboard, so I replaced with it. It looks different from Header Nav, and I think the selection state is easy to see. wdyt? Before: image After: image image --- components/TabsBar.tsx | 36 ++++++++++++++++++++---------- routes/index.tsx | 50 ++++++++++++++---------------------------- 2 files changed, 41 insertions(+), 45 deletions(-) diff --git a/components/TabsBar.tsx b/components/TabsBar.tsx index f273592d639d..d2c1dcaa83cd 100644 --- a/components/TabsBar.tsx +++ b/components/TabsBar.tsx @@ -2,24 +2,36 @@ import { LINK_STYLES } from "@/utils/constants.ts"; import { cx } from "@twind/core"; +export function TabItem( + props: { path: string; innerText: string; active: boolean }, +) { + return ( + + {props.innerText} + + ); +} + export default function TabsBar( props: { links: { path: string; innerText: string }[]; currentPath: string }, ) { return (
{props.links.map((link) => ( - - {link.innerText} - + ))}
); diff --git a/routes/index.tsx b/routes/index.tsx index c71d0f4d0419..e948434d92e9 100644 --- a/routes/index.tsx +++ b/routes/index.tsx @@ -14,9 +14,8 @@ import { type User, } from "@/utils/db.ts"; import { DAY, WEEK } from "std/datetime/constants.ts"; -import { getToggledStyles } from "@/utils/display.ts"; -import { ACTIVE_LINK_STYLES, LINK_STYLES } from "@/utils/constants.ts"; import Head from "@/components/Head.tsx"; +import { TabItem } from "@/components/TabsBar.tsx"; interface HomePageData extends State { itemsUsers: User[]; @@ -62,38 +61,23 @@ export const handler: Handlers = { function TimeSelector(props: { url: URL }) { const timeAgo = props.url.searchParams.get("time-ago"); return ( -
+
{/* These links do not preserve current URL queries. E.g. if ?page=2, that'll be removed once one of these links is clicked */} - - Last Week - - - Last Month - - - All time - + + +
); }