Skip to content

Commit 34ac7bc

Browse files
author
Rajat Saxena
committed
fixed font naming; padding migration; some safe side checks
1 parent 74fe281 commit 34ac7bc

4 files changed

Lines changed: 357 additions & 36 deletions

File tree

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
/**
2+
* Run the following script OR use the following MongoDB command:
3+
* db.pages.updateMany({}, { $unset: { "layout.$[].settings.horizontalPadding": "", "layout.$[].settings.verticalPadding": "", "draftLayout.$[].settings.horizontalPadding": "", "draftLayout.$[].settings.verticalPadding": "" } })
4+
*/
5+
import mongoose from "mongoose";
6+
import { nanoid } from "nanoid";
7+
8+
function generateUniqueId() {
9+
return nanoid();
10+
}
11+
12+
mongoose.connect(process.env.DB_CONNECTION_STRING, {
13+
useNewUrlParser: true,
14+
useUnifiedTopology: true,
15+
});
16+
17+
const WidgetSchema = new mongoose.Schema({
18+
widgetId: { type: String, required: true, default: generateUniqueId },
19+
name: { type: String, required: true },
20+
deleteable: { type: Boolean, required: true, default: true },
21+
shared: { type: Boolean, required: true, default: false },
22+
settings: mongoose.Schema.Types.Mixed,
23+
});
24+
25+
const MediaSchema = new mongoose.Schema({
26+
mediaId: { type: String, required: true },
27+
originalFileName: { type: String, required: true },
28+
mimeType: { type: String, required: true },
29+
size: { type: Number, required: true },
30+
access: { type: String, required: true, enum: ["public", "private"] },
31+
thumbnail: String,
32+
caption: String,
33+
file: String,
34+
});
35+
36+
const PageSchema = new mongoose.Schema(
37+
{
38+
domain: { type: mongoose.Schema.Types.ObjectId, required: true },
39+
pageId: { type: String, required: true },
40+
type: {
41+
type: String,
42+
required: true,
43+
enum: ["product", "site", "blog", "community"],
44+
default: "product",
45+
},
46+
creatorId: { type: String, required: true },
47+
name: { type: String, required: true },
48+
layout: { type: [WidgetSchema], default: [] },
49+
draftLayout: { type: [WidgetSchema], default: [] },
50+
entityId: { type: String },
51+
deleteable: { type: Boolean, required: true, default: false },
52+
title: { type: String },
53+
description: String,
54+
socialImage: MediaSchema,
55+
robotsAllowed: { type: Boolean, default: true },
56+
draftTitle: String,
57+
draftDescription: String,
58+
draftSocialImage: MediaSchema,
59+
draftRobotsAllowed: Boolean,
60+
deleted: { type: Boolean, default: false },
61+
},
62+
{
63+
timestamps: true,
64+
},
65+
);
66+
67+
PageSchema.index(
68+
{
69+
domain: 1,
70+
pageId: 1,
71+
},
72+
{ unique: true },
73+
);
74+
75+
const Page = mongoose.model("Page", PageSchema);
76+
77+
const unsetPaddings = async (page) => {
78+
console.log(`Unsetting paddings for domain: ${page.domain}`);
79+
80+
// Update layout widgets
81+
if (page.layout && page.layout.length > 0) {
82+
page.layout.forEach((widget) => {
83+
if (widget.settings) {
84+
delete widget.settings.horizontalPadding;
85+
delete widget.settings.verticalPadding;
86+
}
87+
});
88+
}
89+
90+
// Update draftLayout widgets
91+
if (page.draftLayout && page.draftLayout.length > 0) {
92+
page.draftLayout.forEach((widget) => {
93+
if (widget.settings) {
94+
delete widget.settings.horizontalPadding;
95+
delete widget.settings.verticalPadding;
96+
}
97+
});
98+
}
99+
100+
page.markModified("layout");
101+
page.markModified("draftLayout");
102+
await page.save();
103+
console.log(`Updated paddings for domain: ${page.domain}\n`);
104+
};
105+
106+
const migratePaddings = async () => {
107+
const pages = await Page.find({});
108+
for (const page of pages) {
109+
try {
110+
await unsetPaddings(page);
111+
} catch (error) {
112+
console.error(`Error updating paddings for domain: ${page.domain}`);
113+
console.error(error);
114+
}
115+
}
116+
};
117+
118+
(async () => {
119+
await migratePaddings();
120+
mongoose.connection.close();
121+
})();

apps/web/lib/theme-styles.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@ function formatHSL(hsl: HSL): string {
66
}
77

88
export function generateThemeStyles(theme: Theme): string {
9-
const { colors } = theme.theme;
9+
const { colors } = theme?.theme;
10+
if (!colors) {
11+
return "";
12+
}
13+
1014
const lightColors = colors.light;
1115
const darkColors = colors.dark;
16+
if (!lightColors || !darkColors) {
17+
return "";
18+
}
1219

1320
return `
1421
:root {

packages/page-primitives/src/themes/classic.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,93 +93,93 @@ const themeStyles: ThemeStyle = {
9393
},
9494
typography: {
9595
preheader: {
96-
fontFamily: "font-sans",
96+
fontFamily: "font-inter",
9797
fontSize: "text-sm",
9898
fontWeight: "font-medium",
9999
lineHeight: "leading-normal",
100100
letterSpacing: "tracking-wide",
101101
textTransform: "uppercase",
102102
},
103103
header1: {
104-
fontFamily: "font-sans",
104+
fontFamily: "font-inter",
105105
fontSize: "text-4xl",
106106
fontWeight: "font-bold",
107107
lineHeight: "leading-tight",
108108
letterSpacing: "tracking-tight",
109109
},
110110
header2: {
111-
fontFamily: "font-sans",
111+
fontFamily: "font-inter",
112112
fontSize: "text-3xl",
113113
fontWeight: "font-bold",
114114
lineHeight: "leading-tight",
115115
letterSpacing: "tracking-tight",
116116
},
117117
header3: {
118-
fontFamily: "font-sans",
118+
fontFamily: "font-inter",
119119
fontSize: "text-2xl",
120120
fontWeight: "font-semibold",
121121
lineHeight: "leading-snug",
122122
letterSpacing: "tracking-normal",
123123
},
124124
header4: {
125-
fontFamily: "font-sans",
125+
fontFamily: "font-inter",
126126
fontSize: "text-xl",
127127
fontWeight: "font-semibold",
128128
lineHeight: "leading-snug",
129129
letterSpacing: "tracking-normal",
130130
},
131131
subheader1: {
132-
fontFamily: "font-sans",
132+
fontFamily: "font-inter",
133133
fontSize: "text-lg",
134134
fontWeight: "font-medium",
135135
lineHeight: "leading-relaxed",
136136
letterSpacing: "tracking-normal",
137137
},
138138
subheader2: {
139-
fontFamily: "font-sans",
139+
fontFamily: "font-inter",
140140
fontSize: "text-base",
141141
fontWeight: "font-medium",
142142
lineHeight: "leading-relaxed",
143143
letterSpacing: "tracking-normal",
144144
},
145145
text1: {
146-
fontFamily: "font-sans",
146+
fontFamily: "font-inter",
147147
fontSize: "text-base",
148148
fontWeight: "font-normal",
149149
lineHeight: "leading-relaxed",
150150
letterSpacing: "tracking-normal",
151151
},
152152
text2: {
153-
fontFamily: "font-sans",
153+
fontFamily: "font-inter",
154154
fontSize: "text-sm",
155155
fontWeight: "font-normal",
156156
lineHeight: "leading-relaxed",
157157
letterSpacing: "tracking-normal",
158158
},
159159
caption: {
160-
fontFamily: "font-sans",
160+
fontFamily: "font-inter",
161161
fontSize: "text-xs",
162162
fontWeight: "font-normal",
163163
lineHeight: "leading-relaxed",
164164
letterSpacing: "tracking-normal",
165165
},
166166
link: {
167-
fontFamily: "font-sans",
167+
fontFamily: "font-inter",
168168
fontSize: "text-base",
169169
fontWeight: "font-normal",
170170
lineHeight: "leading-relaxed",
171171
letterSpacing: "tracking-normal",
172172
textDecoration: "no-underline",
173173
},
174174
button: {
175-
fontFamily: "font-sans",
175+
fontFamily: "font-inter",
176176
fontSize: "text-base",
177177
fontWeight: "font-medium",
178178
lineHeight: "leading-normal",
179179
letterSpacing: "tracking-normal",
180180
},
181181
input: {
182-
fontFamily: "font-sans",
182+
fontFamily: "font-inter",
183183
fontSize: "text-sm",
184184
fontWeight: "font-normal",
185185
lineHeight: "leading-normal",

0 commit comments

Comments
 (0)