From 76b1e08a9df49ab4808adf289d62b564001f150b Mon Sep 17 00:00:00 2001 From: celine Date: Sat, 31 Jan 2026 00:52:33 -0500 Subject: [PATCH] added pagetitle to looseleaf and pub, added shortcut if you only have one pub or looseleaf --- app/(home-pages)/home/HomeLayout.tsx | 62 +-------- .../looseleafs/LooseleafsLayout.tsx | 12 +- .../dashboard/PublicationDashboard.tsx | 15 +-- components/ActionBar/Publications.tsx | 118 +++++++++++++++++- components/PageHeader.tsx | 2 +- 5 files changed, 136 insertions(+), 73 deletions(-) diff --git a/app/(home-pages)/home/HomeLayout.tsx b/app/(home-pages)/home/HomeLayout.tsx index c8f834c4..95d22e60 100644 --- a/app/(home-pages)/home/HomeLayout.tsx +++ b/app/(home-pages)/home/HomeLayout.tsx @@ -29,12 +29,7 @@ import { HomeEmptyState, PublicationBanner, } from "./HomeEmpty/HomeEmpty"; -import { Popover } from "components/Popover"; -import { PubIcon, PublicationButtons } from "components/ActionBar/Publications"; -import { normalizePublicationRecord } from "src/utils/normalizeRecords"; -import { ButtonPrimary } from "components/Buttons"; -import { LooseLeafSmall } from "components/Icons/LooseleafSmall"; -import { HomeButton } from "components/ActionBar/NavigationButtons"; +import { PublicationNavigation } from "components/ActionBar/Publications"; export type Leaflet = { added_at: string; @@ -83,43 +78,6 @@ export const HomeLayout = (props: { (leaflet) => leaflet.archived === true, ).length > 0; - function getPubIcons() { - let hasLooseleafs = !!identity?.permission_token_on_homepage.find( - (f) => - f.permission_tokens.leaflets_to_documents && - f.permission_tokens.leaflets_to_documents[0]?.document, - ); - - if (identity && identity.publications.length >= 1) { - return ( -
- {identity.publications.map((pub, index) => { - if (index <= 3) - return ( - - ); - })} -
- ); - } - if (identity && hasLooseleafs) { - return ( -
- -
- ); - } else - return ( - - Create a Publication! - - ); - } - return ( {getPubIcons()}} - className="pt-1 px-2!" - > - -
- - - } + controls={} /> } /> @@ -268,7 +212,7 @@ export function LeafletList(props: { className={` leafletList w-full - ${display === "grid" ? "grid auto-rows-max md:grid-cols-4 sm:grid-cols-3 grid-cols-2 gap-y-4 gap-x-4 sm:gap-x-6 sm:gap-y-5 grow" : "flex flex-col gap-2 pt-2"} `} + ${display === "grid" ? "grid auto-rows-max md:grid-cols-4 sm:grid-cols-3 grid-cols-2 gap-y-4 gap-x-4 sm:gap-x-6 sm:gap-y-5 grow" : "flex flex-col gap-2"} `} > {props.leaflets.map(({ token: leaflet, added_at, archived }, index) => ( } + /> + } /> ); }; diff --git a/app/lish/[did]/[publication]/dashboard/PublicationDashboard.tsx b/app/lish/[did]/[publication]/dashboard/PublicationDashboard.tsx index af910e54..505092e4 100644 --- a/app/lish/[did]/[publication]/dashboard/PublicationDashboard.tsx +++ b/app/lish/[did]/[publication]/dashboard/PublicationDashboard.tsx @@ -13,8 +13,7 @@ import { } from "components/PageLayouts/DashboardLayout"; import { useDebouncedEffect } from "src/hooks/useDebouncedEffect"; import { type NormalizedPublication } from "src/utils/normalizeRecords"; -import { PublicationButtons } from "components/ActionBar/Publications"; -import { Popover } from "components/Popover"; +import { PublicationNavigation } from "components/ActionBar/Publications"; export default function PublicationDashboard({ publication, @@ -83,14 +82,10 @@ export default function PublicationDashboard({ pubs} className="pt-1 px-2!"> - - + } /> } diff --git a/components/ActionBar/Publications.tsx b/components/ActionBar/Publications.tsx index f0b87d0d..1a98dd9f 100644 --- a/components/ActionBar/Publications.tsx +++ b/components/ActionBar/Publications.tsx @@ -15,12 +15,15 @@ import { SpeedyLink } from "components/SpeedyLink"; import { PublishSmall } from "components/Icons/PublishSmall"; import { Popover } from "components/Popover"; import { BlueskyLogin } from "app/login/LoginForm"; -import { ButtonSecondary } from "components/Buttons"; +import { ButtonPrimary, ButtonSecondary } from "components/Buttons"; import { useIsMobile } from "src/hooks/isMobile"; import { useState } from "react"; import { LooseLeafSmall } from "components/Icons/LooseleafSmall"; -import type { navPages } from "./NavigationButtons"; +import { HomeButton, type navPages } from "./NavigationButtons"; import { AddTiny } from "components/Icons/AddTiny"; +import { HomeSmall } from "components/Icons/HomeSmall"; +import { HomeTiny } from "components/Icons/HomeTiny"; +import { LooseleafTiny } from "components/Icons/LooseleafTiny"; export const PublicationButtons = (props: { currentPage: navPages; @@ -225,6 +228,117 @@ export const PubIcon = (props: { ); }; +export const PublicationNavigation = (props: { + currentPage: navPages; + currentPubUri?: string; +}) => { + let { identity } = useIdentityData(); + + let hasLooseleafs = !!identity?.permission_token_on_homepage.find( + (f) => + f.permission_tokens.leaflets_to_documents && + f.permission_tokens.leaflets_to_documents[0]?.document, + ); + + let pubCount = identity?.publications.length ?? 0; + let onlyOnePub = pubCount === 1 && !hasLooseleafs; + let onlyLooseleafs = pubCount === 0 && hasLooseleafs; + + function getTriggerIcons() { + if (identity && pubCount >= 1) { + return ( +
+ {identity.publications.map((pub, index) => { + if (index <= 2) + return ( + + ); + })} +
+ ); + } + if (identity && hasLooseleafs) { + return ( +
+ +
+ ); + } else + return ( + + Create a Publication! + + ); + } + + // Single pub, no looseleafs - just link to that pub + if (onlyOnePub && identity) { + let pub = identity.publications[0]; + if (props.currentPage === "pub") + return ( + + Home + + ); + return ( + +
{pub.name}
+ +
+ ); + } + + // Only looseleafs, no pubs - just link to looseleafs + if (!onlyLooseleafs) { + if (props.currentPage === "looseleafs") + return ( + + Home + + ); + return ( + +
+ Looseleafs +
+
+ ); + } + + return ( + {getTriggerIcons()}} className="pt-1 px-2!"> + +
+ +
+ ); +}; + export const PubListEmptyIllo = () => { return ( {
-- 2.51.2