diff --git a/apps/v4/components/theme-customizer.tsx b/apps/v4/components/theme-customizer.tsx index 39bea7c12a..31f7a96347 100644 --- a/apps/v4/components/theme-customizer.tsx +++ b/apps/v4/components/theme-customizer.tsx @@ -124,9 +124,7 @@ export function CopyCodeButton({ - - {activeThemeName === "neutral" ? "Default" : activeThemeName} - + {activeThemeName} Copy and paste the following code into your CSS file. @@ -149,9 +147,7 @@ export function CopyCodeButton({ - - {activeThemeName === "neutral" ? "Default" : activeThemeName} - + {activeThemeName} Copy and paste the following code into your CSS file. @@ -165,7 +161,7 @@ export function CopyCodeButton({ function CustomizerCode({ themeName }: { themeName: string }) { const [hasCopied, setHasCopied] = React.useState(false) - const [tailwindVersion, setTailwindVersion] = React.useState("v4") + const [tailwindVersion, setTailwindVersion] = React.useState("v4-oklch") const activeTheme = React.useMemo( () => baseColors.find((theme) => theme.name === themeName), [themeName] @@ -191,10 +187,11 @@ function CustomizerCode({ themeName }: { themeName: string }) { className="min-w-0 px-4 pb-4 md:p-0" > - Tailwind v4 + OKLCH + HSL Tailwind v3 - +
{ copyToClipboardWithMeta( - tailwindVersion === "v3" - ? getThemeCode(activeTheme, 0.65) - : getThemeCodeOKLCH(activeThemeOKLCH, 0.65), + getThemeCodeOKLCH(activeThemeOKLCH, 0.65), { name: "copy_theme_code", properties: { theme: themeName, - radius: 0.5, + radius: 0.65, }, } ) @@ -246,7 +241,8 @@ function CustomizerCode({ themeName }: { themeName: string }) { className="line text-code-foreground" key={key} > -    --{key}: {value}; +    --{key}: {" "} + {value}; ))} @@ -264,7 +260,8 @@ function CustomizerCode({ themeName }: { themeName: string }) { className="line text-code-foreground" key={key} > -    --{key}: {value}; +    --{key}: {" "} + {value}; ))} @@ -274,6 +271,90 @@ function CustomizerCode({ themeName }: { themeName: string }) {
+ +
+
+ + app/globals.css +
+
+              
+              
+                
+                   :root {
+                
+                
+                     --radius: 0.65rem;
+                
+                {Object.entries(activeTheme?.cssVars.light || {}).map(
+                  ([key, value]) => (
+                    
+                         --{key}:{" "}
+                       hsl({value});
+                    
+                  )
+                )}
+                
+                   }
+                
+                
+                   
+                
+                
+                   .dark {
+                
+                {Object.entries(activeTheme?.cssVars.dark || {}).map(
+                  ([key, value]) => (
+                    
+                         --{key}:{" "}
+                       hsl({value});
+                    
+                  )
+                )}
+                
+                   }
+                
+              
+            
+
+
{ - copyToClipboardWithMeta( - tailwindVersion === "v3" - ? getThemeCode(activeTheme, 0.65) - : getThemeCodeOKLCH(activeThemeOKLCH, 0.65), - { - name: "copy_theme_code", - properties: { - theme: themeName, - radius: 0.5, - }, - } - ) + copyToClipboardWithMeta(getThemeCode(activeTheme, 0.5), { + name: "copy_theme_code", + properties: { + theme: themeName, + radius: 0.5, + }, + }) setHasCopied(true) }} > @@ -322,10 +398,16 @@ function CustomizerCode({ themeName }: { themeName: string }) {     --background:{" "} + {" "} {activeTheme?.cssVars.light["background"]};     --foreground:{" "} + {" "} {activeTheme?.cssVars.light["foreground"]}; {[ @@ -340,6 +422,13 @@ function CustomizerCode({ themeName }: { themeName: string }) {     --{prefix}:{" "} + {" "} { activeTheme?.cssVars.light[ prefix as keyof typeof activeTheme.cssVars.light @@ -349,6 +438,13 @@ function CustomizerCode({ themeName }: { themeName: string }) {     --{prefix}-foreground:{" "} + {" "} { activeTheme?.cssVars.light[ `${prefix}-foreground` as keyof typeof activeTheme.cssVars.light @@ -360,14 +456,23 @@ function CustomizerCode({ themeName }: { themeName: string }) { ))}     --border:{" "} + {" "} {activeTheme?.cssVars.light["border"]};     --input:{" "} + {" "} {activeTheme?.cssVars.light["input"]};     --ring:{" "} + {" "} {activeTheme?.cssVars.light["ring"]}; @@ -378,6 +483,13 @@ function CustomizerCode({ themeName }: { themeName: string }) {     --{prefix}:{" "} + {" "} { activeTheme?.cssVars.light[ prefix as keyof typeof activeTheme.cssVars.light @@ -399,10 +511,16 @@ function CustomizerCode({ themeName }: { themeName: string }) {     --background:{" "} + {" "} {activeTheme?.cssVars.dark["background"]};     --foreground:{" "} + {" "} {activeTheme?.cssVars.dark["foreground"]}; {[ @@ -417,6 +535,13 @@ function CustomizerCode({ themeName }: { themeName: string }) {     --{prefix}:{" "} + {" "} { activeTheme?.cssVars.dark[ prefix as keyof typeof activeTheme.cssVars.dark @@ -426,6 +551,13 @@ function CustomizerCode({ themeName }: { themeName: string }) {     --{prefix}-foreground:{" "} + {" "} { activeTheme?.cssVars.dark[ `${prefix}-foreground` as keyof typeof activeTheme.cssVars.dark @@ -437,14 +569,23 @@ function CustomizerCode({ themeName }: { themeName: string }) { ))}     --border:{" "} + {" "} {activeTheme?.cssVars.dark["border"]};     --input:{" "} + {" "} {activeTheme?.cssVars.dark["input"]};     --ring:{" "} + {" "} {activeTheme?.cssVars.dark["ring"]}; {["chart-1", "chart-2", "chart-3", "chart-4", "chart-5"].map( @@ -452,6 +593,13 @@ function CustomizerCode({ themeName }: { themeName: string }) {     --{prefix}:{" "} + {" "} { activeTheme?.cssVars.dark[ prefix as keyof typeof activeTheme.cssVars.dark @@ -477,6 +625,15 @@ function CustomizerCode({ themeName }: { themeName: string }) { ) } +function ColorIndicator({ color }: { color: string }) { + return ( + + ) +} + function getThemeCodeOKLCH(theme: BaseColorOKLCH | undefined, radius: number) { if (!theme) { return "" @@ -509,6 +666,27 @@ function getThemeCode(theme: BaseColor | undefined, radius: number) { }) } +function getThemeCodeHSLV4(theme: BaseColor | undefined, radius: number) { + if (!theme) { + return "" + } + + const rootSection = + ":root {\n --radius: " + + radius + + "rem;\n" + + Object.entries(theme.cssVars.light) + .map((entry) => " --" + entry[0] + ": hsl(" + entry[1] + ");") + .join("\n") + + "\n}\n\n.dark {\n" + + Object.entries(theme.cssVars.dark) + .map((entry) => " --" + entry[0] + ": hsl(" + entry[1] + ");") + .join("\n") + + "\n}\n" + + return rootSection +} + const BASE_STYLES_WITH_VARIABLES = ` @layer base { :root {