From ff2a421450c22eaaeac78ba5cd2101045af9da3a Mon Sep 17 00:00:00 2001 From: Jared Pereira Date: Wed, 26 Nov 2025 17:23:55 -0500 Subject: [PATCH] fix some standalone theme and canvas stuff --- .../[did]/[publication]/[rkey]/CanvasPage.tsx | 2 +- .../[rkey]/DocumentPageRenderer.tsx | 3 ++- .../[rkey]/LinearDocumentPage.tsx | 2 +- .../[did]/[publication]/[rkey]/PostPages.tsx | 23 +++++++++++++++---- .../ThemeManager/PublicationThemeProvider.tsx | 15 ++++++++++-- 5 files changed, 36 insertions(+), 9 deletions(-) diff --git a/app/lish/[did]/[publication]/[rkey]/CanvasPage.tsx b/app/lish/[did]/[publication]/[rkey]/CanvasPage.tsx index 32bccd2c..9d45e6b6 100644 --- a/app/lish/[did]/[publication]/[rkey]/CanvasPage.tsx +++ b/app/lish/[did]/[publication]/[rkey]/CanvasPage.tsx @@ -45,10 +45,10 @@ export function CanvasPage({ pageId, pageOptions, fullPageScroll, + hasPageBackground, } = props; if (!document) return null; - let hasPageBackground = !!theme?.showPageBackground; let isSubpage = !!pageId; let drawer = useDrawerOpen(document_uri); diff --git a/app/lish/[did]/[publication]/[rkey]/DocumentPageRenderer.tsx b/app/lish/[did]/[publication]/[rkey]/DocumentPageRenderer.tsx index b53b6383..6f7518fb 100644 --- a/app/lish/[did]/[publication]/[rkey]/DocumentPageRenderer.tsx +++ b/app/lish/[did]/[publication]/[rkey]/DocumentPageRenderer.tsx @@ -108,6 +108,7 @@ export async function DocumentPageRenderer({ let theme = pubRecord?.theme || record.theme || null; let pub_creator = document.documents_in_publications[0]?.publications?.identity_did || did; + let isStandalone = !pubRecord; let firstPage = record.pages[0]; @@ -121,7 +122,7 @@ export async function DocumentPageRenderer({ return ( - + { let page = record.pages.find( (p) => - (p as PubLeafletPagesLinearDocument.Main | PubLeafletPagesCanvas.Main) - .id === pageId, + ( + p as + | PubLeafletPagesLinearDocument.Main + | PubLeafletPagesCanvas.Main + ).id === pageId, ) as | PubLeafletPagesLinearDocument.Main | PubLeafletPagesCanvas.Main diff --git a/components/ThemeManager/PublicationThemeProvider.tsx b/components/ThemeManager/PublicationThemeProvider.tsx index 0429fb4e..b8ff543c 100644 --- a/components/ThemeManager/PublicationThemeProvider.tsx +++ b/components/ThemeManager/PublicationThemeProvider.tsx @@ -16,6 +16,9 @@ const PubThemeDefaults = { accentText: "#FFFFFF", accentBackground: "#0000FF", }; + +// Default page background for standalone leaflets (matches editor default) +const StandalonePageBackground = "#FFFFFF"; function parseThemeColor( c: PubLeafletThemeColor.Rgb | PubLeafletThemeColor.Rgba, ) { @@ -95,8 +98,9 @@ export function PublicationThemeProvider(props: { children: React.ReactNode; theme?: PubLeafletPublication.Record["theme"] | null; pub_creator: string; + isStandalone?: boolean; }) { - let colors = usePubTheme(props.theme); + let colors = usePubTheme(props.theme, props.isStandalone); return ( {props.children} @@ -106,10 +110,17 @@ export function PublicationThemeProvider(props: { export const usePubTheme = ( theme?: PubLeafletPublication.Record["theme"] | null, + isStandalone?: boolean, ) => { let bgLeaflet = useColor(theme, "backgroundColor"); let bgPage = useColor(theme, "pageBackground"); - bgPage = theme?.pageBackground ? bgPage : bgLeaflet; + // For standalone documents, use the editor default page background (#FFFFFF) + // For publications without explicit pageBackground, use bgLeaflet + if (isStandalone && !theme?.pageBackground) { + bgPage = parseColor(StandalonePageBackground); + } else if (theme && !theme.pageBackground) { + bgPage = bgLeaflet; + } let showPageBackground = theme?.showPageBackground; let primary = useColor(theme, "primary"); -- 2.51.2