gradient-forge 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/index.mjs +66 -16
- package/package.json +1 -1
package/cli/index.mjs
CHANGED
|
@@ -164,23 +164,61 @@ const promptSelect = async (title, items, defaultIndex = 0) => {
|
|
|
164
164
|
});
|
|
165
165
|
};
|
|
166
166
|
|
|
167
|
-
// Generate CSS
|
|
167
|
+
// Generate CSS - with !important to override tailwind defaults
|
|
168
168
|
const generateCSS = (themeId, mode) => {
|
|
169
169
|
const tokens = getThemeTokens(themeId);
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
const isDark = mode === "dark";
|
|
171
|
+
|
|
172
|
+
return `/* Gradient Forge Theme - ${mode} */
|
|
173
|
+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
|
|
174
|
+
|
|
175
|
+
:root {
|
|
176
|
+
--font-sans: 'Inter', sans-serif;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/* Theme CSS Variables */
|
|
180
|
+
.${themeId},
|
|
181
|
+
.${themeId} body {
|
|
172
182
|
${Object.entries(tokens).map(([k, v]) => ` ${k}: ${v};`).join("\n")}
|
|
173
183
|
}
|
|
174
184
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
185
|
+
/* Force theme override with !important */
|
|
186
|
+
.${themeId} {
|
|
187
|
+
--background: ${tokens["--background"]} !important;
|
|
188
|
+
--foreground: ${tokens["--foreground"]} !important;
|
|
189
|
+
--primary: ${tokens["--primary"]} !important;
|
|
190
|
+
--primary-foreground: ${tokens["--primary-foreground"]} !important;
|
|
191
|
+
--secondary: ${tokens["--secondary"]} !important;
|
|
192
|
+
--secondary-foreground: ${tokens["--secondary-foreground"]} !important;
|
|
193
|
+
--muted: ${tokens["--muted"]} !important;
|
|
194
|
+
--muted-foreground: ${tokens["--muted-foreground"]} !important;
|
|
195
|
+
--accent: ${tokens["--accent"]} !important;
|
|
196
|
+
--accent-foreground: ${tokens["--accent-foreground"]} !important;
|
|
197
|
+
--destructive: ${tokens["--destructive"]} !important;
|
|
198
|
+
--destructive-foreground: ${tokens["--destructive-foreground"]} !important;
|
|
199
|
+
--border: ${tokens["--border"]} !important;
|
|
200
|
+
--card: ${tokens["--card"]} !important;
|
|
201
|
+
--card-foreground: ${tokens["--card-foreground"]} !important;
|
|
202
|
+
--popover: ${tokens["--popover"]} !important;
|
|
203
|
+
--popover-foreground: ${tokens["--popover-foreground"]} !important;
|
|
204
|
+
--input: ${tokens["--input"]} !important;
|
|
205
|
+
--ring: ${tokens["--ring"]} !important;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/* Apply gradient background */
|
|
209
|
+
.${themeId} body {
|
|
210
|
+
background: linear-gradient(160deg, hsl(${tokens["--background"]}) 0%, hsl(${tokens["--background"]}) 50%, hsl(${tokens["--background"]}) 100%);
|
|
211
|
+
background-attachment: fixed;
|
|
178
212
|
}
|
|
179
213
|
|
|
180
|
-
|
|
181
|
-
|
|
214
|
+
/* Surface layers with glassmorphism */
|
|
215
|
+
.${themeId} .bg-card,
|
|
216
|
+
.${themeId} .bg-popover,
|
|
217
|
+
.${themeId} .bg-sidebar {
|
|
218
|
+
background-color: hsl(${tokens["--card"]} / 0.4) !important;
|
|
182
219
|
background-image: linear-gradient(${tokens["--app-surface-tint"]}, ${tokens["--app-surface-tint"]});
|
|
183
220
|
backdrop-filter: blur(16px);
|
|
221
|
+
border: 1px solid hsl(${tokens["--border"]} / 0.3);
|
|
184
222
|
}
|
|
185
223
|
`;
|
|
186
224
|
};
|
|
@@ -268,12 +306,14 @@ const setupNextJs = (projectRoot, themeId, mode) => {
|
|
|
268
306
|
fs.writeFileSync(contextPath, generateContext(themeId, mode));
|
|
269
307
|
logSuccess(`Created: components/theme/theme-context.tsx`);
|
|
270
308
|
|
|
271
|
-
// Inject into globals.css
|
|
309
|
+
// Inject into globals.css - add AFTER tailwind imports so theme overrides tailwind
|
|
272
310
|
const globalsPath = path.join(appDir, "globals.css");
|
|
273
311
|
if (fs.existsSync(globalsPath)) {
|
|
274
|
-
|
|
312
|
+
let content = fs.readFileSync(globalsPath, "utf8");
|
|
275
313
|
if (!content.includes("gradient-forge.css")) {
|
|
276
|
-
|
|
314
|
+
// Add at the end after all tailwind imports
|
|
315
|
+
content = content + '\n@import "./gradient-forge.css";';
|
|
316
|
+
fs.writeFileSync(globalsPath, content);
|
|
277
317
|
logSuccess(`Injected into: app/globals.css`);
|
|
278
318
|
}
|
|
279
319
|
}
|
|
@@ -290,12 +330,22 @@ const setupNextJs = (projectRoot, themeId, mode) => {
|
|
|
290
330
|
content = importStmt + "\n" + content;
|
|
291
331
|
}
|
|
292
332
|
|
|
293
|
-
// Wrap body -
|
|
294
|
-
content = content.replace(/(<body[^>]*>)
|
|
295
|
-
|
|
333
|
+
// Wrap body - keep existing className and add ThemeProvider around children
|
|
334
|
+
content = content.replace(/(<body[^>]*>)([\s\S]*?)(<\/body>)/,
|
|
335
|
+
'$1<ThemeProvider>$2</ThemeProvider>$3');
|
|
296
336
|
|
|
297
|
-
// Add classes to html - preserve existing
|
|
298
|
-
|
|
337
|
+
// Add theme classes to html - preserve existing className and add theme classes
|
|
338
|
+
if (content.includes('className=')) {
|
|
339
|
+
// For JSX className={expression}, add theme classes to the expression
|
|
340
|
+
content = content.replace(
|
|
341
|
+
/(className=\{)([^}]+)(\})/,
|
|
342
|
+
`$1$2 + " ${mode} ${themeId}"$3`
|
|
343
|
+
);
|
|
344
|
+
} else {
|
|
345
|
+
// For plain html or no className, add className attribute
|
|
346
|
+
content = content.replace(/<html/,
|
|
347
|
+
`<html className="${mode} ${themeId}" data-theme="${themeId}" data-color-mode="${mode}"`);
|
|
348
|
+
}
|
|
299
349
|
|
|
300
350
|
fs.writeFileSync(layoutPath, content);
|
|
301
351
|
logSuccess(`Updated: app/layout.tsx`);
|