From 2cb5eff0f826d2b4a2818bbda662b07a73a866a2 Mon Sep 17 00:00:00 2001 From: celine Date: Sat, 31 Jan 2026 00:02:04 -0500 Subject: [PATCH] Added a page title to the home layout --- app/(home-pages)/home/HomeLayout.tsx | 64 +++++++++++++++++++ .../dashboard/PublicationDashboard.tsx | 18 ++++++ components/ActionBar/ActionButton.tsx | 2 +- components/ActionBar/DesktopNavigation.tsx | 12 ++-- components/ActionBar/NavigationButtons.tsx | 30 ++++----- components/ActionBar/Publications.tsx | 23 +++++-- components/PageLayouts/DashboardLayout.tsx | 22 ++++++- 7 files changed, 139 insertions(+), 32 deletions(-) diff --git a/app/(home-pages)/home/HomeLayout.tsx b/app/(home-pages)/home/HomeLayout.tsx index 7ba4b9b6..c8f834c4 100644 --- a/app/(home-pages)/home/HomeLayout.tsx +++ b/app/(home-pages)/home/HomeLayout.tsx @@ -18,6 +18,7 @@ import { DashboardLayout, DashboardState, useDashboardState, + PageTitle, } from "components/PageLayouts/DashboardLayout"; import { Actions } from "./Actions/Actions"; import { GetLeafletDataReturnType } from "app/api/rpc/[command]/get_leaflet_data"; @@ -28,6 +29,12 @@ 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"; export type Leaflet = { added_at: string; @@ -76,6 +83,43 @@ 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!" + > + +
+ + + } + /> + } /> ); }; diff --git a/app/lish/[did]/[publication]/dashboard/PublicationDashboard.tsx b/app/lish/[did]/[publication]/dashboard/PublicationDashboard.tsx index 184f4e25..af910e54 100644 --- a/app/lish/[did]/[publication]/dashboard/PublicationDashboard.tsx +++ b/app/lish/[did]/[publication]/dashboard/PublicationDashboard.tsx @@ -8,10 +8,13 @@ import { PublishedPostsList } from "./PublishedPostsLists"; import { PublicationSubscribers } from "./PublicationSubscribers"; import { DashboardLayout, + PageTitle, PublicationDashboardControls, } 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"; export default function PublicationDashboard({ publication, @@ -76,6 +79,21 @@ export default function PublicationDashboard({ actions={} currentPage="pub" publication={publication.uri} + pageTitle={ + pubs} className="pt-1 px-2!"> + + + } + /> + } /> ); } diff --git a/components/ActionBar/ActionButton.tsx b/components/ActionBar/ActionButton.tsx index fa7f210b..5355a62c 100644 --- a/components/ActionBar/ActionButton.tsx +++ b/components/ActionBar/ActionButton.tsx @@ -71,7 +71,7 @@ export const ActionButton = ( >
{icon}
{label}
{subtext && ( diff --git a/components/ActionBar/DesktopNavigation.tsx b/components/ActionBar/DesktopNavigation.tsx index 453aac63..b27cc7c6 100644 --- a/components/ActionBar/DesktopNavigation.tsx +++ b/components/ActionBar/DesktopNavigation.tsx @@ -8,6 +8,7 @@ import { } from "./NavigationButtons"; import { PublicationButtons } from "./Publications"; import { Sidebar } from "./Sidebar"; +import { LoginActionButton, LoginButton } from "components/LoginButton"; export const DesktopNavigation = (props: { currentPage: navPages; @@ -24,11 +25,14 @@ export const DesktopNavigation = (props: { props.currentPage === "pub"; return (
- {identity?.atp_did && ( - + + {identity?.atp_did ? ( - - )} + ) : ( + + )} + + { +export const HomeButton = (props: { + current?: boolean; + className?: string; +}) => { return ( } - label="Writer Home" - className={props.current ? "bg-bg-page! border-border-light!" : ""} + label="Write" + className={`${props.current ? "bg-bg-page! border-border-light!" : ""} ${props.className}`} /> ); @@ -82,14 +86,7 @@ export const WriterButton = (props: { nav labelOnMobile={true} icon={} - label=
- Writer - {current && ( - <> - {currentIcon} - - )} -
+ label=
Write
className={current ? "bg-bg-page! border-border-light!" : ""} /> ) : ( @@ -99,11 +96,6 @@ export const WriterButton = (props: { icon={ <> - {current && ( - <> - {currentIcon} - - )} } label=
Writer
@@ -116,7 +108,7 @@ export const WriterButton = (props: { } - label="Writer Home" + label="Write" className={ props.currentPage === "home" ? "bg-bg-page! border-border-light!" @@ -145,7 +137,7 @@ export const ReaderButton = (props: { nav labelOnMobile={props.compactOnMobile} icon={} - label="Reader" + label="Read" className={props.current ? "bg-bg-page! border-border-light!" : ""} /> diff --git a/components/ActionBar/Publications.tsx b/components/ActionBar/Publications.tsx index 7cc59f31..f0b87d0d 100644 --- a/components/ActionBar/Publications.tsx +++ b/components/ActionBar/Publications.tsx @@ -20,10 +20,13 @@ import { useIsMobile } from "src/hooks/isMobile"; import { useState } from "react"; import { LooseLeafSmall } from "components/Icons/LooseleafSmall"; import type { navPages } from "./NavigationButtons"; +import { AddTiny } from "components/Icons/AddTiny"; export const PublicationButtons = (props: { currentPage: navPages; currentPubUri: string | undefined; + className?: string; + optionClassName?: string; }) => { let { identity } = useIdentityData(); let hasLooseleafs = !!identity?.permission_token_on_homepage.find( @@ -38,12 +41,14 @@ export const PublicationButtons = (props: { return ; return ( -
+
{hasLooseleafs && ( <> {/*TODO How should i get if this is the current page or not? theres not "pub" to check the uri for. Do i need to add it as an option to NavPages? thats kinda annoying*/} @@ -51,11 +56,12 @@ export const PublicationButtons = (props: { label="Looseleafs" icon={} nav - className={ + className={`${ props.currentPage === "looseleafs" ? "bg-bg-page! border-border!" : "" } + ${props.optionClassName}`} /> @@ -68,14 +74,16 @@ export const PublicationButtons = (props: { key={d.uri} record={d.record} current={d.uri === props.currentPubUri} + className={props.optionClassName} /> ); })} - New +
+ New Publication
); @@ -86,6 +94,7 @@ export const PublicationOption = (props: { name: string; record: Json; current?: boolean; + className?: string; }) => { let record = normalizePublicationRecord(props.record); if (!record) return; @@ -93,13 +102,13 @@ export const PublicationOption = (props: { return ( } nav - className={props.current ? "bg-bg-page! border-border!" : ""} + className={`${props.current ? "bg-bg-page! border-border!" : ""} ${props.className}`} /> ); diff --git a/components/PageLayouts/DashboardLayout.tsx b/components/PageLayouts/DashboardLayout.tsx index 8096c2b0..c33256f5 100644 --- a/components/PageLayouts/DashboardLayout.tsx +++ b/components/PageLayouts/DashboardLayout.tsx @@ -27,6 +27,7 @@ import Link from "next/link"; import { ExternalLinkTiny } from "components/Icons/ExternalLinkTiny"; import { usePreserveScroll } from "src/hooks/usePreserveScroll"; import { Tab } from "components/Tab"; +import { PubIcon, PublicationButtons } from "components/ActionBar/Publications"; export type DashboardState = { display?: "grid" | "list"; @@ -141,6 +142,7 @@ export function DashboardLayout< publication?: string; profileDid?: string; actions: React.ReactNode; + pageTitle?: React.ReactNode; }) { const searchParams = useSearchParams(); const tabParam = searchParams.get("tab"); @@ -167,6 +169,7 @@ export function DashboardLayout< let [headerState, setHeaderState] = useState<"default" | "controls">( "default", ); + return (
+ {props.pageTitle} + {Object.keys(props.tabs).length <= 1 && !controls ? null : ( <>
@@ -256,6 +261,21 @@ export function DashboardLayout< ); } +export const PageTitle = (props: { + pageTitle: string; + controls: React.ReactNode; +}) => { + return ( + +

{props.pageTitle}

+
{props.controls}
+
+ ); +}; + export const HomeDashboardControls = (props: { searchValue: string; setSearchValueAction: (searchValue: string) => void; @@ -449,7 +469,7 @@ const SearchInput = (props: { className={`dashboardSearchInput appearance-none! outline-hidden! w-full min-w-0 text-primary relative pl-7 pr-1 -my-px - border rounded-md border-transparent focus-within:border-border + border rounded-md border-border-light focus-within:border-border bg-transparent ${props.hasBackgroundImage ? "focus-within:bg-bg-page" : "focus-within:bg-bg-leaflet"} `} type="text" id="pubName" -- 2.51.2