@kilivi/payloadcms-theme-management 0.1.6 → 0.1.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.
Files changed (93) hide show
  1. package/README.md +97 -97
  2. package/dist/components/ServerThemeInjector.d.ts +1 -1
  3. package/dist/components/ServerThemeInjector.d.ts.map +1 -1
  4. package/dist/components/{ServerThemeInjector.jsx → ServerThemeInjector.js} +50 -37
  5. package/dist/components/ServerThemeInjector.js.map +1 -0
  6. package/dist/components/ThemePreview.js +318 -0
  7. package/dist/components/ThemePreview.js.map +1 -0
  8. package/dist/components/typographyPreviewUtils.js +12 -17
  9. package/dist/components/typographyPreviewUtils.js.map +1 -1
  10. package/dist/constants/themeFonts.js +94 -24
  11. package/dist/constants/themeFonts.js.map +1 -1
  12. package/dist/fields/ColorPickerField.js +332 -0
  13. package/dist/fields/ColorPickerField.js.map +1 -0
  14. package/dist/fields/RadiusField.js +174 -0
  15. package/dist/fields/RadiusField.js.map +1 -0
  16. package/dist/fields/ThemeColorPickerField.css +138 -138
  17. package/dist/fields/ThemeColorPickerField.js +163 -0
  18. package/dist/fields/ThemeColorPickerField.js.map +1 -0
  19. package/dist/fields/ThemePreviewField.js +558 -0
  20. package/dist/fields/ThemePreviewField.js.map +1 -0
  21. package/dist/fields/ThemeTokenSelectField.js +209 -0
  22. package/dist/fields/ThemeTokenSelectField.js.map +1 -0
  23. package/dist/fields/colorModeFields.js +167 -73
  24. package/dist/fields/colorModeFields.js.map +1 -1
  25. package/dist/fields/themeConfigurationField.d.ts +1 -1
  26. package/dist/fields/themeConfigurationField.d.ts.map +1 -1
  27. package/dist/fields/themeConfigurationField.js +227 -134
  28. package/dist/fields/themeConfigurationField.js.map +1 -1
  29. package/dist/index.d.ts +17 -16
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +52 -52
  32. package/dist/index.js.map +1 -1
  33. package/dist/payload-types.js +5 -5
  34. package/dist/payload-types.js.map +1 -1
  35. package/dist/plugin.d.ts +1 -2
  36. package/dist/plugin.d.ts.map +1 -1
  37. package/dist/plugin.js +2 -1
  38. package/dist/plugin.js.map +1 -1
  39. package/dist/presets.js +66 -65
  40. package/dist/presets.js.map +1 -1
  41. package/dist/providers/Theme/index.d.ts +1 -1
  42. package/dist/providers/Theme/index.d.ts.map +1 -1
  43. package/dist/providers/Theme/{index.jsx → index.js} +61 -31
  44. package/dist/providers/Theme/index.js.map +1 -0
  45. package/dist/providers/Theme/shared.d.ts +1 -1
  46. package/dist/providers/Theme/shared.d.ts.map +1 -1
  47. package/dist/providers/Theme/shared.js +34 -9
  48. package/dist/providers/Theme/shared.js.map +1 -1
  49. package/dist/providers/Theme/themeConfig.d.ts +1 -1
  50. package/dist/providers/Theme/themeConfig.d.ts.map +1 -1
  51. package/dist/providers/Theme/themeConfig.js +37 -36
  52. package/dist/providers/Theme/themeConfig.js.map +1 -1
  53. package/dist/providers/Theme/types.js +15 -13
  54. package/dist/providers/Theme/types.js.map +1 -1
  55. package/dist/server.d.ts +2 -2
  56. package/dist/server.d.ts.map +1 -1
  57. package/dist/server.js +3 -2
  58. package/dist/server.js.map +1 -1
  59. package/dist/src/--verbose/dist/fields/ThemeColorPickerField.scss +138 -0
  60. package/dist/src/dist/fields/ThemeColorPickerField.scss +138 -0
  61. package/dist/types.d.ts +2 -2
  62. package/dist/types.d.ts.map +1 -1
  63. package/dist/types.js +2 -1
  64. package/dist/types.js.map +1 -1
  65. package/dist/utils/resolveThemeConfiguration.d.ts +3 -3
  66. package/dist/utils/resolveThemeConfiguration.d.ts.map +1 -1
  67. package/dist/utils/resolveThemeConfiguration.js +53 -34
  68. package/dist/utils/resolveThemeConfiguration.js.map +1 -1
  69. package/dist/utils/themeAssets.d.ts +1 -1
  70. package/dist/utils/themeAssets.d.ts.map +1 -1
  71. package/dist/utils/themeAssets.js +4 -4
  72. package/dist/utils/themeAssets.js.map +1 -1
  73. package/dist/utils/themeColors.js +95 -41
  74. package/dist/utils/themeColors.js.map +1 -1
  75. package/dist/utils/themeUtils.d.ts +2 -2
  76. package/dist/utils/themeUtils.d.ts.map +1 -1
  77. package/dist/utils/themeUtils.js +38 -53
  78. package/dist/utils/themeUtils.js.map +1 -1
  79. package/package.json +13 -5
  80. package/dist/components/ServerThemeInjector.jsx.map +0 -1
  81. package/dist/components/ThemePreview.jsx +0 -231
  82. package/dist/components/ThemePreview.jsx.map +0 -1
  83. package/dist/fields/ColorPickerField.jsx +0 -205
  84. package/dist/fields/ColorPickerField.jsx.map +0 -1
  85. package/dist/fields/RadiusField.jsx +0 -123
  86. package/dist/fields/RadiusField.jsx.map +0 -1
  87. package/dist/fields/ThemeColorPickerField.jsx +0 -110
  88. package/dist/fields/ThemeColorPickerField.jsx.map +0 -1
  89. package/dist/fields/ThemePreviewField.jsx +0 -420
  90. package/dist/fields/ThemePreviewField.jsx.map +0 -1
  91. package/dist/fields/ThemeTokenSelectField.jsx +0 -151
  92. package/dist/fields/ThemeTokenSelectField.jsx.map +0 -1
  93. package/dist/providers/Theme/index.jsx.map +0 -1
package/README.md CHANGED
@@ -1,97 +1,97 @@
1
- # Theme Configuration Plugin for Payload CMS
2
-
3
- A flexible theme configuration plugin for Payload CMS v3 that allows you to manage theme settings through the admin UI.
4
-
5
- ## Features
6
-
7
- - 🎨 **Theme Management** - Configure primary and secondary colors
8
- - 🔤 **Typography Control** - Set custom font families
9
- - 📐 **Layout Settings** - Adjust header height and other layout properties
10
- - 🌓 **Theme Switcher** - Optional theme switching capability (light/dark/auto)
11
- - ⚙️ **Configurable** - Exclude specific collections or globals as needed
12
-
13
- ## Installation
14
-
15
- ```bash
16
- npm install @payloadcms-plugins/theme-management
17
- # or
18
- yarn add @payloadcms-plugins/theme-management
19
- # or
20
- pnpm add @payloadcms-plugins/theme-management
21
- ```
22
-
23
- ## Usage
24
-
25
- Add the plugin to your Payload config:
26
-
27
- ```typescript
28
- import { buildConfig } from 'payload';
29
- import { ThemeConfigurationPlugin } from '@payloadcms-plugins/theme-management';
30
-
31
- export default buildConfig({
32
- // ... other config
33
- plugins: [
34
- ThemeConfigurationPlugin({
35
- enableThemeSwitcher: true,
36
- defaultTheme: 'auto',
37
- excludedCollections: [], // Collections to exclude
38
- excludedGlobals: [], // Globals to exclude
39
- }),
40
- ],
41
- });
42
- ```
43
-
44
- ## Configuration Options
45
-
46
- ### `ThemeConfigurationPluginConfig`
47
-
48
- | Option | Type | Default | Description |
49
- |--------|------|---------|-------------|
50
- | `excludedCollections` | `string[]` | `[]` | Array of collection slugs to exclude |
51
- | `excludedGlobals` | `string[]` | `[]` | Array of global slugs to exclude |
52
- | `enableThemeSwitcher` | `boolean` | `true` | Enable theme switcher in admin UI |
53
- | `defaultTheme` | `'light' \| 'dark' \| 'auto'` | `'auto'` | Default theme |
54
-
55
- ## Theme Configuration Fields
56
-
57
- The plugin adds a global called `theme-management` with the following fields:
58
-
59
- - **Primary Color** - Main theme color (e.g., #3B82F6)
60
- - **Secondary Color** - Secondary theme color (e.g., #10B981)
61
- - **Font Family** - Primary font family for the site
62
- - **Header Height** - Height of the site header in pixels
63
-
64
- ## Accessing Theme Configuration
65
-
66
- You can access the theme configuration in your application:
67
-
68
- ```typescript
69
- const payload = await getPayloadClient();
70
-
71
- const themeConfig = await payload.findGlobal({
72
- slug: 'theme-management',
73
- });
74
-
75
- console.log(themeConfig.primaryColor); // e.g., "#3B82F6"
76
- ```
77
-
78
- ## Development
79
-
80
- ```bash
81
- # Install dependencies
82
- pnpm install
83
-
84
- # Build the plugin
85
- pnpm build
86
-
87
- # Watch mode for development
88
- pnpm dev
89
- ```
90
-
91
- ## License
92
-
93
- Apache-2.0
94
-
95
- ## Contributing
96
-
97
- Contributions are welcome! Please feel free to submit a Pull Request.
1
+ # Theme Configuration Plugin for Payload CMS
2
+
3
+ A flexible theme configuration plugin for Payload CMS v3 that allows you to manage theme settings through the admin UI.
4
+
5
+ ## Features
6
+
7
+ - 🎨 **Theme Management** - Configure primary and secondary colors
8
+ - 🔤 **Typography Control** - Set custom font families
9
+ - 📐 **Layout Settings** - Adjust header height and other layout properties
10
+ - 🌓 **Theme Switcher** - Optional theme switching capability (light/dark/auto)
11
+ - ⚙️ **Configurable** - Exclude specific collections or globals as needed
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm install @payloadcms-plugins/theme-management
17
+ # or
18
+ yarn add @payloadcms-plugins/theme-management
19
+ # or
20
+ pnpm add @payloadcms-plugins/theme-management
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ Add the plugin to your Payload config:
26
+
27
+ ```typescript
28
+ import { buildConfig } from 'payload';
29
+ import { ThemeConfigurationPlugin } from '@payloadcms-plugins/theme-management';
30
+
31
+ export default buildConfig({
32
+ // ... other config
33
+ plugins: [
34
+ ThemeConfigurationPlugin({
35
+ enableThemeSwitcher: true,
36
+ defaultTheme: 'auto',
37
+ excludedCollections: [], // Collections to exclude
38
+ excludedGlobals: [], // Globals to exclude
39
+ }),
40
+ ],
41
+ });
42
+ ```
43
+
44
+ ## Configuration Options
45
+
46
+ ### `ThemeConfigurationPluginConfig`
47
+
48
+ | Option | Type | Default | Description |
49
+ |--------|------|---------|-------------|
50
+ | `excludedCollections` | `string[]` | `[]` | Array of collection slugs to exclude |
51
+ | `excludedGlobals` | `string[]` | `[]` | Array of global slugs to exclude |
52
+ | `enableThemeSwitcher` | `boolean` | `true` | Enable theme switcher in admin UI |
53
+ | `defaultTheme` | `'light' \| 'dark' \| 'auto'` | `'auto'` | Default theme |
54
+
55
+ ## Theme Configuration Fields
56
+
57
+ The plugin adds a global called `theme-management` with the following fields:
58
+
59
+ - **Primary Color** - Main theme color (e.g., #3B82F6)
60
+ - **Secondary Color** - Secondary theme color (e.g., #10B981)
61
+ - **Font Family** - Primary font family for the site
62
+ - **Header Height** - Height of the site header in pixels
63
+
64
+ ## Accessing Theme Configuration
65
+
66
+ You can access the theme configuration in your application:
67
+
68
+ ```typescript
69
+ const payload = await getPayloadClient();
70
+
71
+ const themeConfig = await payload.findGlobal({
72
+ slug: 'theme-management',
73
+ });
74
+
75
+ console.log(themeConfig.primaryColor); // e.g., "#3B82F6"
76
+ ```
77
+
78
+ ## Development
79
+
80
+ ```bash
81
+ # Install dependencies
82
+ pnpm install
83
+
84
+ # Build the plugin
85
+ pnpm build
86
+
87
+ # Watch mode for development
88
+ pnpm dev
89
+ ```
90
+
91
+ ## License
92
+
93
+ Apache-2.0
94
+
95
+ ## Contributing
96
+
97
+ Contributions are welcome! Please feel free to submit a Pull Request.
@@ -1,4 +1,4 @@
1
- import type { SiteSetting } from '@/payload-types';
1
+ import type { SiteSetting } from '../payload-types.js';
2
2
  interface ServerThemeInjectorProps {
3
3
  siteSettings: SiteSetting | null;
4
4
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ServerThemeInjector.d.ts","sourceRoot":"","sources":["../../src/components/ServerThemeInjector.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAalD,UAAU,wBAAwB;IAChC,YAAY,EAAE,WAAW,GAAG,IAAI,CAAA;CACjC;AAMD;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,EAAE,YAAY,EAAE,EAAE,QAAQ,CAAC,wBAAwB,CAAC,wCA0F7F"}
1
+ {"version":3,"file":"ServerThemeInjector.d.ts","sourceRoot":"","sources":["../../src/components/ServerThemeInjector.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAatD,UAAU,wBAAwB;IAChC,YAAY,EAAE,WAAW,GAAG,IAAI,CAAA;CACjC;AAMD;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,EAAE,YAAY,EAAE,EAAE,QAAQ,CAAC,wBAAwB,CAAC,wCA0F7F"}
@@ -1,16 +1,18 @@
1
- import { getBorderRadiusConfig } from '@/providers/Theme/themeConfig';
2
- import { resolveThemeConfiguration } from '../utils/resolveThemeConfiguration';
3
- import { createFallbackCriticalCSS, getThemeCriticalCSS, getThemeCSSPath, } from '../utils/themeAssets';
4
- import { generateThemeColorsCss } from '../utils/themeColors';
5
- import { generateThemeCSS } from '../utils/themeUtils';
6
- /**
7
- * Server-side theme CSS injector to prevent FOUC
8
- * This component injects critical theme CSS directly into the HTML head during SSR
9
- */
10
- export async function ServerThemeInjector({ siteSettings }) {
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { getBorderRadiusConfig } from '../providers/Theme/themeConfig.js';
3
+ import { resolveThemeConfiguration } from '../utils/resolveThemeConfiguration.js';
4
+ import { createFallbackCriticalCSS, getThemeCriticalCSS, getThemeCSSPath } from '../utils/themeAssets.js';
5
+ import { generateThemeColorsCss } from '../utils/themeColors.js';
6
+ import { generateThemeCSS } from '../utils/themeUtils.js';
7
+ /**
8
+ * Server-side theme CSS injector to prevent FOUC
9
+ * This component injects critical theme CSS directly into the HTML head during SSR
10
+ */ export async function ServerThemeInjector({ siteSettings }) {
11
11
  const resolvedConfiguration = resolveThemeConfiguration(siteSettings?.themeConfiguration);
12
- const { theme, borderRadius, customCSS, lightMode, darkMode, fontScale, spacing, animationLevel, allowColorModeToggle, colorMode, typography, } = resolvedConfiguration;
13
- const baseThemeConfiguration = { ...(siteSettings?.themeConfiguration ?? {}) };
12
+ const { theme, borderRadius, customCSS, lightMode, darkMode, fontScale, spacing, animationLevel, allowColorModeToggle, colorMode, typography } = resolvedConfiguration;
13
+ const baseThemeConfiguration = {
14
+ ...siteSettings?.themeConfiguration ?? {}
15
+ };
14
16
  if ('typography' in baseThemeConfiguration) {
15
17
  delete baseThemeConfiguration.typography;
16
18
  }
@@ -26,7 +28,7 @@ export async function ServerThemeInjector({ siteSettings }) {
26
28
  customCSS: customCSS ?? undefined,
27
29
  lightMode,
28
30
  darkMode,
29
- typography: typography ?? undefined,
31
+ typography: typography ?? undefined
30
32
  };
31
33
  let criticalCSS = await getThemeCriticalCSS(theme);
32
34
  criticalCSS ??= createFallbackCriticalCSS(theme);
@@ -36,40 +38,51 @@ export async function ServerThemeInjector({ siteSettings }) {
36
38
  medium: 'medium',
37
39
  large: 'large',
38
40
  xl: 'xl',
39
- full: 'xl',
41
+ full: 'xl'
40
42
  };
41
43
  const mappedBorderRadius = borderRadiusMap[borderRadius ?? 'medium'] ?? 'medium';
42
44
  const borderRadiusConfig = getBorderRadiusConfig(mappedBorderRadius);
43
- const cssRecord = typeof borderRadiusConfig?.css === 'string'
44
- ? { '--radius-default': borderRadiusConfig.css }
45
- : borderRadiusConfig?.css ?? {};
46
- const borderRadiusCSS = Object.entries(cssRecord)
47
- .map(([property, value]) => ` ${property}: ${value};`)
48
- .join('\n');
49
- const borderRadiusBlock = borderRadiusCSS
50
- ? `:root {
45
+ const cssRecord = typeof borderRadiusConfig?.css === 'string' ? {
46
+ '--radius-default': borderRadiusConfig.css
47
+ } : borderRadiusConfig?.css ?? {};
48
+ const borderRadiusCSS = Object.entries(cssRecord).map(([property, value])=>` ${property}: ${value};`).join('\n');
49
+ const borderRadiusBlock = borderRadiusCSS ? `:root {
51
50
  ${borderRadiusCSS}
52
- }`
53
- : '';
51
+ }` : '';
54
52
  const themeConfigurationCSS = generateThemeCSS(normalizedThemeConfiguration);
55
- const colorModesCSS = generateThemeColorsCss({ themeName: theme, lightMode, darkMode });
53
+ const colorModesCSS = generateThemeColorsCss({
54
+ themeName: theme,
55
+ lightMode,
56
+ darkMode
57
+ });
56
58
  const customCSSBlock = typeof customCSS === 'string' ? customCSS.trim() : '';
57
59
  const combinedCSS = [
58
60
  criticalCSS,
59
61
  borderRadiusBlock,
60
62
  themeConfigurationCSS,
61
63
  colorModesCSS,
62
- customCSSBlock,
63
- ]
64
- .filter((block) => Boolean(block?.trim?.().length))
65
- .join('\n\n');
64
+ customCSSBlock
65
+ ].filter((block)=>Boolean(block?.trim?.().length)).join('\n\n');
66
66
  const themeCSSPath = getThemeCSSPath(theme);
67
- return (<>
68
- <style id="theme-critical-css" dangerouslySetInnerHTML={{
69
- __html: combinedCSS,
70
- }}/>
71
- <link rel="preload" href={themeCSSPath} as="style"/>
72
- <link rel="stylesheet" href={themeCSSPath}/>
73
- </>);
67
+ return /*#__PURE__*/ _jsxs(_Fragment, {
68
+ children: [
69
+ /*#__PURE__*/ _jsx("style", {
70
+ id: "theme-critical-css",
71
+ dangerouslySetInnerHTML: {
72
+ __html: combinedCSS
73
+ }
74
+ }),
75
+ /*#__PURE__*/ _jsx("link", {
76
+ rel: "preload",
77
+ href: themeCSSPath,
78
+ as: "style"
79
+ }),
80
+ /*#__PURE__*/ _jsx("link", {
81
+ rel: "stylesheet",
82
+ href: themeCSSPath
83
+ })
84
+ ]
85
+ });
74
86
  }
75
- //# sourceMappingURL=ServerThemeInjector.jsx.map
87
+
88
+ //# sourceMappingURL=ServerThemeInjector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/ServerThemeInjector.tsx"],"sourcesContent":["import type { SiteSetting } from '../payload-types.js'\r\nimport { getBorderRadiusConfig } from '../providers/Theme/themeConfig.js'\r\nimport type { BorderRadiusPreset, ThemeDefaults } from '../providers/Theme/types.js'\r\nimport type { ThemeTypographyPreset } from '../presets.js'\r\nimport { resolveThemeConfiguration } from '../utils/resolveThemeConfiguration.js'\r\nimport {\r\n createFallbackCriticalCSS,\r\n getThemeCriticalCSS,\r\n getThemeCSSPath,\r\n} from '../utils/themeAssets.js'\r\nimport { generateThemeColorsCss } from '../utils/themeColors.js'\r\nimport { generateThemeCSS } from '../utils/themeUtils.js'\r\n\r\ninterface ServerThemeInjectorProps {\r\n siteSettings: SiteSetting | null\r\n}\r\n\r\ntype RuntimeThemeConfiguration = Omit<NonNullable<SiteSetting['themeConfiguration']>, 'typography'> & {\r\n typography?: ThemeTypographyPreset | null\r\n}\r\n\r\n/**\r\n * Server-side theme CSS injector to prevent FOUC\r\n * This component injects critical theme CSS directly into the HTML head during SSR\r\n */\r\nexport async function ServerThemeInjector({ siteSettings }: Readonly<ServerThemeInjectorProps>) {\r\n const resolvedConfiguration = resolveThemeConfiguration(siteSettings?.themeConfiguration)\r\n const {\r\n theme,\r\n borderRadius,\r\n customCSS,\r\n lightMode,\r\n darkMode,\r\n fontScale,\r\n spacing,\r\n animationLevel,\r\n allowColorModeToggle,\r\n colorMode,\r\n typography,\r\n } = resolvedConfiguration\r\n\r\n const baseThemeConfiguration = { ...(siteSettings?.themeConfiguration ?? {}) }\r\n if ('typography' in baseThemeConfiguration) {\r\n delete (baseThemeConfiguration as Record<string, unknown>).typography\r\n }\r\n\r\n const normalizedThemeConfiguration: RuntimeThemeConfiguration = {\r\n ...baseThemeConfiguration,\r\n theme,\r\n colorMode,\r\n allowColorModeToggle,\r\n borderRadius,\r\n fontScale,\r\n spacing,\r\n animationLevel,\r\n customCSS: customCSS ?? undefined,\r\n lightMode,\r\n darkMode,\r\n typography: typography ?? undefined,\r\n }\r\n\r\n let criticalCSS = await getThemeCriticalCSS(theme as ThemeDefaults)\r\n criticalCSS ??= createFallbackCriticalCSS(theme as ThemeDefaults)\r\n\r\n const borderRadiusMap: Record<string, BorderRadiusPreset> = {\r\n none: 'none',\r\n small: 'small',\r\n medium: 'medium',\r\n large: 'large',\r\n xl: 'xl',\r\n full: 'xl',\r\n }\r\n const mappedBorderRadius = borderRadiusMap[borderRadius ?? 'medium'] ?? 'medium'\r\n const borderRadiusConfig = getBorderRadiusConfig(mappedBorderRadius)\r\n const cssRecord = typeof borderRadiusConfig?.css === 'string'\r\n ? { '--radius-default': borderRadiusConfig.css }\r\n : borderRadiusConfig?.css ?? {}\r\n\r\n const borderRadiusCSS = Object.entries(cssRecord)\r\n .map(([property, value]) => ` ${property}: ${value};`)\r\n .join('\\n')\r\n\r\n const borderRadiusBlock = borderRadiusCSS\r\n ? `:root {\r\n${borderRadiusCSS}\r\n}`\r\n : ''\r\n\r\n const themeConfigurationCSS = generateThemeCSS(normalizedThemeConfiguration)\r\n const colorModesCSS = generateThemeColorsCss({ themeName: theme, lightMode, darkMode })\r\n const customCSSBlock = typeof customCSS === 'string' ? customCSS.trim() : ''\r\n\r\n const combinedCSS = [\r\n criticalCSS,\r\n borderRadiusBlock,\r\n themeConfigurationCSS,\r\n colorModesCSS,\r\n customCSSBlock,\r\n ]\r\n .filter((block) => Boolean(block?.trim?.().length))\r\n .join('\\n\\n')\r\n\r\n const themeCSSPath = getThemeCSSPath(theme as ThemeDefaults)\r\n return (\r\n <>\r\n <style\r\n id=\"theme-critical-css\"\r\n dangerouslySetInnerHTML={{\r\n __html: combinedCSS,\r\n }}\r\n />\r\n <link rel=\"preload\" href={themeCSSPath} as=\"style\" />\r\n <link rel=\"stylesheet\" href={themeCSSPath} />\r\n </>\r\n )\r\n}\r\n"],"names":["getBorderRadiusConfig","resolveThemeConfiguration","createFallbackCriticalCSS","getThemeCriticalCSS","getThemeCSSPath","generateThemeColorsCss","generateThemeCSS","ServerThemeInjector","siteSettings","resolvedConfiguration","themeConfiguration","theme","borderRadius","customCSS","lightMode","darkMode","fontScale","spacing","animationLevel","allowColorModeToggle","colorMode","typography","baseThemeConfiguration","normalizedThemeConfiguration","undefined","criticalCSS","borderRadiusMap","none","small","medium","large","xl","full","mappedBorderRadius","borderRadiusConfig","cssRecord","css","borderRadiusCSS","Object","entries","map","property","value","join","borderRadiusBlock","themeConfigurationCSS","colorModesCSS","themeName","customCSSBlock","trim","combinedCSS","filter","block","Boolean","length","themeCSSPath","style","id","dangerouslySetInnerHTML","__html","link","rel","href","as"],"mappings":";AACA,SAASA,qBAAqB,QAAQ,oCAAmC;AAGzE,SAASC,yBAAyB,QAAQ,wCAAuC;AACjF,SACEC,yBAAyB,EACzBC,mBAAmB,EACnBC,eAAe,QACV,0BAAyB;AAChC,SAASC,sBAAsB,QAAQ,0BAAyB;AAChE,SAASC,gBAAgB,QAAQ,yBAAwB;AAUzD;;;CAGC,GACD,OAAO,eAAeC,oBAAoB,EAAEC,YAAY,EAAsC;IAC5F,MAAMC,wBAAwBR,0BAA0BO,cAAcE;IACtE,MAAM,EACJC,KAAK,EACLC,YAAY,EACZC,SAAS,EACTC,SAAS,EACTC,QAAQ,EACRC,SAAS,EACTC,OAAO,EACPC,cAAc,EACdC,oBAAoB,EACpBC,SAAS,EACTC,UAAU,EACX,GAAGZ;IAEJ,MAAMa,yBAAyB;QAAE,GAAId,cAAcE,sBAAsB,CAAC,CAAC;IAAE;IAC7E,IAAI,gBAAgBY,wBAAwB;QAC1C,OAAO,AAACA,uBAAmDD,UAAU;IACvE;IAEA,MAAME,+BAA0D;QAC9D,GAAGD,sBAAsB;QACzBX;QACAS;QACAD;QACAP;QACAI;QACAC;QACAC;QACAL,WAAWA,aAAaW;QACxBV;QACAC;QACAM,YAAYA,cAAcG;IAC5B;IAEA,IAAIC,cAAc,MAAMtB,oBAAoBQ;IAC5Cc,gBAAgBvB,0BAA0BS;IAE1C,MAAMe,kBAAsD;QAC1DC,MAAM;QACNC,OAAO;QACPC,QAAQ;QACRC,OAAO;QACPC,IAAI;QACJC,MAAM;IACR;IACA,MAAMC,qBAAqBP,eAAe,CAACd,gBAAgB,SAAS,IAAI;IACxE,MAAMsB,qBAAqBlC,sBAAsBiC;IACjD,MAAME,YAAY,OAAOD,oBAAoBE,QAAQ,WACjD;QAAE,oBAAoBF,mBAAmBE,GAAG;IAAC,IAC7CF,oBAAoBE,OAAO,CAAC;IAEhC,MAAMC,kBAAkBC,OAAOC,OAAO,CAACJ,WACpCK,GAAG,CAAC,CAAC,CAACC,UAAUC,MAAM,GAAK,CAAC,EAAE,EAAED,SAAS,EAAE,EAAEC,MAAM,CAAC,CAAC,EACrDC,IAAI,CAAC;IAER,MAAMC,oBAAoBP,kBACtB,CAAC;AACP,EAAEA,gBAAgB;CACjB,CAAC,GACI;IAEJ,MAAMQ,wBAAwBvC,iBAAiBiB;IAC/C,MAAMuB,gBAAgBzC,uBAAuB;QAAE0C,WAAWpC;QAAOG;QAAWC;IAAS;IACrF,MAAMiC,iBAAiB,OAAOnC,cAAc,WAAWA,UAAUoC,IAAI,KAAK;IAE1E,MAAMC,cAAc;QAClBzB;QACAmB;QACAC;QACAC;QACAE;KACD,CACEG,MAAM,CAAC,CAACC,QAAUC,QAAQD,OAAOH,SAASK,SAC1CX,IAAI,CAAC;IAER,MAAMY,eAAenD,gBAAgBO;IACrC,qBACE;;0BACE,KAAC6C;gBACCC,IAAG;gBACHC,yBAAyB;oBACvBC,QAAQT;gBACV;;0BAEF,KAACU;gBAAKC,KAAI;gBAAUC,MAAMP;gBAAcQ,IAAG;;0BAC3C,KAACH;gBAAKC,KAAI;gBAAaC,MAAMP;;;;AAGnC"}
@@ -0,0 +1,318 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useField } from '@payloadcms/ui';
4
+ import React, { useMemo } from 'react';
5
+ import { themeIsValid } from '../providers/Theme/types.js';
6
+ import { defaultThemePresets } from '../presets.js';
7
+ const DEFAULT_THEME_KEY = 'cool';
8
+ const basePresetMap = defaultThemePresets.reduce((accumulator, preset)=>{
9
+ accumulator[preset.name] = preset;
10
+ return accumulator;
11
+ }, {});
12
+ const fallbackPreset = basePresetMap[DEFAULT_THEME_KEY] ?? defaultThemePresets[0];
13
+ const fallbackLightMode = fallbackPreset?.lightMode ?? {
14
+ primary: '#3b82f6',
15
+ accent: '#06b6d4',
16
+ background: '#ffffff',
17
+ foreground: '#1f2937'
18
+ };
19
+ export default function ThemePreview() {
20
+ // Get individual field values using useField hooks
21
+ const { value: selectedTheme } = useField({
22
+ path: 'themeConfiguration.theme'
23
+ });
24
+ const { value: primaryColor } = useField({
25
+ path: 'themeConfiguration.customization.primaryColor'
26
+ });
27
+ const { value: accentColor } = useField({
28
+ path: 'themeConfiguration.customization.accentColor'
29
+ });
30
+ const { value: backgroundColor } = useField({
31
+ path: 'themeConfiguration.customization.backgroundColor'
32
+ });
33
+ const { value: textColor } = useField({
34
+ path: 'themeConfiguration.customization.textColor'
35
+ });
36
+ // Determine current theme and if overrides are active
37
+ const currentTheme = themeIsValid(selectedTheme) ? selectedTheme : fallbackPreset?.name ?? 'cool';
38
+ const hasOverrides = Boolean(primaryColor || accentColor || backgroundColor || textColor);
39
+ const themeColors = useMemo(()=>{
40
+ const preset = basePresetMap[currentTheme] ?? fallbackPreset;
41
+ const lightMode = preset?.lightMode ?? fallbackLightMode;
42
+ return {
43
+ primary: lightMode?.primary ?? fallbackLightMode.primary,
44
+ accent: lightMode?.accent ?? lightMode?.secondary ?? fallbackLightMode.accent ?? fallbackLightMode.primary,
45
+ background: lightMode?.background ?? fallbackLightMode.background,
46
+ text: lightMode?.foreground ?? fallbackLightMode.foreground
47
+ };
48
+ }, [
49
+ currentTheme
50
+ ]);
51
+ const currentColors = useMemo(()=>({
52
+ primary: primaryColor || themeColors.primary,
53
+ accent: accentColor || themeColors.accent,
54
+ background: backgroundColor || themeColors.background,
55
+ text: textColor || themeColors.text
56
+ }), [
57
+ primaryColor,
58
+ accentColor,
59
+ backgroundColor,
60
+ textColor,
61
+ themeColors
62
+ ]);
63
+ return /*#__PURE__*/ _jsxs("div", {
64
+ className: "theme-preview",
65
+ style: {
66
+ marginTop: '20px'
67
+ },
68
+ children: [
69
+ /*#__PURE__*/ _jsx("div", {
70
+ style: {
71
+ fontSize: '16px',
72
+ fontWeight: '600',
73
+ marginBottom: '16px',
74
+ color: '#374151'
75
+ },
76
+ children: "🎨 Live Theme Preview"
77
+ }),
78
+ /*#__PURE__*/ _jsxs("div", {
79
+ className: "preview-container",
80
+ style: {
81
+ border: '2px solid #e5e7eb',
82
+ borderRadius: '12px',
83
+ overflow: 'hidden',
84
+ backgroundColor: currentColors.background,
85
+ color: currentColors.text,
86
+ minHeight: '300px'
87
+ },
88
+ children: [
89
+ /*#__PURE__*/ _jsxs("div", {
90
+ style: {
91
+ backgroundColor: currentColors.primary,
92
+ color: currentColors.background,
93
+ padding: '16px 24px',
94
+ display: 'flex',
95
+ justifyContent: 'space-between',
96
+ alignItems: 'center'
97
+ },
98
+ children: [
99
+ /*#__PURE__*/ _jsx("div", {
100
+ style: {
101
+ fontSize: '20px',
102
+ fontWeight: '700'
103
+ },
104
+ children: "Your Website"
105
+ }),
106
+ /*#__PURE__*/ _jsxs("nav", {
107
+ style: {
108
+ display: 'flex',
109
+ gap: '24px',
110
+ fontSize: '14px'
111
+ },
112
+ children: [
113
+ /*#__PURE__*/ _jsx("span", {
114
+ children: "Home"
115
+ }),
116
+ /*#__PURE__*/ _jsx("span", {
117
+ children: "About"
118
+ }),
119
+ /*#__PURE__*/ _jsx("span", {
120
+ children: "Services"
121
+ }),
122
+ /*#__PURE__*/ _jsx("span", {
123
+ children: "Contact"
124
+ })
125
+ ]
126
+ })
127
+ ]
128
+ }),
129
+ /*#__PURE__*/ _jsxs("div", {
130
+ style: {
131
+ padding: '32px 24px'
132
+ },
133
+ children: [
134
+ /*#__PURE__*/ _jsx("h1", {
135
+ style: {
136
+ fontSize: '32px',
137
+ fontWeight: '800',
138
+ marginBottom: '16px',
139
+ color: currentColors.text
140
+ },
141
+ children: "Welcome to Your Site"
142
+ }),
143
+ /*#__PURE__*/ _jsx("p", {
144
+ style: {
145
+ fontSize: '16px',
146
+ lineHeight: '1.6',
147
+ marginBottom: '24px',
148
+ color: currentColors.text,
149
+ opacity: 0.8
150
+ },
151
+ children: "This is how your content will look with the selected theme. The colors and styling will be applied across your entire website."
152
+ }),
153
+ /*#__PURE__*/ _jsxs("div", {
154
+ style: {
155
+ display: 'flex',
156
+ gap: '12px',
157
+ marginBottom: '32px'
158
+ },
159
+ children: [
160
+ /*#__PURE__*/ _jsx("button", {
161
+ style: {
162
+ backgroundColor: currentColors.primary,
163
+ color: currentColors.background,
164
+ border: 'none',
165
+ padding: '12px 24px',
166
+ borderRadius: '6px',
167
+ fontSize: '14px',
168
+ fontWeight: '600',
169
+ cursor: 'pointer'
170
+ },
171
+ children: "Primary Button"
172
+ }),
173
+ /*#__PURE__*/ _jsx("button", {
174
+ style: {
175
+ backgroundColor: 'transparent',
176
+ color: currentColors.primary,
177
+ border: `2px solid ${currentColors.primary}`,
178
+ padding: '10px 24px',
179
+ borderRadius: '6px',
180
+ fontSize: '14px',
181
+ fontWeight: '600',
182
+ cursor: 'pointer'
183
+ },
184
+ children: "Secondary Button"
185
+ })
186
+ ]
187
+ }),
188
+ /*#__PURE__*/ _jsx("div", {
189
+ style: {
190
+ backgroundColor: currentColors.text,
191
+ color: currentColors.background,
192
+ padding: '24px',
193
+ borderRadius: '8px',
194
+ opacity: 0.05,
195
+ marginBottom: '16px'
196
+ }
197
+ }),
198
+ /*#__PURE__*/ _jsxs("div", {
199
+ style: {
200
+ border: `1px solid ${currentColors.text}`,
201
+ padding: '20px',
202
+ borderRadius: '8px',
203
+ opacity: 0.1
204
+ },
205
+ children: [
206
+ /*#__PURE__*/ _jsx("h3", {
207
+ style: {
208
+ fontSize: '18px',
209
+ fontWeight: '600',
210
+ marginBottom: '12px',
211
+ color: currentColors.text
212
+ },
213
+ children: "Sample Card"
214
+ }),
215
+ /*#__PURE__*/ _jsx("p", {
216
+ style: {
217
+ fontSize: '14px',
218
+ color: currentColors.text,
219
+ opacity: 0.7
220
+ },
221
+ children: "This shows how cards and content blocks will appear."
222
+ })
223
+ ]
224
+ })
225
+ ]
226
+ }),
227
+ /*#__PURE__*/ _jsx("div", {
228
+ style: {
229
+ backgroundColor: currentColors.accent,
230
+ color: currentColors.background,
231
+ padding: '16px 24px',
232
+ textAlign: 'center',
233
+ fontSize: '14px',
234
+ marginTop: 'auto'
235
+ },
236
+ children: "© 2025 Your Website. Powered by PayloadCMS."
237
+ })
238
+ ]
239
+ }),
240
+ /*#__PURE__*/ _jsxs("div", {
241
+ style: {
242
+ marginTop: '12px',
243
+ fontSize: '12px',
244
+ color: '#6b7280',
245
+ display: 'grid',
246
+ gridTemplateColumns: 'repeat(2, 1fr)',
247
+ gap: '8px'
248
+ },
249
+ children: [
250
+ /*#__PURE__*/ _jsxs("div", {
251
+ children: [
252
+ /*#__PURE__*/ _jsx("strong", {
253
+ children: "Active Theme:"
254
+ }),
255
+ " ",
256
+ currentTheme
257
+ ]
258
+ }),
259
+ /*#__PURE__*/ _jsxs("div", {
260
+ children: [
261
+ /*#__PURE__*/ _jsx("strong", {
262
+ children: "Primary:"
263
+ }),
264
+ " ",
265
+ currentColors.primary
266
+ ]
267
+ }),
268
+ /*#__PURE__*/ _jsxs("div", {
269
+ children: [
270
+ /*#__PURE__*/ _jsx("strong", {
271
+ children: "Accent:"
272
+ }),
273
+ " ",
274
+ currentColors.accent
275
+ ]
276
+ }),
277
+ /*#__PURE__*/ _jsxs("div", {
278
+ children: [
279
+ /*#__PURE__*/ _jsx("strong", {
280
+ children: "Background:"
281
+ }),
282
+ " ",
283
+ currentColors.background
284
+ ]
285
+ })
286
+ ]
287
+ }),
288
+ hasOverrides && /*#__PURE__*/ _jsxs("div", {
289
+ style: {
290
+ marginTop: '8px',
291
+ padding: '8px 12px',
292
+ backgroundColor: '#fef3c7',
293
+ borderRadius: '6px',
294
+ fontSize: '11px',
295
+ color: '#92400e',
296
+ display: 'flex',
297
+ alignItems: 'center',
298
+ gap: '6px'
299
+ },
300
+ children: [
301
+ /*#__PURE__*/ _jsx("span", {
302
+ children: "⚡"
303
+ }),
304
+ /*#__PURE__*/ _jsxs("span", {
305
+ children: [
306
+ /*#__PURE__*/ _jsx("strong", {
307
+ children: "Custom colors applied"
308
+ }),
309
+ " - overriding theme defaults"
310
+ ]
311
+ })
312
+ ]
313
+ })
314
+ ]
315
+ });
316
+ }
317
+
318
+ //# sourceMappingURL=ThemePreview.js.map