2
2
3
3
class ColorThemes ::ShowView < ApplicationView
4
4
include Phlex ::Rails ::Helpers ::FormWith
5
+ include Phlex ::Rails ::Helpers ::LinkTo
5
6
6
7
def initialize ( color_scale :, curated_color_scales : [ ] )
7
8
@color_scale = color_scale
@@ -11,8 +12,6 @@ def initialize(color_scale:, curated_color_scales: [])
11
12
def view_template
12
13
render Pages ::Header . new ( title : "Settings: Color Theme" )
13
14
div ( class : "section-content container py-gap" ) do
14
- p { "You can preview and save your desired color theme for this site. We have curated some options for you below." }
15
-
16
15
h3 { @color_scale . display_name }
17
16
div ( class : "color-theme color-theme:#{ @color_scale . name . parameterize } " ) do
18
17
@color_scale . weights . each do |weight , color |
@@ -24,12 +23,23 @@ def view_template
24
23
end
25
24
26
25
h3 { "Want to try a different color theme?" }
26
+ p { "You can preview and save your desired color theme for this site. We have curated some options for you below." }
27
+
27
28
form_with ( url : color_theme_path , method : :get ) do |f |
28
- fieldset do
29
- f . select :id , @curated_color_scales . map { |cs | [ cs . display_name , cs . id ] } , include_blank : "Pick one!"
30
- end
31
- fieldset do
32
- f . submit "Show me!" , class : "button primary"
29
+ fieldset ( class : "flex items-center" ) do
30
+ f . select :id ,
31
+ @curated_color_scales . map { |cs | [ cs . display_name , cs . id ] } ,
32
+ {
33
+ prompt : "Pick one!"
34
+ } ,
35
+ # https://stackoverflow.com/questions/68624668/how-can-i-submit-a-form-on-input-change-with-turbo-streams
36
+ onchange : "this.form.requestSubmit()" ,
37
+ class : "mr-2 bg-gray-50 border border-gray-300 text-small rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
38
+
39
+ whitespace
40
+ span ( class : "mr-2 font-small" ) { "OR" }
41
+ whitespace
42
+ link_to "I feel lucky!" , color_theme_path ( id : @curated_color_scales . sample . id ) , class : "button primary"
33
43
end
34
44
end
35
45
end
0 commit comments