@kilivi/payloadcms-theme-management 0.1.13 → 0.1.15
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/dist/components/InitTheme.js +8 -8
- package/dist/components/InitTheme.js.map +1 -1
- package/dist/components/ServerThemeInjector.js +3 -3
- package/dist/components/ServerThemeInjector.js.map +1 -1
- package/dist/components/ThemePreview.js.map +1 -1
- package/dist/components/typographyPreviewUtils.js.map +1 -1
- package/dist/constants/themeFonts.js.map +1 -1
- package/dist/fields/ColorPickerField.js.map +1 -1
- package/dist/fields/RadiusField.js.map +1 -1
- package/dist/fields/ThemeColorPickerField.css +138 -138
- package/dist/fields/ThemeColorPickerField.js.map +1 -1
- package/dist/fields/ThemePreviewField.js.map +1 -1
- package/dist/fields/ThemeTokenSelectField.js.map +1 -1
- package/dist/fields/colorModeFields.js.map +1 -1
- package/dist/fields/themeConfigurationField.js +3 -3
- package/dist/fields/themeConfigurationField.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/payload-types.js +3 -3
- package/dist/payload-types.js.map +1 -1
- package/dist/plugin.js.map +1 -1
- package/dist/presets.js.map +1 -1
- package/dist/providers/Theme/index.js.map +1 -1
- package/dist/providers/Theme/shared.js.map +1 -1
- package/dist/providers/Theme/themeConfig.js.map +1 -1
- package/dist/providers/Theme/types.js.map +1 -1
- package/dist/server.js.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/resolveThemeConfiguration.js.map +1 -1
- package/dist/utils/themeAssets.js.map +1 -1
- package/dist/utils/themeColors.js.map +1 -1
- package/dist/utils/themeHtmlAttributes.js +12 -12
- package/dist/utils/themeHtmlAttributes.js.map +1 -1
- package/dist/utils/themeUtils.js +6 -6
- package/dist/utils/themeUtils.js.map +1 -1
- package/package.json +1 -1
- package/dist/src/--verbose/dist/fields/ThemeColorPickerField.scss +0 -138
- package/dist/src/dist/fields/ThemeColorPickerField.scss +0 -138
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/themeAssets.ts"],"sourcesContent":["import { readFile } from 'fs/promises'\
|
|
1
|
+
{"version":3,"sources":["../../src/utils/themeAssets.ts"],"sourcesContent":["import { readFile } from 'fs/promises'\nimport { join } from 'path'\nimport type { ThemeDefaults } from '../providers/Theme/types.js'\n\nconst themeCriticalFiles: Record<string, string> = {\n cool: 'cool-critical.css',\n brutal: 'brutal-critical.css',\n neon: 'neon-critical.css',\n solar: 'solar-critical.css',\n dealership: 'dealership-critical.css',\n 'real-estate': 'real-estate-critical.css',\n 'real-estate-gold': 'real-estate-gold-critical.css',\n 'real-estate-neutral': 'real-estate-neutral-critical.css',\n}\n\nconst themeFullFiles: Record<string, string> = {\n cool: 'cool.css',\n brutal: 'brutal.css',\n neon: 'neon.css',\n solar: 'solar.css',\n dealership: 'dealership.css',\n 'real-estate': 'real-estate.css',\n 'real-estate-gold': 'real-estate-gold.css',\n 'real-estate-neutral': 'real-estate-neutral.css',\n}\n\nexport async function getThemeCriticalCSS(theme: ThemeDefaults): Promise<string | null> {\n try {\n const filename = themeCriticalFiles[theme]\n if (!filename) {\n console.warn(`Critical CSS file not found for theme: ${theme}`)\n return null\n }\n\n const filePath = join(process.cwd(), 'public', 'themes', filename)\n const css = await readFile(filePath, 'utf-8')\n\n return css.replace(/\\r\\n/g, '\\n').replace(/\\r/g, '\\n')\n } catch (error) {\n console.error(`Error reading critical CSS for theme ${theme}:`, error)\n return null\n }\n}\n\nexport function getThemeCSSPath(theme: ThemeDefaults): string {\n const filename = themeFullFiles[theme]\n return `/themes/${filename}`\n}\n\nexport function generateThemePreloadLinks(theme: ThemeDefaults): string {\n const cssPath = getThemeCSSPath(theme)\n return `<link rel=\"preload\" href=\"${cssPath}\" as=\"style\" onload=\"this.onload=null;this.rel='stylesheet'\">`\n}\n\nexport function createFallbackCriticalCSS(theme: ThemeDefaults): string {\n return `\n/* Fallback critical CSS for ${theme} theme */\n[data-theme=\"${theme}\"] {\n --background: hsl(0 0% 100%);\n --foreground: hsl(222 47% 11%);\n --primary: hsl(221 83% 53%);\n --primary-foreground: hsl(210 40% 98%);\n color-scheme: light;\n}\n\n[data-theme=\"${theme}\"][data-theme-mode=\"dark\"] {\n --background: hsl(222 47% 11%);\n --foreground: hsl(210 40% 98%);\n --primary: hsl(217 91% 60%);\n --primary-foreground: hsl(222 47% 11%);\n color-scheme: dark;\n}\n`.trim()\n}\n"],"names":["readFile","join","themeCriticalFiles","cool","brutal","neon","solar","dealership","themeFullFiles","getThemeCriticalCSS","theme","filename","console","warn","filePath","process","cwd","css","replace","error","getThemeCSSPath","generateThemePreloadLinks","cssPath","createFallbackCriticalCSS","trim"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAa;AACtC,SAASC,IAAI,QAAQ,OAAM;AAG3B,MAAMC,qBAA6C;IACjDC,MAAM;IACNC,QAAQ;IACRC,MAAM;IACNC,OAAO;IACPC,YAAY;IACZ,eAAe;IACf,oBAAoB;IACpB,uBAAuB;AACzB;AAEA,MAAMC,iBAAyC;IAC7CL,MAAM;IACNC,QAAQ;IACRC,MAAM;IACNC,OAAO;IACPC,YAAY;IACZ,eAAe;IACf,oBAAoB;IACpB,uBAAuB;AACzB;AAEA,OAAO,eAAeE,oBAAoBC,KAAoB;IAC5D,IAAI;QACF,MAAMC,WAAWT,kBAAkB,CAACQ,MAAM;QAC1C,IAAI,CAACC,UAAU;YACbC,QAAQC,IAAI,CAAC,CAAC,uCAAuC,EAAEH,OAAO;YAC9D,OAAO;QACT;QAEA,MAAMI,WAAWb,KAAKc,QAAQC,GAAG,IAAI,UAAU,UAAUL;QACzD,MAAMM,MAAM,MAAMjB,SAASc,UAAU;QAErC,OAAOG,IAAIC,OAAO,CAAC,SAAS,MAAMA,OAAO,CAAC,OAAO;IACnD,EAAE,OAAOC,OAAO;QACdP,QAAQO,KAAK,CAAC,CAAC,qCAAqC,EAAET,MAAM,CAAC,CAAC,EAAES;QAChE,OAAO;IACT;AACF;AAEA,OAAO,SAASC,gBAAgBV,KAAoB;IAClD,MAAMC,WAAWH,cAAc,CAACE,MAAM;IACtC,OAAO,CAAC,QAAQ,EAAEC,UAAU;AAC9B;AAEA,OAAO,SAASU,0BAA0BX,KAAoB;IAC5D,MAAMY,UAAUF,gBAAgBV;IAChC,OAAO,CAAC,0BAA0B,EAAEY,QAAQ,6DAA6D,CAAC;AAC5G;AAEA,OAAO,SAASC,0BAA0Bb,KAAoB;IAC5D,OAAO,CAAC;6BACmB,EAAEA,MAAM;aACxB,EAAEA,MAAM;;;;;;;;aAQR,EAAEA,MAAM;;;;;;;AAOrB,CAAC,CAACc,IAAI;AACN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/themeColors.ts"],"sourcesContent":["interface ColorMode {\
|
|
1
|
+
{"version":3,"sources":["../../src/utils/themeColors.ts"],"sourcesContent":["interface ColorMode {\n background?: string | null\n foreground?: string | null\n card?: string | null\n cardForeground?: string | null\n popover?: string | null\n popoverForeground?: string | null\n primary?: string | null\n primaryForeground?: string | null\n secondary?: string | null\n secondaryForeground?: string | null\n muted?: string | null\n mutedForeground?: string | null\n accent?: string | null\n accentForeground?: string | null\n destructive?: string | null\n destructiveForeground?: string | null\n border?: string | null\n input?: string | null\n ring?: string | null\n}\n\nexport interface ThemeColors {\n lightMode?: ColorMode\n darkMode?: ColorMode\n}\n\ninterface GenerateThemeColorsOptions extends ThemeColors {\n themeName?: string\n}\n\nconst COLOR_VARIABLE_MAP: Array<{ key: keyof ColorMode; variable: string }> = [\n { key: 'background', variable: '--background' },\n { key: 'foreground', variable: '--foreground' },\n { key: 'card', variable: '--card' },\n { key: 'cardForeground', variable: '--card-foreground' },\n { key: 'popover', variable: '--popover' },\n { key: 'popoverForeground', variable: '--popover-foreground' },\n { key: 'primary', variable: '--primary' },\n { key: 'primaryForeground', variable: '--primary-foreground' },\n { key: 'secondary', variable: '--secondary' },\n { key: 'secondaryForeground', variable: '--secondary-foreground' },\n { key: 'muted', variable: '--muted' },\n { key: 'mutedForeground', variable: '--muted-foreground' },\n { key: 'accent', variable: '--accent' },\n { key: 'accentForeground', variable: '--accent-foreground' },\n { key: 'destructive', variable: '--destructive' },\n { key: 'destructiveForeground', variable: '--destructive-foreground' },\n { key: 'border', variable: '--border' },\n { key: 'input', variable: '--input' },\n { key: 'ring', variable: '--ring' },\n]\n\nexport function hexToHsl(hex: string): string {\n if (!hex) return '0 0% 0%'\n\n hex = hex.replace('#', '')\n\n if (hex.length === 3) {\n hex = hex\n .split('')\n .map((char) => char + char)\n .join('')\n }\n\n const r = Number.parseInt(hex.substring(0, 2), 16) / 255\n const g = Number.parseInt(hex.substring(2, 4), 16) / 255\n const b = Number.parseInt(hex.substring(4, 6), 16) / 255\n\n const max = Math.max(r, g, b)\n const min = Math.min(r, g, b)\n let h = 0\n let s = 0\n const l = (max + min) / 2\n\n if (max !== min) {\n const d = max - min\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min)\n\n switch (max) {\n case r:\n h = ((g - b) / d + (g < b ? 6 : 0)) / 6\n break\n case g:\n h = ((b - r) / d + 2) / 6\n break\n case b:\n h = ((r - g) / d + 4) / 6\n break\n }\n }\n\n h = Math.round(h * 360)\n s = Math.round(s * 100)\n const lRounded = Math.round(l * 100)\n\n return `${h} ${s}% ${lRounded}%`\n}\n\nexport function generateColorModeCss(\n colors: ColorMode,\n options: { themeName?: string; isDark?: boolean } = {},\n): string {\n if (!colors) return ''\n\n const { themeName, isDark = false } = options\n\n const cssVariables = COLOR_VARIABLE_MAP.reduce<string[]>((acc, { key, variable }) => {\n const value = normalizeColor(colors[key])\n if (!value) return acc\n acc.push(`${variable}: hsl(${hexToHsl(value)});`)\n return acc\n }, [])\n\n if (cssVariables.length === 0) return ''\n\n const selector = buildSelector(themeName, isDark)\n return `${selector} {\n ${cssVariables.join('\\n ')}\n}`\n}\n\nexport function generateThemeColorsCss(options: GenerateThemeColorsOptions): string {\n const cssBlocks: string[] = []\n const { themeName, lightMode, darkMode } = options\n\n if (lightMode) {\n const lightModeCss = generateColorModeCss(lightMode, { themeName, isDark: false })\n if (lightModeCss) cssBlocks.push(lightModeCss)\n }\n\n if (darkMode) {\n const darkModeCss = generateColorModeCss(darkMode, { themeName, isDark: true })\n if (darkModeCss) cssBlocks.push(darkModeCss)\n }\n\n return cssBlocks.join('\\n\\n')\n}\n\nfunction buildSelector(themeName: string | undefined, isDark: boolean): string {\n if (themeName) {\n if (isDark) {\n return `:root[data-theme='${themeName}'][data-theme-mode='dark'], .dark[data-theme='${themeName}']`\n }\n return `:root[data-theme='${themeName}']`\n }\n\n if (isDark) {\n return \":root[data-theme-mode='dark'], .dark\"\n }\n\n return ':root'\n}\n\nfunction normalizeColor(value: string | null | undefined): string | null {\n if (typeof value !== 'string') return null\n const trimmed = value.trim()\n return trimmed.length === 0 ? null : trimmed\n}\n"],"names":["COLOR_VARIABLE_MAP","key","variable","hexToHsl","hex","replace","length","split","map","char","join","r","Number","parseInt","substring","g","b","max","Math","min","h","s","l","d","round","lRounded","generateColorModeCss","colors","options","themeName","isDark","cssVariables","reduce","acc","value","normalizeColor","push","selector","buildSelector","generateThemeColorsCss","cssBlocks","lightMode","darkMode","lightModeCss","darkModeCss","trimmed","trim"],"mappings":"AA+BA,MAAMA,qBAAwE;IAC5E;QAAEC,KAAK;QAAcC,UAAU;IAAe;IAC9C;QAAED,KAAK;QAAcC,UAAU;IAAe;IAC9C;QAAED,KAAK;QAAQC,UAAU;IAAS;IAClC;QAAED,KAAK;QAAkBC,UAAU;IAAoB;IACvD;QAAED,KAAK;QAAWC,UAAU;IAAY;IACxC;QAAED,KAAK;QAAqBC,UAAU;IAAuB;IAC7D;QAAED,KAAK;QAAWC,UAAU;IAAY;IACxC;QAAED,KAAK;QAAqBC,UAAU;IAAuB;IAC7D;QAAED,KAAK;QAAaC,UAAU;IAAc;IAC5C;QAAED,KAAK;QAAuBC,UAAU;IAAyB;IACjE;QAAED,KAAK;QAASC,UAAU;IAAU;IACpC;QAAED,KAAK;QAAmBC,U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;QAAM;QAChF,IAAIa,cAAcH,UAAUJ,IAAI,CAACO;IACnC;IAEA,IAAID,UAAU;QACZ,MAAME,cAAclB,qBAAqBgB,UAAU;YAAEb;YAAWC,QAAQ;QAAK;QAC7E,IAAIc,aAAaJ,UAAUJ,IAAI,CAACQ;IAClC;IAEA,OAAOJ,UAAU9B,IAAI,CAAC;AACxB;AAEA,SAAS4B,cAAcT,SAA6B,EAAEC,MAAe;IACnE,IAAID,WAAW;QACb,IAAIC,QAAQ;YACV,OAAO,CAAC,kBAAkB,EAAED,UAAU,8CAA8C,EAAEA,UAAU,EAAE,CAAC;QACrG;QACA,OAAO,CAAC,kBAAkB,EAAEA,UAAU,EAAE,CAAC;IAC3C;IAEA,IAAIC,QAAQ;QACV,OAAO;IACT;IAEA,OAAO;AACT;AAEA,SAASK,eAAeD,KAAgC;IACtD,IAAI,OAAOA,UAAU,UAAU,OAAO;IACtC,MAAMW,UAAUX,MAAMY,IAAI;IAC1B,OAAOD,QAAQvC,MAAM,KAAK,IAAI,OAAOuC;AACvC"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generates HTML attributes for the <html> element based on theme configuration
|
|
3
|
-
* This ensures the theme is applied before React hydration to prevent FOUC
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* ```tsx
|
|
7
|
-
* const siteSettings = await payload.findGlobal({ slug: 'site-settings' })
|
|
8
|
-
* const themeConfig = resolveThemeConfiguration(siteSettings?.themeConfiguration)
|
|
9
|
-
* const htmlAttrs = getThemeHtmlAttributes(themeConfig)
|
|
10
|
-
*
|
|
11
|
-
* <html {...htmlAttrs} className={yourClassName}>
|
|
12
|
-
* ```
|
|
1
|
+
/**
|
|
2
|
+
* Generates HTML attributes for the <html> element based on theme configuration
|
|
3
|
+
* This ensures the theme is applied before React hydration to prevent FOUC
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```tsx
|
|
7
|
+
* const siteSettings = await payload.findGlobal({ slug: 'site-settings' })
|
|
8
|
+
* const themeConfig = resolveThemeConfiguration(siteSettings?.themeConfiguration)
|
|
9
|
+
* const htmlAttrs = getThemeHtmlAttributes(themeConfig)
|
|
10
|
+
*
|
|
11
|
+
* <html {...htmlAttrs} className={yourClassName}>
|
|
12
|
+
* ```
|
|
13
13
|
*/ export function getThemeHtmlAttributes(config) {
|
|
14
14
|
return {
|
|
15
15
|
'data-theme': config.theme,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/themeHtmlAttributes.ts"],"sourcesContent":["import type { ResolvedThemeConfiguration } from './resolveThemeConfiguration.js'\
|
|
1
|
+
{"version":3,"sources":["../../src/utils/themeHtmlAttributes.ts"],"sourcesContent":["import type { ResolvedThemeConfiguration } from './resolveThemeConfiguration.js'\n\n/**\n * Generates HTML attributes for the <html> element based on theme configuration\n * This ensures the theme is applied before React hydration to prevent FOUC\n * \n * @example\n * ```tsx\n * const siteSettings = await payload.findGlobal({ slug: 'site-settings' })\n * const themeConfig = resolveThemeConfiguration(siteSettings?.themeConfiguration)\n * const htmlAttrs = getThemeHtmlAttributes(themeConfig)\n * \n * <html {...htmlAttrs} className={yourClassName}>\n * ```\n */\nexport function getThemeHtmlAttributes(config: ResolvedThemeConfiguration): {\n 'data-theme': string\n 'data-theme-mode': string\n 'data-border-radius': string\n 'data-font-scale': string\n 'data-spacing': string\n 'data-animation-level': string\n 'data-allow-color-mode-toggle': string\n suppressHydrationWarning: true\n} {\n return {\n 'data-theme': config.theme,\n 'data-theme-mode': config.colorMode,\n 'data-border-radius': config.borderRadius,\n 'data-font-scale': config.fontScale,\n 'data-spacing': config.spacing,\n 'data-animation-level': config.animationLevel,\n 'data-allow-color-mode-toggle': config.allowColorModeToggle ? 'true' : 'false',\n suppressHydrationWarning: true,\n }\n}\n"],"names":["getThemeHtmlAttributes","config","theme","colorMode","borderRadius","fontScale","spacing","animationLevel","allowColorModeToggle","suppressHydrationWarning"],"mappings":"AAEA;;;;;;;;;;;;CAYC,GACD,OAAO,SAASA,uBAAuBC,MAAkC;IAUvE,OAAO;QACL,cAAcA,OAAOC,KAAK;QAC1B,mBAAmBD,OAAOE,SAAS;QACnC,sBAAsBF,OAAOG,YAAY;QACzC,mBAAmBH,OAAOI,SAAS;QACnC,gBAAgBJ,OAAOK,OAAO;QAC9B,wBAAwBL,OAAOM,cAAc;QAC7C,gCAAgCN,OAAOO,oBAAoB,GAAG,SAAS;QACvEC,0BAA0B;IAC5B;AACF"}
|
package/dist/utils/themeUtils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { borderRadiusPresets } from '../providers/Theme/themeConfig.js';
|
|
2
|
-
/**
|
|
3
|
-
* Generates CSS custom properties from theme configuration
|
|
2
|
+
/**
|
|
3
|
+
* Generates CSS custom properties from theme configuration
|
|
4
4
|
*/ export function generateThemeCSS(config) {
|
|
5
5
|
const cssRules = [];
|
|
6
6
|
const customization = config.customization;
|
|
@@ -22,8 +22,8 @@ import { borderRadiusPresets } from '../providers/Theme/themeConfig.js';
|
|
|
22
22
|
appendCustomCSS(cssRules, customization);
|
|
23
23
|
return cssRules.join('\n');
|
|
24
24
|
}
|
|
25
|
-
/**
|
|
26
|
-
* Determines if a color is light or dark
|
|
25
|
+
/**
|
|
26
|
+
* Determines if a color is light or dark
|
|
27
27
|
*/ function isLightBackground(color) {
|
|
28
28
|
// Simple heuristic: if it contains 'white', '#fff', or high RGB values, it's light
|
|
29
29
|
const lightPatterns = [
|
|
@@ -34,8 +34,8 @@ import { borderRadiusPresets } from '../providers/Theme/themeConfig.js';
|
|
|
34
34
|
];
|
|
35
35
|
return lightPatterns.some((pattern)=>pattern.test(color));
|
|
36
36
|
}
|
|
37
|
-
/**
|
|
38
|
-
* Generate theme styles for use in components
|
|
37
|
+
/**
|
|
38
|
+
* Generate theme styles for use in components
|
|
39
39
|
*/ export function getThemeStyles(config) {
|
|
40
40
|
const styles = {};
|
|
41
41
|
const customization = config.customization;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/themeUtils.ts"],"sourcesContent":["import type { SiteSetting } from '../payload-types.js'\r\nimport { borderRadiusPresets } from '../providers/Theme/themeConfig.js'\r\nimport type { ThemeTypographyPreset } from '../presets.js'\r\n\r\ntype ThemeTypographyConfiguration = {\r\n typography?: ThemeTypographyPreset | null\r\n}\r\n\r\ntype ThemeConfiguration = Omit<NonNullable<SiteSetting['themeConfiguration']>, 'typography'> &\r\n ThemeTypographyConfiguration\r\n\r\ninterface ThemeCustomization {\r\n primaryColor?: string | null\r\n accentColor?: string | null\r\n backgroundColor?: string | null\r\n textColor?: string | null\r\n customCSS?: string | null\r\n}\r\n\r\ntype ThemeConfigurationWithCustomization = ThemeConfiguration & {\r\n customization?: ThemeCustomization | null\r\n}\r\n/**\r\n * Generates CSS custom properties from theme configuration\r\n */\r\nexport function generateThemeCSS(config: ThemeConfiguration): string {\r\n const cssRules: string[] = []\r\n const customization = (config as ThemeConfigurationWithCustomization).customization\r\n const themeSelector = config.theme ? `:root[data-theme='${config.theme}']` : ':root'\r\n\r\n // Start root CSS rules\r\n cssRules.push(`${themeSelector} {`)\r\n applyCustomizationRootRules(cssRules, customization)\r\n applyBorderRadiusRule(cssRules, config)\r\n applyFontScaleRules(cssRules, config)\r\n applySpacingRule(cssRules, config)\r\n applyAnimationRule(cssRules, config)\r\n applyTypographyRules(cssRules, config)\r\n\r\n cssRules.push('}')\r\n\r\n // Color mode specific overrides\r\n applyDarkModeOverrides(cssRules, config, customization, themeSelector)\r\n\r\n // Animation level: none - respect prefers-reduced-motion\r\n applyReducedMotionOverride(cssRules, config)\r\n\r\n // Custom CSS\r\n appendCustomCSS(cssRules, customization)\r\n\r\n return cssRules.join('\\n')\r\n}\r\n\r\n/**\r\n * Determines if a color is light or dark\r\n */\r\nfunction isLightBackground(color: string): boolean {\r\n // Simple heuristic: if it contains 'white', '#fff', or high RGB values, it's light\r\n const lightPatterns = [\r\n /white/i,\r\n /#f{3,6}/i,\r\n /rgb\\s*\\(\\s*([2-9]\\d{2}|1[5-9]\\d|1\\d{2}),/,\r\n /hsl\\s*\\([^)]*,\\s*[^,)]*,\\s*([7-9]\\d|100)%\\)/,\r\n ]\r\n\r\n return lightPatterns.some((pattern) => pattern.test(color))\r\n}\r\n\r\n/**\r\n * Generate theme styles for use in components\r\n */\r\nexport function getThemeStyles(config: ThemeConfiguration) {\r\n const styles: Record<string, string> = {}\r\n const customization = (config as ThemeConfigurationWithCustomization).customization\r\n\r\n applyCustomizationStyleOverrides(styles, customization)\r\n applyTypographyStyleOverrides(styles, config.typography)\r\n\r\n return styles\r\n}\r\n\r\nfunction applyCustomizationRootRules(\r\n rules: string[],\r\n customization: ThemeCustomization | null | undefined,\r\n): void {\r\n if (!customization) return\r\n\r\n if (customization.primaryColor) {\r\n rules.push(` --primary-custom: ${customization.primaryColor};`)\r\n }\r\n\r\n if (customization.accentColor) {\r\n rules.push(` --accent-custom: ${customization.accentColor};`)\r\n }\r\n\r\n if (customization.backgroundColor) {\r\n rules.push(` --background: ${customization.backgroundColor};`)\r\n rules.push(` --card: ${customization.backgroundColor};`)\r\n rules.push(` --popover: ${customization.backgroundColor};`)\r\n }\r\n\r\n if (customization.textColor) {\r\n rules.push(` --foreground: ${customization.textColor};`)\r\n }\r\n}\r\n\r\nfunction applyBorderRadiusRule(rules: string[], config: ThemeConfiguration): void {\r\n if (!config.borderRadius) return\r\n\r\n const preset = borderRadiusPresets[config.borderRadius]\r\n if (!preset) return\r\n\r\n const cssEntries = Object.entries(preset.css)\r\n cssEntries.forEach(([property, value]) => {\r\n rules.push(` ${property}: ${value};`)\r\n })\r\n\r\n const defaultRadius =\r\n preset.css['--radius-default'] ?? preset.css['--radius-medium'] ?? preset.css['--radius-large']\r\n if (defaultRadius) {\r\n rules.push(` --radius: ${defaultRadius};`)\r\n }\r\n}\r\n\r\nfunction applyFontScaleRules(rules: string[], config: ThemeConfiguration): void {\r\n if (!config.fontScale) return\r\n\r\n const scaleValues: Record<string, string> = {\r\n small: '0.9',\r\n medium: '1',\r\n large: '1.1',\r\n xl: '1.25',\r\n }\r\n\r\n const scale = scaleValues[config.fontScale] ?? '1'\r\n rules.push(` --font-scale: ${scale};`)\r\n rules.push(` --theme-font-scale: ${scale};`)\r\n\r\n const baseSizes: Record<string, string> = {\r\n 'text-xs': '0.75rem',\r\n 'text-sm': '0.875rem',\r\n 'text-base': '1rem',\r\n 'text-lg': '1.125rem',\r\n 'text-xl': '1.25rem',\r\n 'text-2xl': '1.5rem',\r\n 'text-3xl': '1.875rem',\r\n 'text-4xl': '2.25rem',\r\n }\r\n\r\n Object.entries(baseSizes).forEach(([className, baseSize]) => {\r\n const scaledSize = parseFloat(baseSize) * parseFloat(scale)\r\n rules.push(` --${className}: ${scaledSize}rem;`)\r\n })\r\n}\r\n\r\nfunction applySpacingRule(rules: string[], config: ThemeConfiguration): void {\r\n if (!config.spacing) return\r\n\r\n const spacingMultipliers: Record<string, string> = {\r\n compact: '0.75',\r\n medium: '1',\r\n spacious: '1.5',\r\n }\r\n\r\n const multiplier = spacingMultipliers[config.spacing] ?? '1'\r\n rules.push(` --spacing-scale: ${multiplier};`)\r\n rules.push(` --theme-spacing: ${multiplier};`)\r\n}\r\n\r\nfunction applyAnimationRule(rules: string[], config: ThemeConfiguration): void {\r\n if (!config.animationLevel) return\r\n\r\n const animationSettings: Record<string, { duration: string; easing: string; scale: string }> = {\r\n none: {\r\n duration: '0s',\r\n easing: 'linear',\r\n scale: '0',\r\n },\r\n reduced: {\r\n duration: '0.1s',\r\n easing: 'ease-out',\r\n scale: '0.5',\r\n },\r\n medium: {\r\n duration: '0.2s',\r\n easing: 'ease-out',\r\n scale: '1',\r\n },\r\n full: {\r\n duration: '0.3s',\r\n easing: 'cubic-bezier(0.4, 0, 0.2, 1)',\r\n scale: '1.2',\r\n },\r\n }\r\n\r\n const level = config.animationLevel as keyof typeof animationSettings\r\n const settings = animationSettings[level] ?? animationSettings.medium\r\n if (!settings) return\r\n rules.push(` --animation-duration: ${settings.duration};`)\r\n rules.push(` --animation-easing: ${settings.easing};`)\r\n rules.push(` --animation-scale: ${settings.scale};`)\r\n rules.push(` --theme-animation-level: ${config.animationLevel};`)\r\n}\r\n\r\nfunction applyTypographyRules(rules: string[], config: ThemeConfiguration): void {\r\n const typography = config.typography\r\n if (!typography) return\r\n\r\n if (typography.fontFamily) {\r\n rules.push(` --typography-fontFamily: ${typography.fontFamily};`)\r\n }\r\n\r\n if (typography.headingFamily) {\r\n rules.push(` --typography-headingFamily: ${typography.headingFamily};`)\r\n }\r\n\r\n if (typography.baseFontSize) {\r\n rules.push(` --typography-baseFontSize: ${typography.baseFontSize};`)\r\n }\r\n\r\n if (typography.lineHeight) {\r\n rules.push(` --typography-lineHeight: ${typography.lineHeight};`)\r\n }\r\n\r\n if (typography.fontWeights) {\r\n Object.entries(typography.fontWeights).forEach(([token, weight]) => {\r\n if (weight) {\r\n rules.push(` --typography-fontWeights-${token}: ${weight};`)\r\n }\r\n })\r\n }\r\n\r\n if (typography.letterSpacing) {\r\n Object.entries(typography.letterSpacing).forEach(([token, value]) => {\r\n if (value) {\r\n rules.push(` --typography-letterSpacing-${token}: ${value};`)\r\n }\r\n })\r\n }\r\n}\r\n\r\nfunction applyDarkModeOverrides(\r\n rules: string[],\r\n config: ThemeConfiguration,\r\n customization: ThemeCustomization | null | undefined,\r\n selector: string,\r\n): void {\r\n if (config.colorMode !== 'dark' && config.colorMode !== 'auto') return\r\n\r\n rules.push('')\r\n rules.push('@media (prefers-color-scheme: dark) {')\r\n rules.push(` ${selector} {`)\r\n\r\n if (customization?.backgroundColor && isLightBackground(customization.backgroundColor)) {\r\n rules.push(` --background: hsl(224 71% 4%);`)\r\n rules.push(` --card: hsl(224 71% 4%);`)\r\n rules.push(` --popover: hsl(224 71% 4%);`)\r\n }\r\n\r\n if (customization?.textColor && !isLightBackground(customization.textColor)) {\r\n rules.push(` --foreground: hsl(213 31% 91%);`)\r\n }\r\n\r\n rules.push(' }')\r\n rules.push('}')\r\n}\r\n\r\nfunction applyReducedMotionOverride(rules: string[], config: ThemeConfiguration): void {\r\n if (config.animationLevel !== 'none') return\r\n\r\n rules.push('')\r\n rules.push('@media (prefers-reduced-motion: reduce) {')\r\n rules.push(' *, *::before, *::after {')\r\n rules.push(' animation-duration: 0.01ms !important;')\r\n rules.push(' animation-iteration-count: 1 !important;')\r\n rules.push(' transition-duration: 0.01ms !important;')\r\n rules.push(' scroll-behavior: auto !important;')\r\n rules.push(' }')\r\n rules.push('}')\r\n}\r\n\r\nfunction appendCustomCSS(\r\n rules: string[],\r\n customization: ThemeCustomization | null | undefined,\r\n): void {\r\n if (!customization?.customCSS) return\r\n\r\n rules.push('')\r\n rules.push('/* Custom CSS */')\r\n rules.push(customization.customCSS)\r\n}\r\n\r\nfunction applyCustomizationStyleOverrides(\r\n styles: Record<string, string>,\r\n customization: ThemeCustomization | null | undefined,\r\n): void {\r\n if (!customization) return\r\n\r\n if (customization.primaryColor) {\r\n styles['--primary'] = customization.primaryColor\r\n }\r\n\r\n if (customization.accentColor) {\r\n styles['--accent'] = customization.accentColor\r\n }\r\n\r\n if (customization.backgroundColor) {\r\n styles['--background'] = customization.backgroundColor\r\n styles['--card'] = customization.backgroundColor\r\n styles['--popover'] = customization.backgroundColor\r\n }\r\n\r\n if (customization.textColor) {\r\n styles['--foreground'] = customization.textColor\r\n }\r\n}\r\n\r\nfunction applyTypographyStyleOverrides(\r\n styles: Record<string, string>,\r\n typography: ThemeTypographyPreset | null | undefined,\r\n): void {\r\n if (!typography) return\r\n\r\n if (typography.fontFamily) {\r\n styles['--font-family-base'] = typography.fontFamily\r\n }\r\n\r\n if (typography.headingFamily) {\r\n styles['--font-family-heading'] = typography.headingFamily\r\n }\r\n\r\n if (typography.baseFontSize) {\r\n styles['--font-size-base'] = typography.baseFontSize\r\n }\r\n\r\n if (typography.lineHeight) {\r\n styles['--line-height-base'] = typography.lineHeight\r\n }\r\n}\r\n"],"names":["borderRadiusPresets","generateThemeCSS","config","cssRules","customization","themeSelector","theme","push","applyCustomizationRootRules","applyBorderRadiusRule","applyFontScaleRules","applySpacingRule","applyAnimationRule","applyTypographyRules","applyDarkModeOverrides","applyReducedMotionOverride","appendCustomCSS","join","isLightBackground","color","lightPatterns","some","pattern","test","getThemeStyles","styles","applyCustomizationStyleOverrides","applyTypographyStyleOverrides","typography","rules","primaryColor","accentColor","backgroundColor","textColor","borderRadius","preset","cssEntries","Object","entries","css","forEach","property","value","defaultRadius","fontScale","scaleValues","small","medium","large","xl","scale","baseSizes","className","baseSize","scaledSize","parseFloat","spacing","spacingMultipliers","compact","spacious","multiplier","animationLevel","animationSettings","none","duration","easing","reduced","full","level","settings","fontFamily","headingFamily","baseFontSize","lineHeight","fontWeights","token","weight","letterSpacing","selector","colorMode","customCSS"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,oCAAmC;AAqBvE;;CAEC,GACD,OAAO,SAASC,iBAAiBC,MAA0B;IACzD,MAAMC,WAAqB,EAAE;IAC7B,MAAMC,gBAAgB,AAACF,OAA+CE,aAAa;IACnF,MAAMC,gBAAgBH,OAAOI,KAAK,GAAG,CAAC,kBAAkB,EAAEJ,OAAOI,KAAK,CAAC,EAAE,CAAC,GAAG;IAE7E,uBAAuB;IACvBH,SAASI,IAAI,CAAC,GAAGF,cAAc,EAAE,CAAC;IAClCG,4BAA4BL,UAAUC;IACtCK,sBAAsBN,UAAUD;IAChCQ,oBAAoBP,UAAUD;IAC9BS,iBAAiBR,UAAUD;IAC3BU,mBAAmBT,UAAUD;IAC7BW,qBAAqBV,UAAUD;IAE/BC,SAASI,IAAI,CAAC;IAEd,gCAAgC;IAChCO,uBAAuBX,UAAUD,QAAQE,eAAeC;IAExD,yDAAyD;IACzDU,2BAA2BZ,UAAUD;IAErC,aAAa;IACbc,gBAAgBb,UAAUC;IAE1B,OAAOD,SAASc,IAAI,CAAC;AACvB;AAEA;;CAEC,GACD,SAASC,kBAAkBC,KAAa;IACtC,mFAAmF;IACnF,MAAM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eAAe;QAChDP,MAAM,CAAC,YAAY,GAAGrB,cAAc4B,eAAe;IACrD;IAEA,IAAI5B,cAAc6B,SAAS,EAAE;QAC3BR,MAAM,CAAC,eAAe,GAAGrB,cAAc6B,SAAS;IAClD;AACF;AAEA,SAASN,8BACPF,MAA8B,EAC9BG,UAAoD;IAEpD,IAAI,CAACA,YAAY;IAEjB,IAAIA,WAAW0C,UAAU,EAAE;QACzB7C,MAAM,CAAC,qBAAqB,GAAGG,WAAW0C,UAAU;IACtD;IAEA,IAAI1C,WAAW2C,aAAa,EAAE;QAC5B9C,MAAM,CAAC,wBAAwB,GAAGG,WAAW2C,aAAa;IAC5D;IAEA,IAAI3C,WAAW4C,YAAY,EAAE;QAC3B/C,MAAM,CAAC,mBAAmB,GAAGG,WAAW4C,YAAY;IACtD;IAEA,IAAI5C,WAAW6C,UAAU,EAAE;QACzBhD,MAAM,CAAC,qBAAqB,GAAGG,WAAW6C,UAAU;IACtD;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/themeUtils.ts"],"sourcesContent":["import type { SiteSetting } from '../payload-types.js'\nimport { borderRadiusPresets } from '../providers/Theme/themeConfig.js'\nimport type { ThemeTypographyPreset } from '../presets.js'\n\ntype ThemeTypographyConfiguration = {\n typography?: ThemeTypographyPreset | null\n}\n\ntype ThemeConfiguration = Omit<NonNullable<SiteSetting['themeConfiguration']>, 'typography'> &\n ThemeTypographyConfiguration\n\ninterface ThemeCustomization {\n primaryColor?: string | null\n accentColor?: string | null\n backgroundColor?: string | null\n textColor?: string | null\n customCSS?: string | null\n}\n\ntype ThemeConfigurationWithCustomization = ThemeConfiguration & {\n customization?: ThemeCustomization | null\n}\n/**\n * Generates CSS custom properties from theme configuration\n */\nexport function generateThemeCSS(config: ThemeConfiguration): string {\n const cssRules: string[] = []\n const customization = (config as ThemeConfigurationWithCustomization).customization\n const themeSelector = config.theme ? `:root[data-theme='${config.theme}']` : ':root'\n\n // Start root CSS rules\n cssRules.push(`${themeSelector} {`)\n applyCustomizationRootRules(cssRules, customization)\n applyBorderRadiusRule(cssRules, config)\n applyFontScaleRules(cssRules, config)\n applySpacingRule(cssRules, config)\n applyAnimationRule(cssRules, config)\n applyTypographyRules(cssRules, config)\n\n cssRules.push('}')\n\n // Color mode specific overrides\n applyDarkModeOverrides(cssRules, config, customization, themeSelector)\n\n // Animation level: none - respect prefers-reduced-motion\n applyReducedMotionOverride(cssRules, config)\n\n // Custom CSS\n appendCustomCSS(cssRules, customization)\n\n return cssRules.join('\\n')\n}\n\n/**\n * Determines if a color is light or dark\n */\nfunction isLightBackground(color: string): boolean {\n // Simple heuristic: if it contains 'white', '#fff', or high RGB values, it's light\n const lightPatterns = [\n /white/i,\n /#f{3,6}/i,\n /rgb\\s*\\(\\s*([2-9]\\d{2}|1[5-9]\\d|1\\d{2}),/,\n /hsl\\s*\\([^)]*,\\s*[^,)]*,\\s*([7-9]\\d|100)%\\)/,\n ]\n\n return lightPatterns.some((pattern) => pattern.test(color))\n}\n\n/**\n * Generate theme styles for use in components\n */\nexport function getThemeStyles(config: ThemeConfiguration) {\n const styles: Record<string, string> = {}\n const customization = (config as ThemeConfigurationWithCustomization).customization\n\n applyCustomizationStyleOverrides(styles, customization)\n applyTypographyStyleOverrides(styles, config.typography)\n\n return styles\n}\n\nfunction applyCustomizationRootRules(\n rules: string[],\n customization: ThemeCustomization | null | undefined,\n): void {\n if (!customization) return\n\n if (customization.primaryColor) {\n rules.push(` --primary-custom: ${customization.primaryColor};`)\n }\n\n if (customization.accentColor) {\n rules.push(` --accent-custom: ${customization.accentColor};`)\n }\n\n if (customization.backgroundColor) {\n rules.push(` --background: ${customization.backgroundColor};`)\n rules.push(` --card: ${customization.backgroundColor};`)\n rules.push(` --popover: ${customization.backgroundColor};`)\n }\n\n if (customization.textColor) {\n rules.push(` --foreground: ${customization.textColor};`)\n }\n}\n\nfunction applyBorderRadiusRule(rules: string[], config: ThemeConfiguration): void {\n if (!config.borderRadius) return\n\n const preset = borderRadiusPresets[config.borderRadius]\n if (!preset) return\n\n const cssEntries = Object.entries(preset.css)\n cssEntries.forEach(([property, value]) => {\n rules.push(` ${property}: ${value};`)\n })\n\n const defaultRadius =\n preset.css['--radius-default'] ?? preset.css['--radius-medium'] ?? preset.css['--radius-large']\n if (defaultRadius) {\n rules.push(` --radius: ${defaultRadius};`)\n }\n}\n\nfunction applyFontScaleRules(rules: string[], config: ThemeConfiguration): void {\n if (!config.fontScale) return\n\n const scaleValues: Record<string, string> = {\n small: '0.9',\n medium: '1',\n large: '1.1',\n xl: '1.25',\n }\n\n const scale = scaleValues[config.fontScale] ?? '1'\n rules.push(` --font-scale: ${scale};`)\n rules.push(` --theme-font-scale: ${scale};`)\n\n const baseSizes: Record<string, string> = {\n 'text-xs': '0.75rem',\n 'text-sm': '0.875rem',\n 'text-base': '1rem',\n 'text-lg': '1.125rem',\n 'text-xl': '1.25rem',\n 'text-2xl': '1.5rem',\n 'text-3xl': '1.875rem',\n 'text-4xl': '2.25rem',\n }\n\n Object.entries(baseSizes).forEach(([className, baseSize]) => {\n const scaledSize = parseFloat(baseSize) * parseFloat(scale)\n rules.push(` --${className}: ${scaledSize}rem;`)\n })\n}\n\nfunction applySpacingRule(rules: string[], config: ThemeConfiguration): void {\n if (!config.spacing) return\n\n const spacingMultipliers: Record<string, string> = {\n compact: '0.75',\n medium: '1',\n spacious: '1.5',\n }\n\n const multiplier = spacingMultipliers[config.spacing] ?? '1'\n rules.push(` --spacing-scale: ${multiplier};`)\n rules.push(` --theme-spacing: ${multiplier};`)\n}\n\nfunction applyAnimationRule(rules: string[], config: ThemeConfiguration): void {\n if (!config.animationLevel) return\n\n const animationSettings: Record<string, { duration: string; easing: string; scale: string }> = {\n none: {\n duration: '0s',\n easing: 'linear',\n scale: '0',\n },\n reduced: {\n duration: '0.1s',\n easing: 'ease-out',\n scale: '0.5',\n },\n medium: {\n duration: '0.2s',\n easing: 'ease-out',\n scale: '1',\n },\n full: {\n duration: '0.3s',\n easing: 'cubic-bezier(0.4, 0, 0.2, 1)',\n scale: '1.2',\n },\n }\n\n const level = config.animationLevel as keyof typeof animationSettings\n const settings = animationSettings[level] ?? animationSettings.medium\n if (!settings) return\n rules.push(` --animation-duration: ${settings.duration};`)\n rules.push(` --animation-easing: ${settings.easing};`)\n rules.push(` --animation-scale: ${settings.scale};`)\n rules.push(` --theme-animation-level: ${config.animationLevel};`)\n}\n\nfunction applyTypographyRules(rules: string[], config: ThemeConfiguration): void {\n const typography = config.typography\n if (!typography) return\n\n if (typography.fontFamily) {\n rules.push(` --typography-fontFamily: ${typography.fontFamily};`)\n }\n\n if (typography.headingFamily) {\n rules.push(` --typography-headingFamily: ${typography.headingFamily};`)\n }\n\n if (typography.baseFontSize) {\n rules.push(` --typography-baseFontSize: ${typography.baseFontSize};`)\n }\n\n if (typography.lineHeight) {\n rules.push(` --typography-lineHeight: ${typography.lineHeight};`)\n }\n\n if (typography.fontWeights) {\n Object.entries(typography.fontWeights).forEach(([token, weight]) => {\n if (weight) {\n rules.push(` --typography-fontWeights-${token}: ${weight};`)\n }\n })\n }\n\n if (typography.letterSpacing) {\n Object.entries(typography.letterSpacing).forEach(([token, value]) => {\n if (value) {\n rules.push(` --typography-letterSpacing-${token}: ${value};`)\n }\n })\n }\n}\n\nfunction applyDarkModeOverrides(\n rules: string[],\n config: ThemeConfiguration,\n customization: ThemeCustomization | null | undefined,\n selector: string,\n): void {\n if (config.colorMode !== 'dark' && config.colorMode !== 'auto') return\n\n rules.push('')\n rules.push('@media (prefers-color-scheme: dark) {')\n rules.push(` ${selector} {`)\n\n if (customization?.backgroundColor && isLightBackground(customization.backgroundColor)) {\n rules.push(` --background: hsl(224 71% 4%);`)\n rules.push(` --card: hsl(224 71% 4%);`)\n rules.push(` --popover: hsl(224 71% 4%);`)\n }\n\n if (customization?.textColor && !isLightBackground(customization.textColor)) {\n rules.push(` --foreground: hsl(213 31% 91%);`)\n }\n\n rules.push(' }')\n rules.push('}')\n}\n\nfunction applyReducedMotionOverride(rules: string[], config: ThemeConfiguration): void {\n if (config.animationLevel !== 'none') return\n\n rules.push('')\n rules.push('@media (prefers-reduced-motion: reduce) {')\n rules.push(' *, *::before, *::after {')\n rules.push(' animation-duration: 0.01ms !important;')\n rules.push(' animation-iteration-count: 1 !important;')\n rules.push(' transition-duration: 0.01ms !important;')\n rules.push(' scroll-behavior: auto !important;')\n rules.push(' }')\n rules.push('}')\n}\n\nfunction appendCustomCSS(\n rules: string[],\n customization: ThemeCustomization | null | undefined,\n): void {\n if (!customization?.customCSS) return\n\n rules.push('')\n rules.push('/* Custom CSS */')\n rules.push(customization.customCSS)\n}\n\nfunction applyCustomizationStyleOverrides(\n styles: Record<string, string>,\n customization: ThemeCustomization | null | undefined,\n): void {\n if (!customization) return\n\n if (customization.primaryColor) {\n styles['--primary'] = customization.primaryColor\n }\n\n if (customization.accentColor) {\n styles['--accent'] = customization.accentColor\n }\n\n if (customization.backgroundColor) {\n styles['--background'] = customization.backgroundColor\n styles['--card'] = customization.backgroundColor\n styles['--popover'] = customization.backgroundColor\n }\n\n if (customization.textColor) {\n styles['--foreground'] = customization.textColor\n }\n}\n\nfunction applyTypographyStyleOverrides(\n styles: Record<string, string>,\n typography: ThemeTypographyPreset | null | undefined,\n): void {\n if (!typography) return\n\n if (typography.fontFamily) {\n styles['--font-family-base'] = typography.fontFamily\n }\n\n if (typography.headingFamily) {\n styles['--font-family-heading'] = typography.headingFamily\n }\n\n if (typography.baseFontSize) {\n styles['--font-size-base'] = typography.baseFontSize\n }\n\n if (typography.lineHeight) {\n styles['--line-height-base'] = typography.lineHeight\n }\n}\n"],"names":["borderRadiusPresets","generateThemeCSS","config","cssRules","customization","themeSelector","theme","push","applyCustomizationRootRules","applyBorderRadiusRule","applyFontScaleRules","applySpacingRule","applyAnimationRule","applyTypographyRules","applyDarkModeOverrides","applyReducedMotionOverride","appendCustomCSS","join","isLightBackground","color","lightPatterns","some","pattern","test","getThemeStyles","styles","applyCustomizationStyleOverrides","applyTypographyStyleOverrides","typography","rules","primaryColor","accentColor","backgroundColor","textColor","borderRadius","preset","cssEntries","Object","entries","css","forEach","property","value","defaultRadius","fontScale","scaleValues","small","medium","large","xl","scale","baseSizes","className","baseSize","scaledSize","parseFloat","spacing","spacingMultipliers","compact","spacious","multiplier","animationLevel","animationSettings","none","duration","easing","reduced","full","level","settings","fontFamily","headingFamily","baseFontSize","lineHeight","fontWeights","token","weight","letterSpacing","selector","colorMode","customCSS"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,oCAAmC;AAqBvE;;CAEC,GACD,OAAO,SAASC,iBAAiBC,MAA0B;IACzD,MAAMC,WAAqB,EAAE;IAC7B,MAAMC,gBAAgB,AAACF,OAA+CE,aAAa;IACnF,MAAMC,gBAAgBH,OAAOI,KAAK,GAAG,CAAC,kBAAkB,EAAEJ,OAAOI,KAAK,CAAC,EAAE,CAAC,GAAG;IAE7E,uBAAuB;IACvBH,SAASI,IAAI,CAAC,GAAGF,cAAc,EAAE,CAAC;IAClCG,4BAA4BL,UAAUC;IACtCK,sBAAsBN,UAAUD;IAChCQ,oBAAoBP,UAAUD;IAC9BS,iBAAiBR,UAAUD;IAC3BU,mBAAmBT,UAAUD;IAC7BW,qBAAqBV,UAAUD;IAE/BC,SAASI,IAAI,CAAC;IAEd,gCAAgC;IAChCO,uBAAuBX,UAAUD,QAAQE,eAAeC;IAExD,yDAAyD;IACzDU,2BAA2BZ,UAAUD;IAErC,aAAa;IACbc,gBAAgBb,UAAUC;IAE1B,OAAOD,SAASc,IAAI,CAAC;AACvB;AAEA;;CAEC,GACD,SAASC,kBAAkBC,KAAa;IACtC,mFAAmF;IACnF,MAAMC,gBAAgB;QACpB;QACA;QACA;QACA;KACD;IAED,OAAOA,cAAcC,IAAI,CAAC,CAACC,UAAYA,QAAQC,IAAI,CAACJ;AACtD;AAEA;;CAEC,GACD,OAAO,SAASK,eAAetB,MAA0B;IACvD,MAAMuB,SAAiC,CAAC;IACxC,MAAMrB,gBAAgB,AAACF,OAA+CE,aAAa;IAEnF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,IAAIA,WAAW0C,UAAU,EAAE;QACzB7C,MAAM,CAAC,qBAAqB,GAAGG,WAAW0C,UAAU;IACtD;IAEA,IAAI1C,WAAW2C,aAAa,EAAE;QAC5B9C,MAAM,CAAC,wBAAwB,GAAGG,WAAW2C,aAAa;IAC5D;IAEA,IAAI3C,WAAW4C,YAAY,EAAE;QAC3B/C,MAAM,CAAC,mBAAmB,GAAGG,WAAW4C,YAAY;IACtD;IAEA,IAAI5C,WAAW6C,UAAU,EAAE;QACzBhD,MAAM,CAAC,qBAAqB,GAAGG,WAAW6C,UAAU;IACtD;AACF"}
|
package/package.json
CHANGED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
.theme-color-picker-field {
|
|
2
|
-
margin-bottom: 1rem;
|
|
3
|
-
|
|
4
|
-
.field-header {
|
|
5
|
-
margin-bottom: 0.5rem;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.field-label {
|
|
9
|
-
display: block;
|
|
10
|
-
font-weight: 500;
|
|
11
|
-
font-size: 0.875rem;
|
|
12
|
-
color: var(--theme-text);
|
|
13
|
-
margin-bottom: 0.25rem;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.field-description {
|
|
17
|
-
font-size: 0.75rem;
|
|
18
|
-
color: var(--theme-elevation-400);
|
|
19
|
-
margin-top: 0.25rem;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.color-picker-container {
|
|
23
|
-
display: flex;
|
|
24
|
-
gap: 0.75rem;
|
|
25
|
-
align-items: center;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.color-input-wrapper {
|
|
29
|
-
display: flex;
|
|
30
|
-
gap: 0.5rem;
|
|
31
|
-
flex: 1;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.color-input {
|
|
35
|
-
width: 60px;
|
|
36
|
-
height: 38px;
|
|
37
|
-
border: 1px solid var(--theme-elevation-200);
|
|
38
|
-
border-radius: 4px;
|
|
39
|
-
cursor: pointer;
|
|
40
|
-
padding: 2px;
|
|
41
|
-
|
|
42
|
-
&:hover {
|
|
43
|
-
border-color: var(--theme-elevation-400);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
&:focus {
|
|
47
|
-
outline: 2px solid var(--theme-elevation-500);
|
|
48
|
-
outline-offset: 1px;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.text-input {
|
|
53
|
-
flex: 1;
|
|
54
|
-
height: 38px;
|
|
55
|
-
padding: 0 0.75rem;
|
|
56
|
-
border: 1px solid var(--theme-elevation-200);
|
|
57
|
-
border-radius: 4px;
|
|
58
|
-
font-family: monospace;
|
|
59
|
-
font-size: 0.875rem;
|
|
60
|
-
background: var(--theme-elevation-0);
|
|
61
|
-
color: var(--theme-text);
|
|
62
|
-
|
|
63
|
-
&:hover {
|
|
64
|
-
border-color: var(--theme-elevation-400);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
&:focus {
|
|
68
|
-
outline: 2px solid var(--theme-elevation-500);
|
|
69
|
-
outline-offset: 1px;
|
|
70
|
-
border-color: var(--theme-elevation-500);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
&::placeholder {
|
|
74
|
-
color: var(--theme-elevation-400);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
&:invalid {
|
|
78
|
-
border-color: #ef4444;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.color-preview {
|
|
83
|
-
width: 120px;
|
|
84
|
-
height: 38px;
|
|
85
|
-
border-radius: 4px;
|
|
86
|
-
border: 1px solid var(--theme-elevation-200);
|
|
87
|
-
display: flex;
|
|
88
|
-
align-items: center;
|
|
89
|
-
justify-content: center;
|
|
90
|
-
position: relative;
|
|
91
|
-
overflow: hidden;
|
|
92
|
-
|
|
93
|
-
.preview-label {
|
|
94
|
-
font-size: 0.75rem;
|
|
95
|
-
font-family: monospace;
|
|
96
|
-
padding: 0.25rem 0.5rem;
|
|
97
|
-
background: rgba(255, 255, 255, 0.9);
|
|
98
|
-
border-radius: 2px;
|
|
99
|
-
backdrop-filter: blur(4px);
|
|
100
|
-
color: #000;
|
|
101
|
-
font-weight: 500;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
.mini-preview {
|
|
106
|
-
margin-top: 1rem;
|
|
107
|
-
padding: 1rem;
|
|
108
|
-
border-radius: 6px;
|
|
109
|
-
border: 1px solid;
|
|
110
|
-
|
|
111
|
-
.preview-card {
|
|
112
|
-
padding: 1rem;
|
|
113
|
-
border-radius: 4px;
|
|
114
|
-
border: 1px solid;
|
|
115
|
-
display: flex;
|
|
116
|
-
gap: 0.5rem;
|
|
117
|
-
flex-wrap: wrap;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
.preview-button {
|
|
121
|
-
padding: 0.5rem 1rem;
|
|
122
|
-
border-radius: 4px;
|
|
123
|
-
border: none;
|
|
124
|
-
font-size: 0.875rem;
|
|
125
|
-
font-weight: 500;
|
|
126
|
-
cursor: pointer;
|
|
127
|
-
transition: opacity 0.2s;
|
|
128
|
-
|
|
129
|
-
&:hover {
|
|
130
|
-
opacity: 0.9;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
&.secondary {
|
|
134
|
-
border: 1px solid currentColor;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
.theme-color-picker-field {
|
|
2
|
-
margin-bottom: 1rem;
|
|
3
|
-
|
|
4
|
-
.field-header {
|
|
5
|
-
margin-bottom: 0.5rem;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.field-label {
|
|
9
|
-
display: block;
|
|
10
|
-
font-weight: 500;
|
|
11
|
-
font-size: 0.875rem;
|
|
12
|
-
color: var(--theme-text);
|
|
13
|
-
margin-bottom: 0.25rem;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.field-description {
|
|
17
|
-
font-size: 0.75rem;
|
|
18
|
-
color: var(--theme-elevation-400);
|
|
19
|
-
margin-top: 0.25rem;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.color-picker-container {
|
|
23
|
-
display: flex;
|
|
24
|
-
gap: 0.75rem;
|
|
25
|
-
align-items: center;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.color-input-wrapper {
|
|
29
|
-
display: flex;
|
|
30
|
-
gap: 0.5rem;
|
|
31
|
-
flex: 1;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.color-input {
|
|
35
|
-
width: 60px;
|
|
36
|
-
height: 38px;
|
|
37
|
-
border: 1px solid var(--theme-elevation-200);
|
|
38
|
-
border-radius: 4px;
|
|
39
|
-
cursor: pointer;
|
|
40
|
-
padding: 2px;
|
|
41
|
-
|
|
42
|
-
&:hover {
|
|
43
|
-
border-color: var(--theme-elevation-400);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
&:focus {
|
|
47
|
-
outline: 2px solid var(--theme-elevation-500);
|
|
48
|
-
outline-offset: 1px;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.text-input {
|
|
53
|
-
flex: 1;
|
|
54
|
-
height: 38px;
|
|
55
|
-
padding: 0 0.75rem;
|
|
56
|
-
border: 1px solid var(--theme-elevation-200);
|
|
57
|
-
border-radius: 4px;
|
|
58
|
-
font-family: monospace;
|
|
59
|
-
font-size: 0.875rem;
|
|
60
|
-
background: var(--theme-elevation-0);
|
|
61
|
-
color: var(--theme-text);
|
|
62
|
-
|
|
63
|
-
&:hover {
|
|
64
|
-
border-color: var(--theme-elevation-400);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
&:focus {
|
|
68
|
-
outline: 2px solid var(--theme-elevation-500);
|
|
69
|
-
outline-offset: 1px;
|
|
70
|
-
border-color: var(--theme-elevation-500);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
&::placeholder {
|
|
74
|
-
color: var(--theme-elevation-400);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
&:invalid {
|
|
78
|
-
border-color: #ef4444;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.color-preview {
|
|
83
|
-
width: 120px;
|
|
84
|
-
height: 38px;
|
|
85
|
-
border-radius: 4px;
|
|
86
|
-
border: 1px solid var(--theme-elevation-200);
|
|
87
|
-
display: flex;
|
|
88
|
-
align-items: center;
|
|
89
|
-
justify-content: center;
|
|
90
|
-
position: relative;
|
|
91
|
-
overflow: hidden;
|
|
92
|
-
|
|
93
|
-
.preview-label {
|
|
94
|
-
font-size: 0.75rem;
|
|
95
|
-
font-family: monospace;
|
|
96
|
-
padding: 0.25rem 0.5rem;
|
|
97
|
-
background: rgba(255, 255, 255, 0.9);
|
|
98
|
-
border-radius: 2px;
|
|
99
|
-
backdrop-filter: blur(4px);
|
|
100
|
-
color: #000;
|
|
101
|
-
font-weight: 500;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
.mini-preview {
|
|
106
|
-
margin-top: 1rem;
|
|
107
|
-
padding: 1rem;
|
|
108
|
-
border-radius: 6px;
|
|
109
|
-
border: 1px solid;
|
|
110
|
-
|
|
111
|
-
.preview-card {
|
|
112
|
-
padding: 1rem;
|
|
113
|
-
border-radius: 4px;
|
|
114
|
-
border: 1px solid;
|
|
115
|
-
display: flex;
|
|
116
|
-
gap: 0.5rem;
|
|
117
|
-
flex-wrap: wrap;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
.preview-button {
|
|
121
|
-
padding: 0.5rem 1rem;
|
|
122
|
-
border-radius: 4px;
|
|
123
|
-
border: none;
|
|
124
|
-
font-size: 0.875rem;
|
|
125
|
-
font-weight: 500;
|
|
126
|
-
cursor: pointer;
|
|
127
|
-
transition: opacity 0.2s;
|
|
128
|
-
|
|
129
|
-
&:hover {
|
|
130
|
-
opacity: 0.9;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
&.secondary {
|
|
134
|
-
border: 1px solid currentColor;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|