diff --git a/app/lish/createPub/createPublication.ts b/app/lish/createPub/createPublication.ts index 18ed3a9a..a705a0e6 100644 --- a/app/lish/createPub/createPublication.ts +++ b/app/lish/createPub/createPublication.ts @@ -16,6 +16,7 @@ import { Vercel } from "@vercel/sdk"; import { isProductionDomain } from "src/utils/isProductionDeployment"; import { string } from "zod"; import { getPublicationType } from "src/utils/collectionHelpers"; +import { PubThemeDefaultsRGB } from "components/ThemeManager/themeDefaults"; const VERCEL_TOKEN = process.env.VERCEL_TOKEN; const vercel = new Vercel({ @@ -94,6 +95,13 @@ export async function createPublication({ url, ...(description && { description }), ...(iconBlob && { icon: iconBlob }), + basicTheme: { + $type: "site.standard.theme.basic", + background: { $type: "site.standard.theme.color#rgb", ...PubThemeDefaultsRGB.background }, + foreground: { $type: "site.standard.theme.color#rgb", ...PubThemeDefaultsRGB.foreground }, + accent: { $type: "site.standard.theme.color#rgb", ...PubThemeDefaultsRGB.accent }, + accentForeground: { $type: "site.standard.theme.color#rgb", ...PubThemeDefaultsRGB.accentForeground }, + }, preferences: { showInDiscover: preferences.showInDiscover, showComments: preferences.showComments, diff --git a/app/lish/createPub/updatePublication.ts b/app/lish/createPub/updatePublication.ts index 44291293..81a87aa2 100644 --- a/app/lish/createPub/updatePublication.ts +++ b/app/lish/createPub/updatePublication.ts @@ -314,8 +314,18 @@ export async function updatePublicationTheme({ }, }; + // Derive basicTheme from the theme colors for site.standard.publication + const basicTheme: NormalizedPublication["basicTheme"] = { + $type: "site.standard.theme.basic", + background: { $type: "site.standard.theme.color#rgb", r: theme.backgroundColor.r, g: theme.backgroundColor.g, b: theme.backgroundColor.b }, + foreground: { $type: "site.standard.theme.color#rgb", r: theme.primary.r, g: theme.primary.g, b: theme.primary.b }, + accent: { $type: "site.standard.theme.color#rgb", r: theme.accentBackground.r, g: theme.accentBackground.g, b: theme.accentBackground.b }, + accentForeground: { $type: "site.standard.theme.color#rgb", r: theme.accentText.r, g: theme.accentText.g, b: theme.accentText.b }, + }; + return buildRecord(normalizedPub, existingBasePath, publicationType, { theme: themeData, + basicTheme, }); }); } diff --git a/components/ThemeManager/PublicationThemeProvider.tsx b/components/ThemeManager/PublicationThemeProvider.tsx index 33ab9579..48dfe2f4 100644 --- a/components/ThemeManager/PublicationThemeProvider.tsx +++ b/components/ThemeManager/PublicationThemeProvider.tsx @@ -11,14 +11,7 @@ import { useNormalizedPublicationRecord, } from "app/lish/[did]/[publication]/dashboard/PublicationSWRProvider"; import { blobRefToSrc } from "src/utils/blobRefToSrc"; - -const PubThemeDefaults = { - backgroundColor: "#FDFCFA", - pageBackground: "#FDFCFA", - primary: "#272727", - accentText: "#FFFFFF", - accentBackground: "#0000FF", -}; +import { PubThemeDefaults } from "./themeDefaults"; // Default page background for standalone leaflets (matches editor default) const StandalonePageBackground = "#FFFFFF"; diff --git a/components/ThemeManager/themeDefaults.ts b/components/ThemeManager/themeDefaults.ts new file mode 100644 index 00000000..df775809 --- /dev/null +++ b/components/ThemeManager/themeDefaults.ts @@ -0,0 +1,21 @@ +/** + * Default theme values for publications. + * Shared between client and server code. + */ + +// Hex color defaults +export const PubThemeDefaults = { + backgroundColor: "#FDFCFA", + pageBackground: "#FDFCFA", + primary: "#272727", + accentText: "#FFFFFF", + accentBackground: "#0000FF", +} as const; + +// RGB color defaults (parsed from hex values above) +export const PubThemeDefaultsRGB = { + background: { r: 253, g: 252, b: 250 }, // #FDFCFA + foreground: { r: 39, g: 39, b: 39 }, // #272727 + accent: { r: 0, g: 0, b: 255 }, // #0000FF + accentForeground: { r: 255, g: 255, b: 255 }, // #FFFFFF +} as const;