From 3dc440632f94cef773dda34d830c0683d8114b54 Mon Sep 17 00:00:00 2001 From: marshennikovaolga Date: Mon, 9 Sep 2024 20:05:36 +0300 Subject: [PATCH 1/3] pages active sidebar background --- .../custom/sidebar/partial/page-section.tsx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/web/components/custom/sidebar/partial/page-section.tsx b/web/components/custom/sidebar/partial/page-section.tsx index 8fe4e59c..94216769 100644 --- a/web/components/custom/sidebar/partial/page-section.tsx +++ b/web/components/custom/sidebar/partial/page-section.tsx @@ -57,7 +57,8 @@ export const PageSection: React.FC<{ pathname?: string }> = ({ pathname }) => { const [show, setShow] = useAtom(pageShowAtom) const pageCount = me?.root.personalPages?.length || 0 - const isActive = pathname ? pathname.startsWith("/pages") : false + // const isActive = pathname ? pathname.startsWith("/pages") : false + const isActive = pathname === "/pages" if (!me) return null @@ -74,21 +75,24 @@ interface PageSectionHeaderProps { isActive: boolean } -const PageSectionHeader: React.FC = ({ pageCount }) => ( +const PageSectionHeader: React.FC = ({ pageCount, isActive }) => (
-

+

Pages {pageCount > 0 && {pageCount}}

-
+
From 3f6ff82063a73620e1381b1a55b088ad70b13c92 Mon Sep 17 00:00:00 2001 From: marshennikovaolga Date: Mon, 9 Sep 2024 20:17:13 +0300 Subject: [PATCH 2/3] date format --- web/components/routes/page/list.tsx | 2 +- web/components/routes/page/partials/page-item.tsx | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/web/components/routes/page/list.tsx b/web/components/routes/page/list.tsx index d5796a73..149cb9ce 100644 --- a/web/components/routes/page/list.tsx +++ b/web/components/routes/page/list.tsx @@ -64,7 +64,7 @@ export const ColumnHeader: React.FC = () => { Topic - + Updated
diff --git a/web/components/routes/page/partials/page-item.tsx b/web/components/routes/page/partials/page-item.tsx index 1f9c3d29..6b484eed 100644 --- a/web/components/routes/page/partials/page-item.tsx +++ b/web/components/routes/page/partials/page-item.tsx @@ -6,6 +6,7 @@ import { Badge } from "@/components/ui/badge" import { Column } from "./column" import { useMedia } from "react-use" import { useColumnStyles } from "../hooks/use-column-styles" +import { format } from "date-fns" interface PageItemProps { page: PersonalPage @@ -47,8 +48,8 @@ export const PageItem = React.forwardRef(({ pa )} - - {page.updatedAt.toLocaleDateString()} + + {format(new Date(page.updatedAt), "d MMM yyyy")}
From 6f77158aacb56b3e4e48447b2d836c1c851355c2 Mon Sep 17 00:00:00 2001 From: marshennikovaolga Date: Mon, 9 Sep 2024 20:48:29 +0300 Subject: [PATCH 3/3] link isActive sidebar --- .../custom/sidebar/partial/link-section.tsx | 77 ++++++++++--------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/web/components/custom/sidebar/partial/link-section.tsx b/web/components/custom/sidebar/partial/link-section.tsx index 46a6e359..0ac854aa 100644 --- a/web/components/custom/sidebar/partial/link-section.tsx +++ b/web/components/custom/sidebar/partial/link-section.tsx @@ -1,6 +1,6 @@ import React from "react" import Link from "next/link" -import { usePathname } from "next/navigation" +import { usePathname, useRouter } from "next/navigation" import { useAccount } from "@/lib/providers/jazz-provider" import { cn } from "@/lib/utils" import { PersonalLinkLists } from "@/lib/schema/personal-link" @@ -32,28 +32,31 @@ interface LinkSectionHeaderProps { isActive: boolean } -const LinkSectionHeader: React.FC = ({ linkCount, isActive }) => ( -
- -

- Links - {linkCount > 0 && {linkCount}} -

- -
-) +const LinkSectionHeader: React.FC = ({ linkCount, isActive }) => { + const pathname = usePathname() + const [state] = useQueryState("state", parseAsStringLiteral(LEARNING_STATES.map(ls => ls.value))) + const isLinksActive = pathname.startsWith("/links") && !state + + return ( +
+ +

+ Links + {linkCount > 0 && {linkCount}} +

+ +
+ ) +} const ALL_STATES = ["all", ...LEARNING_STATES.map(ls => ls.value)] interface ListProps { @@ -62,31 +65,26 @@ interface ListProps { const List: React.FC = ({ personalLinks }) => { const pathname = usePathname() - const [activeState] = useQueryState("state", parseAsStringLiteral(ALL_STATES)) + const [state] = useQueryState("state", parseAsStringLiteral(LEARNING_STATES.map(ls => ls.value))) + const toLearnCount = personalLinks.filter(link => link?.learningState === "wantToLearn").length const learningCount = personalLinks.filter(link => link?.learningState === "learning").length const learnedCount = personalLinks.filter(link => link?.learningState === "learned").length + const isActive = (checkState: string) => { + return pathname === "/links" && state === checkState + } + return (
- - + +
) } @@ -104,7 +102,10 @@ const ListItem: React.FC = ({ label, href, count, isActive }) =>

{label}