You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: app/content/pages/articles/custom-color-schemes-with-ruby-on-rails.html.mdrb
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,7 @@ Pretty cool, huh? Here are the key ingredients:
31
31
- [Cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies): A session cookie to store your saved color scheme selection
32
32
- [Hotwire](https://hotwired.dev/): Server-rendered HTML and a single-page app experience powered by Rails, [Turbo Drive](https://turbo.hotwired.dev/handbook/introduction#turbo-drive%3A-navigate-within-a-persistent-process), and [Turbo Frames](https://turbo.hotwired.dev/handbook/introduction#turbo-frames%3A-decompose-complex-pages)
33
33
34
-
I started with the premise of using a monochromatic color scheme based on the 11 color scale Tailwind uses for each of [its default color sets](https://tailwindcss.com/docs/customizing-colors). The curated options are all generated from [uicolors.app](https://uicolors.app/create).
34
+
I started with the premise of using a monochromatic color scheme based on the eleven-item color scale [Tailwind](https://tailwindcss.com) uses for each of [its default color sets](https://tailwindcss.com/docs/customizing-colors). The curated options are all generated from [uicolors.app](https://uicolors.app/create).
35
35
36
36
Each color scheme is a row in the `color_schemes` table, with a name and CSS hex code values for each of the eleven weights.
37
37
@@ -51,7 +51,7 @@ end
51
51
52
52
CSS variables make it easy to change repeated CSS in a lot of places. You can set a CSS variable with double dashes, `--`. The CSS variable can be accessed using the `var()` expression. CSS variables can be overridden and can be defined in terms of other variables.
53
53
54
-
Here’s a simplified a view of how I used CSS variables to define the main background color of the `<body>` element.
54
+
Here’s a simplified a view of how I used CSS variables to define the main background color of the `<body>` element. Using the pseudo-class `:root` means the CSS variable can be accessed from any scope in CSS.
55
55
56
56
```css:{"show_header": false}
57
57
:root {
@@ -66,9 +66,11 @@ body {
66
66
}
67
67
```
68
68
69
-
Even though Joy of Rails does not use Tailwind, this approach is consistent with [the Tailwind docs for using CSS variables to customize Tailwind colors](https://tailwindcss.com/docs/customizing-colors#using-css-variables).
69
+
This approach is consistent with [the Tailwind docs for using CSS variables to customize Tailwind colors](https://tailwindcss.com/docs/customizing-colors#using-css-variables) for those of you that may be using (or interested in using) Tailwind.
70
70
71
-
When you click the "Save" button, the application stores the `id` of the chosen color scheme in your Rails session:
71
+
Most of the buttons in the color scheme demo are connected to `<form>` elements with actions that point to the [`ColorSchemesController`](https://github.com/joyofrails/joyofrails.com/blob/a08589e1cbe2accf4a20713829df56533e31755e/app/controllers/settings/color_schemes_controller.rb) in the Joy of Rails application.
72
+
73
+
When you click the "Save" button, [the application stores the `id` of the chosen color scheme in your Rails session](https://github.com/joyofrails/joyofrails.com/blob/a08589e1cbe2accf4a20713829df56533e31755e/app/controllers/settings/color_schemes_controller.rb#L31):
0 commit comments