a tool for shared writing and social publishing

handle setting basicTheme on create/update pubs

+40 -8
+8
app/lish/createPub/createPublication.ts
··· 16 16 import { isProductionDomain } from "src/utils/isProductionDeployment"; 17 17 import { string } from "zod"; 18 18 import { getPublicationType } from "src/utils/collectionHelpers"; 19 + import { PubThemeDefaultsRGB } from "components/ThemeManager/themeDefaults"; 19 20 20 21 const VERCEL_TOKEN = process.env.VERCEL_TOKEN; 21 22 const vercel = new Vercel({ ··· 94 95 url, 95 96 ...(description && { description }), 96 97 ...(iconBlob && { icon: iconBlob }), 98 + basicTheme: { 99 + $type: "site.standard.theme.basic", 100 + background: { $type: "site.standard.theme.color#rgb", ...PubThemeDefaultsRGB.background }, 101 + foreground: { $type: "site.standard.theme.color#rgb", ...PubThemeDefaultsRGB.foreground }, 102 + accent: { $type: "site.standard.theme.color#rgb", ...PubThemeDefaultsRGB.accent }, 103 + accentForeground: { $type: "site.standard.theme.color#rgb", ...PubThemeDefaultsRGB.accentForeground }, 104 + }, 97 105 preferences: { 98 106 showInDiscover: preferences.showInDiscover, 99 107 showComments: preferences.showComments,
+10
app/lish/createPub/updatePublication.ts
··· 314 314 }, 315 315 }; 316 316 317 + // Derive basicTheme from the theme colors for site.standard.publication 318 + const basicTheme: NormalizedPublication["basicTheme"] = { 319 + $type: "site.standard.theme.basic", 320 + background: { $type: "site.standard.theme.color#rgb", r: theme.backgroundColor.r, g: theme.backgroundColor.g, b: theme.backgroundColor.b }, 321 + foreground: { $type: "site.standard.theme.color#rgb", r: theme.primary.r, g: theme.primary.g, b: theme.primary.b }, 322 + accent: { $type: "site.standard.theme.color#rgb", r: theme.accentBackground.r, g: theme.accentBackground.g, b: theme.accentBackground.b }, 323 + accentForeground: { $type: "site.standard.theme.color#rgb", r: theme.accentText.r, g: theme.accentText.g, b: theme.accentText.b }, 324 + }; 325 + 317 326 return buildRecord(normalizedPub, existingBasePath, publicationType, { 318 327 theme: themeData, 328 + basicTheme, 319 329 }); 320 330 }); 321 331 }
+1 -8
components/ThemeManager/PublicationThemeProvider.tsx
··· 11 11 useNormalizedPublicationRecord, 12 12 } from "app/lish/[did]/[publication]/dashboard/PublicationSWRProvider"; 13 13 import { blobRefToSrc } from "src/utils/blobRefToSrc"; 14 - 15 - const PubThemeDefaults = { 16 - backgroundColor: "#FDFCFA", 17 - pageBackground: "#FDFCFA", 18 - primary: "#272727", 19 - accentText: "#FFFFFF", 20 - accentBackground: "#0000FF", 21 - }; 14 + import { PubThemeDefaults } from "./themeDefaults"; 22 15 23 16 // Default page background for standalone leaflets (matches editor default) 24 17 const StandalonePageBackground = "#FFFFFF";
+21
components/ThemeManager/themeDefaults.ts
··· 1 + /** 2 + * Default theme values for publications. 3 + * Shared between client and server code. 4 + */ 5 + 6 + // Hex color defaults 7 + export const PubThemeDefaults = { 8 + backgroundColor: "#FDFCFA", 9 + pageBackground: "#FDFCFA", 10 + primary: "#272727", 11 + accentText: "#FFFFFF", 12 + accentBackground: "#0000FF", 13 + } as const; 14 + 15 + // RGB color defaults (parsed from hex values above) 16 + export const PubThemeDefaultsRGB = { 17 + background: { r: 253, g: 252, b: 250 }, // #FDFCFA 18 + foreground: { r: 39, g: 39, b: 39 }, // #272727 19 + accent: { r: 0, g: 0, b: 255 }, // #0000FF 20 + accentForeground: { r: 255, g: 255, b: 255 }, // #FFFFFF 21 + } as const;