@@ -8,9 +8,11 @@ def view_template
88 div ( class : "space-y-4" ) do
99 Components . Heading ( level : 2 ) { "Introduction" }
1010 Text do
11- plain "Phlex UI uses CSS Variables like "
12- InlineCode { "--primary: 0 0% 9%" }
13- plain " for theming. This allows you to easily customize the look and feel of your application."
11+ plain "RubyUI uses CSS Variables like "
12+ InlineCode { "--primary: oklch(0.205 0 0)" }
13+ plain " for theming. This approach is inspired by "
14+ InlineLink ( href : "https://ui.shadcn.com" ) { "shadcn/ui" }
15+ plain " and allows you to easily customize the look and feel of your application."
1416 end
1517 # List the 2 benefits. That we can use CSS variables to change the style, without changing the tailwindcss classes used
1618 # And that we can change the style of a particular tailwindcss class for both light and dark mode, without having to duplicate the tailwindcss class
@@ -60,19 +62,19 @@ def view_template
6062 end
6163 Text { "Given the following CSS variables:" }
6264 code = <<~CODE
63- --primary: 222.2 47.4% 11.2% ;
64- --primary-foreground: 210 40% 98% ;
65+ --primary: oklch(0.205 0 0) ;
66+ --primary-foreground: oklch(0.985 0 0) ;
6567 CODE
6668 Codeblock ( code , syntax : :css )
6769 Text do
6870 plain "The "
6971 InlineCode { "background" }
7072 plain " color of the following component will be "
71- InlineCode { "hsl( var(--primary) )" }
73+ InlineCode { "var(--primary)" }
7274 plain " and the "
7375 InlineCode { "foreground" }
7476 plain " color will be "
75- InlineCode { "hsl( var(--primary-foreground) )" }
77+ InlineCode { "var(--primary-foreground)" }
7678 plain "."
7779 end
7880 code = <<~CODE
@@ -81,8 +83,8 @@ def view_template
8183 Codeblock ( code , syntax : :html )
8284 Alert ( class : "bg-transparent" ) do
8385 AlertDescription do
84- span ( class : "font-medium" ) { "CSS variables must be defined without color space function " }
85- plain ". See the "
86+ span ( class : "font-medium" ) { "RubyUI uses oklch color format " }
87+ plain ", the same format used by shadcn/ui . See the "
8688 InlineLink ( href : "https://tailwindcss.com/docs/customizing-colors#using-css-variables" ) { "Tailwind CSS documentation" }
8789 plain " for more information."
8890 end
@@ -110,26 +112,42 @@ def view_template
110112 end
111113
112114 div ( class : "space-y-4" ) do
113- Heading ( level : 2 ) { "Other color formats " }
115+ Heading ( level : 2 ) { "Color format (oklch) " }
114116 Text do
115- plain "It's recommended to use "
116- InlineLink ( href : "https://www.smashingmagazine.com/2021/07/hsl-colors-css/" ) { "HSL colors" }
117- plain " for your application. However, you can also use other color formats such as "
118- InlineCode { "rgb" }
119- plain " or "
120- InlineCode { "rgba" }
121- plain "."
117+ plain "RubyUI uses "
118+ InlineLink ( href : "https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/oklch" ) { "oklch colors" }
119+ plain " as the default color format. This is the same format used by "
120+ InlineLink ( href : "https://ui.shadcn.com" ) { "shadcn/ui" }
121+ plain " and provides better perceptual uniformity and wider color gamut support."
122122 end
123123 Text do
124- plain "See "
125- InlineLink ( href : "https://tailwindcss.com/docs/customizing-colors#using-css-variables" ) { "Tailwind CSS documentation " }
126- plain " for more information on how to use "
127- InlineCode { "rgb " }
124+ plain "While "
125+ InlineCode { "oklch " }
126+ plain " is recommended, you can also use other color formats such as "
127+ InlineCode { "hsl " }
128128 plain ", "
129+ InlineCode { "rgb" }
130+ plain ", or "
129131 InlineCode { "rgba" }
130- plain " or "
131- InlineCode { "hsl" }
132- plain " colors."
132+ plain ". See the "
133+ InlineLink ( href : "https://tailwindcss.com/docs/customizing-colors#using-css-variables" ) { "Tailwind CSS documentation" }
134+ plain " for more information."
135+ end
136+ end
137+
138+ div ( class : "space-y-4" ) do
139+ Heading ( level : 2 ) { "shadcn/ui themes" }
140+ Text do
141+ plain "RubyUI themes use the same CSS variable convention as "
142+ InlineLink ( href : "https://ui.shadcn.com" ) { "shadcn/ui" }
143+ plain ". This means you can copy themes directly from "
144+ InlineLink ( href : "https://ui.shadcn.com/themes" ) { "shadcn/ui themes" }
145+ plain " and use them in your RubyUI application."
146+ end
147+ Text do
148+ plain "Visit the "
149+ InlineLink ( href : "/themes/default" ) { "RubyUI themes page" }
150+ plain " to preview and copy themes, just like you would on shadcn/ui."
133151 end
134152 end
135153 end
@@ -139,85 +157,85 @@ def css_variables
139157 space_y_2 do
140158 Text ( size : "2" , weight : "medium" ) { "Default background color of <body>...etc" }
141159 code = <<~CODE
142- --background: 0 0% 100% ;
143- --foreground: 222.2 47.4% 11.2% ;
160+ --background: oklch(1 0 0) ;
161+ --foreground: oklch(0.145 0 0) ;
144162 CODE
145163 Codeblock ( code , syntax : :css )
146164 end
147165
148166 space_y_2 do
149167 Text ( size : "2" , weight : "medium" ) { "Muted backgrounds such as TabsList" }
150168 code = <<~CODE
151- --muted: 210 40% 96.1% ;
152- --muted-foreground: 215.4 16.3% 46.9% ;
169+ --muted: oklch(0.97 0 0) ;
170+ --muted-foreground: oklch(0.556 0 0) ;
153171 CODE
154172 Codeblock ( code , syntax : :css )
155173 end
156174
157175 space_y_2 do
158176 Text ( size : "2" , weight : "medium" ) { "Default border color" }
159177 code = <<~CODE
160- --border: 214.3 31.8% 91.4% ;
178+ --border: oklch(0.922 0 0) ;
161179 CODE
162180 Codeblock ( code , syntax : :css )
163181 end
164182
165183 space_y_2 do
166184 Text ( size : "2" , weight : "medium" ) { "Border color for inputs such as Input, Select or Textarea" }
167185 code = <<~CODE
168- --input: 214.3 31.8% 91.4% ;
186+ --input: oklch(0.922 0 0) ;
169187 CODE
170188 Codeblock ( code , syntax : :css )
171189 end
172190
173191 space_y_2 do
174192 Text ( size : "2" , weight : "medium" ) { "Primary colors for Button" }
175193 code = <<~CODE
176- --primary: 222.2 47.4% 11.2% ;
177- --primary-foreground: 210 40% 98% ;
194+ --primary: oklch(0.205 0 0) ;
195+ --primary-foreground: oklch(0.985 0 0) ;
178196 CODE
179197 Codeblock ( code , syntax : :css )
180198 end
181199
182200 space_y_2 do
183201 Text ( size : "2" , weight : "medium" ) { "Secondary colors for Button" }
184202 code = <<~CODE
185- --secondary: 210 40% 96.1% ;
186- --secondary-foreground: 222.2 47.4% 11.2% ;
203+ --secondary: oklch(0.97 0 0) ;
204+ --secondary-foreground: oklch(0.205 0 0) ;
187205 CODE
188206 Codeblock ( code , syntax : :css )
189207 end
190208
191209 space_y_2 do
192210 Text ( size : "2" , weight : "medium" ) { "Used for accents such as hover effects on DropdownMenu::Item, Select::Item... etc" }
193211 code = <<~CODE
194- --accent: 210 40% 96.1% ;
195- --accent-foreground: 222.2 47.4% 11.2% ;
212+ --accent: oklch(0.97 0 0) ;
213+ --accent-foreground: oklch(0.205 0 0) ;
196214 CODE
197215 Codeblock ( code , syntax : :css )
198216 end
199217
200218 space_y_2 do
201219 Text ( size : "2" , weight : "medium" ) { "Used for destructive actions such as Button.new(variant: :destructive)" }
202220 code = <<~CODE
203- --destructive: 0 100% 50% ;
204- --destructive-foreground: 210 40% 98% ;
221+ --destructive: oklch(0.577 0.245 27.325) ;
222+ --destructive-foreground: oklch(0.577 0.245 27.325) ;
205223 CODE
206224 Codeblock ( code , syntax : :css )
207225 end
208226
209227 space_y_2 do
210228 Text ( size : "2" , weight : "medium" ) { "Used for focus ring" }
211229 code = <<~CODE
212- --ring: 215 20.2% 65.1% ;
230+ --ring: oklch(0.708 0 0) ;
213231 CODE
214232 Codeblock ( code , syntax : :css )
215233 end
216234
217235 space_y_2 do
218236 Text ( size : "2" , weight : "medium" ) { "Border radius for card, input and buttons" }
219237 code = <<~CODE
220- --radius: 0.5rem ;
238+ --radius: 0.625rem ;
221239 CODE
222240 Codeblock ( code , syntax : :css )
223241 end
@@ -231,33 +249,27 @@ def adding_a_color
231249 end
232250 code = <<~CODE
233251 :root {
234- --contrast: 38 92% 50% ;
235- --contrast-foreground: 48 96% 89% ;
252+ --contrast: oklch(0.75 0.18 85) ;
253+ --contrast-foreground: oklch(0.25 0.05 85) ;
236254 }
237255
238256 .dark {
239- --contrast: 48 96% 89% ;
240- --contrast-foreground: 38 92% 50% ;
257+ --contrast: oklch(0.85 0.15 85) ;
258+ --contrast-foreground: oklch(0.2 0.05 85) ;
241259 }
242260 CODE
243261 Codeblock ( code , syntax : :css )
244262 end
245263
246264 space_y_2 do
247- Text ( size : "2" , weight : "medium" ) { "tailwind.config.js " }
265+ Text ( size : "2" , weight : "medium" ) { "application. tailwind.css (inside @theme inline) " }
248266 code = <<~CODE
249- module.exports = {
250- theme: {
251- extend: {
252- colors: {
253- contrast: "hsl(var(--contrast))",
254- "contrast-foreground": "hsl(var(--contrast-foreground))",
255- },
256- },
257- },
267+ @theme inline {
268+ --color-contrast: var(--contrast);
269+ --color-contrast-foreground: var(--contrast-foreground);
258270 }
259271 CODE
260- Codeblock ( code , syntax : :javascript )
272+ Codeblock ( code , syntax : :css )
261273 end
262274
263275 Text do
0 commit comments