tangled
alpha
login
or
join now
leaflet.pub
/
leaflet
289
fork
atom
a tool for shared writing and social publishing
289
fork
atom
overview
issues
28
pulls
pipelines
handle setting basicTheme on create/update pubs
awarm.space
1 month ago
999ef07c
9c45883f
+40
-8
4 changed files
expand all
collapse all
unified
split
app
lish
createPub
createPublication.ts
updatePublication.ts
components
ThemeManager
PublicationThemeProvider.tsx
themeDefaults.ts
+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
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
98
+
basicTheme: {
99
99
+
$type: "site.standard.theme.basic",
100
100
+
background: { $type: "site.standard.theme.color#rgb", ...PubThemeDefaultsRGB.background },
101
101
+
foreground: { $type: "site.standard.theme.color#rgb", ...PubThemeDefaultsRGB.foreground },
102
102
+
accent: { $type: "site.standard.theme.color#rgb", ...PubThemeDefaultsRGB.accent },
103
103
+
accentForeground: { $type: "site.standard.theme.color#rgb", ...PubThemeDefaultsRGB.accentForeground },
104
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
317
+
// Derive basicTheme from the theme colors for site.standard.publication
318
318
+
const basicTheme: NormalizedPublication["basicTheme"] = {
319
319
+
$type: "site.standard.theme.basic",
320
320
+
background: { $type: "site.standard.theme.color#rgb", r: theme.backgroundColor.r, g: theme.backgroundColor.g, b: theme.backgroundColor.b },
321
321
+
foreground: { $type: "site.standard.theme.color#rgb", r: theme.primary.r, g: theme.primary.g, b: theme.primary.b },
322
322
+
accent: { $type: "site.standard.theme.color#rgb", r: theme.accentBackground.r, g: theme.accentBackground.g, b: theme.accentBackground.b },
323
323
+
accentForeground: { $type: "site.standard.theme.color#rgb", r: theme.accentText.r, g: theme.accentText.g, b: theme.accentText.b },
324
324
+
};
325
325
+
317
326
return buildRecord(normalizedPub, existingBasePath, publicationType, {
318
327
theme: themeData,
328
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
14
-
15
15
-
const PubThemeDefaults = {
16
16
-
backgroundColor: "#FDFCFA",
17
17
-
pageBackground: "#FDFCFA",
18
18
-
primary: "#272727",
19
19
-
accentText: "#FFFFFF",
20
20
-
accentBackground: "#0000FF",
21
21
-
};
14
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
1
+
/**
2
2
+
* Default theme values for publications.
3
3
+
* Shared between client and server code.
4
4
+
*/
5
5
+
6
6
+
// Hex color defaults
7
7
+
export const PubThemeDefaults = {
8
8
+
backgroundColor: "#FDFCFA",
9
9
+
pageBackground: "#FDFCFA",
10
10
+
primary: "#272727",
11
11
+
accentText: "#FFFFFF",
12
12
+
accentBackground: "#0000FF",
13
13
+
} as const;
14
14
+
15
15
+
// RGB color defaults (parsed from hex values above)
16
16
+
export const PubThemeDefaultsRGB = {
17
17
+
background: { r: 253, g: 252, b: 250 }, // #FDFCFA
18
18
+
foreground: { r: 39, g: 39, b: 39 }, // #272727
19
19
+
accent: { r: 0, g: 0, b: 255 }, // #0000FF
20
20
+
accentForeground: { r: 255, g: 255, b: 255 }, // #FFFFFF
21
21
+
} as const;