baldur 0.2.0 → 0.2.3
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.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/TODO.md +7 -1
- data/app/assets/stylesheets/baldur/application/components/auth-page.css +7 -0
- data/app/assets/tailwind/baldur/engine.css +2 -2
- data/app/helpers/baldur/marketing_helper.rb +71 -69
- data/app/helpers/baldur/optional/auth_page_helper.rb +4 -2
- data/app/helpers/baldur/optional/google_auth_helper.rb +2 -2
- data/app/helpers/baldur/optional/panel_secondary_helper.rb +3 -2
- data/app/helpers/baldur/ui_helper.rb +151 -138
- data/app/helpers/baldur/ui_helper_feedback.rb +38 -36
- data/app/helpers/baldur/ui_helper_forms.rb +81 -76
- data/app/helpers/baldur/ui_helper_sidebar.rb +6 -5
- data/app/helpers/baldur/ui_helper_unavailable.rb +17 -15
- data/app/views/baldur/components/_theme_toggle.html.erb +23 -0
- data/app/views/baldur/optional/_auth_page.html.erb +6 -0
- data/baldur.gemspec +23 -23
- data/config/importmap.rb +2 -2
- data/lib/baldur/configuration.rb +6 -6
- data/lib/baldur/engine.rb +3 -3
- data/lib/baldur/version.rb +1 -1
- data/lib/baldur.rb +5 -5
- data/lib/generators/baldur/install/install_generator.rb +19 -19
- data/lib/generators/baldur/install/templates/baldur_initializer.rb +7 -7
- data/lib/generators/baldur/install/templates/theme.css +32 -6
- data/lib/generators/baldur/install_google_auth/install_google_auth_generator.rb +2 -2
- data/lib/generators/baldur/install_panel_right/install_panel_right_generator.rb +2 -2
- data/lib/generators/baldur/install_panel_secondary/install_panel_secondary_generator.rb +3 -3
- data/script/verify_host_install +59 -31
- data/test/confirmation_modal_helper_test.rb +34 -34
- data/test/csp_rendering_test.rb +21 -21
- data/test/engine_css_test.rb +36 -0
- data/test/fixtures/shared/_brand_lockup.html.erb +1 -0
- data/test/gemspec_test.rb +7 -5
- data/test/install_generator_test.rb +25 -21
- data/test/install_panel_secondary_generator_test.rb +12 -9
- data/test/marketing_helper_test.rb +7 -7
- data/test/run_all.rb +1 -1
- data/test/sidebar_helper_test.rb +16 -16
- data/test/test_helper.rb +14 -14
- data/test/theme_toggle_helper_test.rb +119 -0
- data/test/tmp/install_generator/app/assets/stylesheets/theme.css +32 -6
- data/test/tmp/install_generator/config/initializers/baldur.rb +7 -7
- metadata +5 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
module Baldur
|
|
2
2
|
module UiHelperForms
|
|
3
|
-
def ui_text_field_tag(name, value = nil, label: nil, supporting_text: nil, placeholder: nil, type: :text,
|
|
3
|
+
def ui_text_field_tag(name, value = nil, label: nil, supporting_text: nil, placeholder: nil, type: :text,
|
|
4
|
+
required: false, disabled: false, wrapper_class: nil, input_class: nil, input_options: {}, multiline: false, prefix: nil, suffix: nil, &block)
|
|
4
5
|
options = (input_options || {}).deep_dup
|
|
5
6
|
input_id = options[:id].presence || "ui-text-field-#{SecureRandom.hex(3)}"
|
|
6
|
-
field_classes = [
|
|
7
|
-
control_classes = [
|
|
7
|
+
field_classes = ['field', 'text-field', ('is-disabled' if disabled), wrapper_class].compact.join(' ')
|
|
8
|
+
control_classes = ['text-field__control', input_class, options[:class]].compact.join(' ')
|
|
8
9
|
support_id = "#{input_id}-support"
|
|
9
10
|
|
|
10
11
|
options[:id] = input_id
|
|
@@ -16,35 +17,36 @@ module Baldur
|
|
|
16
17
|
options[:name] = name
|
|
17
18
|
options[:value] = value unless value.nil? || multiline
|
|
18
19
|
aria = options[:aria].presence || {}
|
|
19
|
-
aria[:describedby] = [
|
|
20
|
+
aria[:describedby] = [aria[:describedby], support_id].compact.join(' ').presence
|
|
20
21
|
options[:aria] = aria if aria.present?
|
|
21
22
|
|
|
22
|
-
baldur_render
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
baldur_render 'baldur/components/text_field',
|
|
24
|
+
wrapper_classes: field_classes,
|
|
25
|
+
label: label,
|
|
26
|
+
supporting_text: supporting_text,
|
|
27
|
+
input_options: options,
|
|
28
|
+
input_value: multiline ? value.to_s : nil,
|
|
29
|
+
multiline: multiline,
|
|
30
|
+
prefix: prefix,
|
|
31
|
+
suffix: suffix,
|
|
32
|
+
support_id: support_id,
|
|
33
|
+
supporting_slot: block_given? ? capture(&block) : nil
|
|
33
34
|
end
|
|
34
35
|
|
|
35
|
-
def ui_date_field_tag(name, value = nil, label: nil, supporting_text: nil, placeholder:
|
|
36
|
+
def ui_date_field_tag(name, value = nil, label: nil, supporting_text: nil, placeholder: 'YYYY-MM-DD',
|
|
37
|
+
required: false, disabled: false, wrapper_class: nil, input_class: nil, input_options: {}, native_input_options: {}, toggle_label: 'Open date picker', icon_name: 'calendar', min_date: nil, max_date: nil)
|
|
36
38
|
display_options = (input_options || {}).deep_dup
|
|
37
39
|
native_options = (native_input_options || {}).deep_dup
|
|
38
40
|
input_id = display_options[:id].presence || "ui-date-field-#{SecureRandom.hex(3)}"
|
|
39
41
|
support_id = "#{input_id}-support"
|
|
40
|
-
wrapper_classes = [
|
|
42
|
+
wrapper_classes = ['field', 'date-field', wrapper_class].compact.join(' ')
|
|
41
43
|
|
|
42
44
|
parsed_date = case value
|
|
43
|
-
|
|
45
|
+
when Date
|
|
44
46
|
value
|
|
45
|
-
|
|
47
|
+
when Time, DateTime, ActiveSupport::TimeWithZone
|
|
46
48
|
value.to_date
|
|
47
|
-
|
|
49
|
+
when String
|
|
48
50
|
begin
|
|
49
51
|
Date.iso8601(value)
|
|
50
52
|
rescue ArgumentError
|
|
@@ -54,105 +56,107 @@ module Baldur
|
|
|
54
56
|
nil
|
|
55
57
|
end
|
|
56
58
|
end
|
|
57
|
-
|
|
59
|
+
else
|
|
58
60
|
value.respond_to?(:to_date) ? value.to_date : nil
|
|
59
|
-
|
|
60
|
-
iso_value = parsed_date&.strftime(
|
|
61
|
+
end
|
|
62
|
+
iso_value = parsed_date&.strftime('%Y-%m-%d')
|
|
61
63
|
native_id = native_options[:id].presence || "#{input_id}-native"
|
|
62
64
|
|
|
63
65
|
display_value = if display_options.key?(:value)
|
|
64
66
|
display_options[:value]
|
|
65
|
-
|
|
67
|
+
else
|
|
66
68
|
iso_value.presence || value.to_s.presence
|
|
67
|
-
|
|
69
|
+
end
|
|
68
70
|
|
|
69
71
|
display_options[:id] = input_id
|
|
70
|
-
display_options[:class] =
|
|
71
|
-
|
|
72
|
+
display_options[:class] =
|
|
73
|
+
['text-field__control', 'date-field__display', input_class, display_options[:class]].compact.join(' ')
|
|
74
|
+
display_options[:type] ||= 'text'
|
|
72
75
|
display_options[:name] ||= name
|
|
73
76
|
display_options[:placeholder] ||= placeholder if placeholder.present?
|
|
74
77
|
display_options[:required] = true if required
|
|
75
78
|
display_options[:disabled] = true if disabled
|
|
76
|
-
display_options[:autocomplete] ||=
|
|
79
|
+
display_options[:autocomplete] ||= 'off'
|
|
77
80
|
display_options[:value] = display_value if display_value.present? && !display_options.key?(:value)
|
|
78
81
|
|
|
79
82
|
display_data = (display_options[:data] || {}).dup
|
|
80
83
|
display_data[:date_field_display] = true
|
|
81
|
-
display_data[:date_field_target] ||=
|
|
84
|
+
display_data[:date_field_target] ||= 'display'
|
|
82
85
|
display_data[:date_field_native_target] ||= native_id
|
|
83
86
|
display_data[:field_label] ||= label if label.present?
|
|
84
87
|
display_options[:data] = display_data
|
|
85
88
|
|
|
86
89
|
aria = display_options[:aria].presence || {}
|
|
87
|
-
describedby = [
|
|
90
|
+
describedby = [aria[:describedby], support_id].compact.join(' ').presence
|
|
88
91
|
aria[:describedby] = describedby if describedby.present?
|
|
89
92
|
display_options[:aria] = aria if aria.present?
|
|
90
93
|
|
|
91
94
|
native_options[:id] = native_id
|
|
92
|
-
native_options[:class] = [
|
|
93
|
-
native_options[:type] ||=
|
|
95
|
+
native_options[:class] = ['date-field__native', native_options[:class]].compact.join(' ')
|
|
96
|
+
native_options[:type] ||= 'date'
|
|
94
97
|
native_options.delete(:name) if native_options[:name].blank?
|
|
95
98
|
native_options[:value] = iso_value if iso_value.present? && !native_options.key?(:value)
|
|
96
99
|
native_options[:required] = true if required
|
|
97
100
|
native_options[:disabled] = true if disabled
|
|
98
|
-
native_options[:tabindex] ||=
|
|
99
|
-
native_options[:autocomplete] ||=
|
|
100
|
-
native_options[:class] = [
|
|
101
|
+
native_options[:tabindex] ||= '-1'
|
|
102
|
+
native_options[:autocomplete] ||= 'off'
|
|
103
|
+
native_options[:class] = [native_options[:class], 'date-field__native--hidden'].compact.join(' ')
|
|
101
104
|
|
|
102
105
|
if min_date.present?
|
|
103
106
|
min_date_value = case min_date
|
|
104
|
-
|
|
105
|
-
min_date.strftime(
|
|
106
|
-
|
|
107
|
+
when Date, Time, DateTime, ActiveSupport::TimeWithZone
|
|
108
|
+
min_date.strftime('%Y-%m-%d')
|
|
109
|
+
when String
|
|
107
110
|
min_date
|
|
108
|
-
|
|
111
|
+
end
|
|
109
112
|
native_options[:min] = min_date_value if min_date_value.present?
|
|
110
113
|
end
|
|
111
114
|
|
|
112
115
|
if max_date.present?
|
|
113
116
|
max_date_value = case max_date
|
|
114
|
-
|
|
115
|
-
max_date.strftime(
|
|
116
|
-
|
|
117
|
+
when Date, Time, DateTime, ActiveSupport::TimeWithZone
|
|
118
|
+
max_date.strftime('%Y-%m-%d')
|
|
119
|
+
when String
|
|
117
120
|
max_date
|
|
118
|
-
|
|
121
|
+
end
|
|
119
122
|
native_options[:max] = max_date_value if max_date_value.present?
|
|
120
123
|
end
|
|
121
124
|
|
|
122
125
|
native_data = (native_options[:data] || {}).dup
|
|
123
126
|
native_data[:date_field_native] = true
|
|
124
|
-
native_data[:date_field_target] ||=
|
|
127
|
+
native_data[:date_field_target] ||= 'native'
|
|
125
128
|
native_data[:date_field_name] ||= name
|
|
126
129
|
native_data[:date_field_display_target] ||= input_id
|
|
127
130
|
native_options[:data] = native_data
|
|
128
131
|
|
|
129
132
|
native_aria = native_options[:aria].presence || {}
|
|
130
|
-
native_aria[:hidden] =
|
|
133
|
+
native_aria[:hidden] = 'true'
|
|
131
134
|
native_aria[:label] ||= label if label.present?
|
|
132
135
|
native_options[:aria] = native_aria if native_aria.present?
|
|
133
136
|
|
|
134
|
-
baldur_render
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
137
|
+
baldur_render 'baldur/components/date_field',
|
|
138
|
+
wrapper_classes: wrapper_classes,
|
|
139
|
+
label: label,
|
|
140
|
+
supporting_text: supporting_text,
|
|
141
|
+
display_input_options: display_options,
|
|
142
|
+
native_input_options: native_options,
|
|
143
|
+
toggle_label: toggle_label,
|
|
144
|
+
icon_name: icon_name,
|
|
145
|
+
support_id: support_id
|
|
143
146
|
end
|
|
144
147
|
|
|
145
|
-
def ui_mobile_field_tag(name, value = nil, label:
|
|
146
|
-
|
|
148
|
+
def ui_mobile_field_tag(name, value = nil, label: 'Mobile', placeholder: '10-digit mobile number',
|
|
149
|
+
country_code: '+91', required: false, disabled: false, wrapper_class: nil, input_class: nil, input_options: {})
|
|
150
|
+
normalized_value = value.to_s.gsub(/\D+/, '').slice(0, 10)
|
|
147
151
|
merged_input_options = (input_options || {}).deep_dup
|
|
148
152
|
merged_input_options[:data] = (merged_input_options[:data] || {}).merge(
|
|
149
153
|
mobile_input: true,
|
|
150
154
|
mobile_country_code: country_code
|
|
151
155
|
)
|
|
152
|
-
merged_input_options[:inputmode] ||=
|
|
153
|
-
merged_input_options[:pattern] ||=
|
|
154
|
-
merged_input_options[:autocomplete] ||=
|
|
155
|
-
merged_wrapper_class = [
|
|
156
|
+
merged_input_options[:inputmode] ||= 'numeric'
|
|
157
|
+
merged_input_options[:pattern] ||= '\\d*'
|
|
158
|
+
merged_input_options[:autocomplete] ||= 'tel'
|
|
159
|
+
merged_wrapper_class = [wrapper_class, 'field--mobile'].compact.join(' ')
|
|
156
160
|
|
|
157
161
|
ui_text_field_tag(
|
|
158
162
|
name,
|
|
@@ -169,7 +173,8 @@ module Baldur
|
|
|
169
173
|
)
|
|
170
174
|
end
|
|
171
175
|
|
|
172
|
-
def ui_menu_select_tag(name, options:, selected: nil, placeholder:
|
|
176
|
+
def ui_menu_select_tag(name, options:, selected: nil, placeholder: 'Select an option', label: nil,
|
|
177
|
+
supporting_text: nil, wrapper_class: nil, data: nil, input_data: nil, disabled: false)
|
|
173
178
|
normalized = options.map do |option|
|
|
174
179
|
case option
|
|
175
180
|
when Hash
|
|
@@ -204,21 +209,21 @@ module Baldur
|
|
|
204
209
|
button_label = selected_option&.dig(:label) || placeholder
|
|
205
210
|
|
|
206
211
|
field_id = "ui-menu-select-#{SecureRandom.hex(4)}"
|
|
207
|
-
auto_width_class = menu_select_explicit_width?(wrapper_class) ? nil :
|
|
208
|
-
wrapper_classes = [
|
|
209
|
-
|
|
210
|
-
baldur_render
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
212
|
+
auto_width_class = menu_select_explicit_width?(wrapper_class) ? nil : 'field--select-auto'
|
|
213
|
+
wrapper_classes = ['field', 'field--select', auto_width_class, wrapper_class].compact.join(' ')
|
|
214
|
+
|
|
215
|
+
baldur_render 'baldur/components/menu_select',
|
|
216
|
+
name: name,
|
|
217
|
+
field_id: field_id,
|
|
218
|
+
wrapper_classes: wrapper_classes,
|
|
219
|
+
wrapper_data: data,
|
|
220
|
+
label: label,
|
|
221
|
+
supporting_text: supporting_text,
|
|
222
|
+
selected_value: selected_value,
|
|
223
|
+
button_label: button_label,
|
|
224
|
+
options: normalized,
|
|
225
|
+
input_data: input_data,
|
|
226
|
+
disabled: disabled
|
|
222
227
|
end
|
|
223
228
|
|
|
224
229
|
private
|
|
@@ -39,11 +39,12 @@ module Baldur
|
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
-
def ui_sidebar(primary_links:, secondary_links: [], secondary_label: nil, brand_path: nil, brand_name: nil,
|
|
42
|
+
def ui_sidebar(primary_links:, secondary_links: [], secondary_label: nil, brand_path: nil, brand_name: nil,
|
|
43
|
+
brand_wordmark: nil, brand_logo: nil, header_content: nil, footer_content: nil, mobile_header_content: nil, mobile_footer_content: nil, shell_class: nil, &block)
|
|
43
44
|
builder = SidebarBuilder.new(self)
|
|
44
45
|
body_content = capture(builder, &block) if block_given?
|
|
45
46
|
|
|
46
|
-
baldur_render
|
|
47
|
+
baldur_render 'baldur/components/sidebar',
|
|
47
48
|
brand: ui_sidebar_resolve_brand(
|
|
48
49
|
brand_path: brand_path,
|
|
49
50
|
brand_name: brand_name,
|
|
@@ -69,7 +70,7 @@ module Baldur
|
|
|
69
70
|
name: brand_name,
|
|
70
71
|
wordmark: brand_wordmark,
|
|
71
72
|
logo_src: brand_logo,
|
|
72
|
-
href: brand_path.presence ||
|
|
73
|
+
href: brand_path.presence || '#'
|
|
73
74
|
}.compact
|
|
74
75
|
|
|
75
76
|
ui_marketing_resolve_brand(overrides)
|
|
@@ -85,7 +86,7 @@ module Baldur
|
|
|
85
86
|
{
|
|
86
87
|
name: normalized[:name].to_s,
|
|
87
88
|
path: normalized[:path],
|
|
88
|
-
icon: normalized[:icon].presence ||
|
|
89
|
+
icon: normalized[:icon].presence || 'circle',
|
|
89
90
|
active: !!normalized[:active],
|
|
90
91
|
title: normalized[:title].presence || normalized[:name].to_s,
|
|
91
92
|
method: normalized[:method],
|
|
@@ -98,7 +99,7 @@ module Baldur
|
|
|
98
99
|
def ui_sidebar_collapsed?
|
|
99
100
|
return false unless respond_to?(:cookies)
|
|
100
101
|
|
|
101
|
-
cookies[
|
|
102
|
+
cookies['baldur-sidebar-collapsed'] == 'true'
|
|
102
103
|
end
|
|
103
104
|
end
|
|
104
105
|
end
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
module Baldur
|
|
2
2
|
module UiHelperUnavailable
|
|
3
|
-
def ui_unavailable_metric(reason: nil, dependencies: nil, warning_keys: nil, text:
|
|
4
|
-
|
|
3
|
+
def ui_unavailable_metric(reason: nil, dependencies: nil, warning_keys: nil, text: 'Not available',
|
|
4
|
+
text_class: 'text-xs text-muted')
|
|
5
|
+
content_tag(:span, class: 'inline-flex items-center gap-1 whitespace-nowrap align-middle') do
|
|
5
6
|
safe_join(
|
|
6
7
|
[
|
|
7
8
|
content_tag(:span, text, class: text_class),
|
|
8
9
|
ui_tooltip(
|
|
9
|
-
text:
|
|
10
|
-
content: ui_unavailable_explanation_content(reason: reason, dependencies: dependencies,
|
|
11
|
-
|
|
10
|
+
text: 'Why unavailable',
|
|
11
|
+
content: ui_unavailable_explanation_content(reason: reason, dependencies: dependencies,
|
|
12
|
+
warning_keys: warning_keys),
|
|
13
|
+
icon: 'info',
|
|
12
14
|
variant: :icon,
|
|
13
15
|
inline: true
|
|
14
16
|
)
|
|
@@ -43,7 +45,7 @@ module Baldur
|
|
|
43
45
|
snapshot_metric = dep[:snapshot_metric]
|
|
44
46
|
next if dataset_key.blank? && field_key.blank? && snapshot_metric.blank?
|
|
45
47
|
|
|
46
|
-
group_key = dataset_key.presence ||
|
|
48
|
+
group_key = dataset_key.presence || '__no_dataset__'
|
|
47
49
|
unless grouped.key?(group_key)
|
|
48
50
|
grouped[group_key] = {
|
|
49
51
|
dataset_key: dataset_key.presence,
|
|
@@ -61,13 +63,13 @@ module Baldur
|
|
|
61
63
|
order.filter_map do |group_key|
|
|
62
64
|
group = grouped[group_key]
|
|
63
65
|
details = []
|
|
64
|
-
details << group[:fields].join(
|
|
66
|
+
details << group[:fields].join(', ') if group[:fields].present?
|
|
65
67
|
details << "snapshot metric: #{group[:metrics].join(', ')}" if group[:metrics].present?
|
|
66
68
|
next if group[:dataset_key].blank? && details.blank?
|
|
67
69
|
|
|
68
70
|
{
|
|
69
71
|
dataset_label: (ui_dependency_dataset_name(group[:dataset_key]) if group[:dataset_key].present?),
|
|
70
|
-
details: details.join(
|
|
72
|
+
details: details.join(' | ')
|
|
71
73
|
}
|
|
72
74
|
end
|
|
73
75
|
end
|
|
@@ -75,18 +77,18 @@ module Baldur
|
|
|
75
77
|
def ui_unavailable_dependency_group_content(groups)
|
|
76
78
|
lines = groups.map do |group|
|
|
77
79
|
line = if group[:dataset_label].present? && group[:details].present?
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
content_tag(:span, line, class:
|
|
80
|
+
"• #{group[:dataset_label]} › #{group[:details]}"
|
|
81
|
+
else
|
|
82
|
+
"• #{group[:dataset_label].presence || group[:details]}"
|
|
83
|
+
end
|
|
84
|
+
content_tag(:span, line, class: 'block text-left')
|
|
83
85
|
end
|
|
84
|
-
safe_join([
|
|
86
|
+
safe_join([content_tag(:span, 'Upload/refresh:', class: 'block text-left'), *lines])
|
|
85
87
|
end
|
|
86
88
|
|
|
87
89
|
def ui_unavailable_explanation_sections(reason:, groups:)
|
|
88
90
|
parts = []
|
|
89
|
-
parts << content_tag(:span, reason, class:
|
|
91
|
+
parts << content_tag(:span, reason, class: 'block text-left') if reason.present?
|
|
90
92
|
parts << ui_unavailable_dependency_group_content(groups) if groups.present?
|
|
91
93
|
safe_join(parts)
|
|
92
94
|
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<%
|
|
2
|
+
aria_label = local_assigns[:aria_label] || "Toggle theme"
|
|
3
|
+
extra_classes = local_assigns[:classes]
|
|
4
|
+
toggle_classes = ["switch", "theme-toggle"].tap do |classes|
|
|
5
|
+
classes << extra_classes if extra_classes.present?
|
|
6
|
+
end.join(" ")
|
|
7
|
+
%>
|
|
8
|
+
<label class="<%= toggle_classes %>">
|
|
9
|
+
<input type="checkbox"
|
|
10
|
+
data-theme-target="toggle"
|
|
11
|
+
data-theme-toggle
|
|
12
|
+
aria-label="<%= aria_label %>" />
|
|
13
|
+
<span class="switch__track">
|
|
14
|
+
<span class="switch__icon switch__icon--sun" aria-hidden="true"><%= ui_icon("sun", class_name: "h-4 w-4") %></span>
|
|
15
|
+
<span class="switch__icon switch__icon--moon" aria-hidden="true"><%= ui_icon("moon", class_name: "h-4 w-4") %></span>
|
|
16
|
+
<span class="switch__thumb"></span>
|
|
17
|
+
</span>
|
|
18
|
+
<span class="icon-button theme-toggle__compact" aria-hidden="true" data-action="click->theme#toggle">
|
|
19
|
+
<span class="theme-toggle__compact-icon theme-toggle__compact-icon--sun"><%= ui_icon("sun", class_name: "h-5 w-5") %></span>
|
|
20
|
+
<span class="theme-toggle__compact-icon theme-toggle__compact-icon--moon"><%= ui_icon("moon", class_name: "h-5 w-5") %></span>
|
|
21
|
+
</span>
|
|
22
|
+
<span class="sr-only"><%= aria_label %></span>
|
|
23
|
+
</label>
|
|
@@ -6,6 +6,12 @@
|
|
|
6
6
|
|
|
7
7
|
<div class="<%= auth_shell_classes %>">
|
|
8
8
|
<div class="auth-page__container">
|
|
9
|
+
<% if local_assigns[:top_rail].present? %>
|
|
10
|
+
<div class="auth-page__top-rail">
|
|
11
|
+
<%= local_assigns[:top_rail] %>
|
|
12
|
+
</div>
|
|
13
|
+
<% end %>
|
|
14
|
+
|
|
9
15
|
<div class="auth-page__brand">
|
|
10
16
|
<%= link_to resolved_brand_path, class: "inline-flex items-center justify-center no-underline" do %>
|
|
11
17
|
<%= render "shared/brand_lockup",
|
data/baldur.gemspec
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
require_relative
|
|
1
|
+
require_relative 'lib/baldur/version'
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |spec|
|
|
4
|
-
spec.name =
|
|
4
|
+
spec.name = 'baldur'
|
|
5
5
|
spec.version = Baldur::VERSION
|
|
6
|
-
spec.authors = [
|
|
7
|
-
spec.summary =
|
|
8
|
-
spec.description =
|
|
9
|
-
spec.homepage =
|
|
10
|
-
spec.license =
|
|
6
|
+
spec.authors = ['Varun Murkar']
|
|
7
|
+
spec.summary = 'Batteries-included Rails UI engine for the importmap, Stimulus, Tailwind stack'
|
|
8
|
+
spec.description = 'Baldur helps Rails teams ship polished UI faster with install generators, reusable ui_* helpers, Tailwind components, and Stimulus wiring for apps using Propshaft, importmap-rails, stimulus-rails, and tailwindcss-rails.'
|
|
9
|
+
spec.homepage = 'https://github.com/varunmurkar/baldur'
|
|
10
|
+
spec.license = 'MIT'
|
|
11
11
|
spec.metadata = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
'source_code_uri' => 'https://github.com/varunmurkar/baldur',
|
|
13
|
+
'bug_tracker_uri' => 'https://github.com/varunmurkar/baldur/issues',
|
|
14
|
+
'changelog_uri' => 'https://github.com/varunmurkar/baldur/releases',
|
|
15
|
+
'rubygems_mfa_required' => 'true'
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
spec.files = Dir.chdir(__dir__) do
|
|
19
19
|
Dir[
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
'{app,config,lib,script,test}/**/*',
|
|
21
|
+
'README.md',
|
|
22
|
+
'TODO.md',
|
|
23
|
+
'LICENSE',
|
|
24
|
+
'SECURITY.md',
|
|
25
|
+
'baldur.gemspec',
|
|
26
|
+
'Gemfile'
|
|
27
27
|
].select { |path| File.file?(path) }
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
spec.required_ruby_version =
|
|
30
|
+
spec.required_ruby_version = '>= 3.3.0'
|
|
31
31
|
|
|
32
|
-
spec.add_dependency
|
|
33
|
-
spec.add_dependency
|
|
34
|
-
spec.add_dependency
|
|
35
|
-
spec.add_dependency
|
|
32
|
+
spec.add_dependency 'importmap-rails'
|
|
33
|
+
spec.add_dependency 'lucide-rails'
|
|
34
|
+
spec.add_dependency 'rails', '>= 7.0.0'
|
|
35
|
+
spec.add_dependency 'tailwindcss-rails', '>= 4.3.0'
|
|
36
36
|
end
|
data/config/importmap.rb
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
pin_all_from File.expand_path(
|
|
2
|
-
pin_all_from File.expand_path(
|
|
1
|
+
pin_all_from File.expand_path('../app/assets/javascripts/baldur/controllers', __dir__), under: 'baldur/controllers'
|
|
2
|
+
pin_all_from File.expand_path('../app/assets/javascripts/baldur/lib', __dir__), under: 'baldur/lib'
|
data/lib/baldur/configuration.rb
CHANGED
|
@@ -10,15 +10,15 @@ module Baldur
|
|
|
10
10
|
def initialize
|
|
11
11
|
@warning_dependency_resolver = ->(_warning_keys) { [] }
|
|
12
12
|
@dependency_dataset_name_resolver = ->(dataset_key) { dataset_key.to_s.humanize }
|
|
13
|
-
@unavailable_fallback_message =
|
|
13
|
+
@unavailable_fallback_message = 'Missing metric or raw data required to compute this value.'
|
|
14
14
|
@marketing_brand = {
|
|
15
|
-
name:
|
|
16
|
-
wordmark:
|
|
17
|
-
logo_src:
|
|
18
|
-
logo_alt:
|
|
15
|
+
name: 'Brand',
|
|
16
|
+
wordmark: 'Brand',
|
|
17
|
+
logo_src: '/icon.png',
|
|
18
|
+
logo_alt: 'Brand logo'
|
|
19
19
|
}
|
|
20
20
|
@default_google_sign_in_path = nil
|
|
21
|
-
@theme_storage_key =
|
|
21
|
+
@theme_storage_key = 'baldur.theme'
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
end
|
data/lib/baldur/engine.rb
CHANGED
|
@@ -2,9 +2,9 @@ module Baldur
|
|
|
2
2
|
class Engine < ::Rails::Engine
|
|
3
3
|
isolate_namespace Baldur
|
|
4
4
|
|
|
5
|
-
initializer
|
|
6
|
-
app.config.importmap.paths << Engine.root.join(
|
|
7
|
-
app.config.importmap.cache_sweepers << Engine.root.join(
|
|
5
|
+
initializer 'baldur.importmap', before: 'importmap' do |app|
|
|
6
|
+
app.config.importmap.paths << Engine.root.join('config/importmap.rb')
|
|
7
|
+
app.config.importmap.cache_sweepers << Engine.root.join('app/assets/javascripts')
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
10
|
end
|
data/lib/baldur/version.rb
CHANGED
data/lib/baldur.rb
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
1
|
+
require 'rails'
|
|
2
|
+
require 'lucide-rails'
|
|
3
3
|
|
|
4
|
-
require_relative
|
|
5
|
-
require_relative
|
|
6
|
-
require_relative
|
|
4
|
+
require_relative 'baldur/version'
|
|
5
|
+
require_relative 'baldur/configuration'
|
|
6
|
+
require_relative 'baldur/engine'
|
|
7
7
|
|
|
8
8
|
module Baldur
|
|
9
9
|
class << self
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'rails/generators'
|
|
2
2
|
|
|
3
3
|
module Baldur
|
|
4
4
|
module Generators
|
|
5
5
|
class InstallGenerator < Rails::Generators::Base
|
|
6
|
-
source_root File.expand_path(
|
|
6
|
+
source_root File.expand_path('templates', __dir__)
|
|
7
7
|
|
|
8
8
|
CORE_CONTROLLERS = %w[
|
|
9
9
|
accordion
|
|
@@ -35,19 +35,19 @@ module Baldur
|
|
|
35
35
|
].freeze
|
|
36
36
|
|
|
37
37
|
def create_ui_helper
|
|
38
|
-
template
|
|
38
|
+
template 'ui_helper.rb', 'app/helpers/ui_helper.rb'
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def create_initializer
|
|
42
|
-
template
|
|
42
|
+
template 'baldur_initializer.rb', 'config/initializers/baldur.rb'
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
def create_theme_override
|
|
46
|
-
template
|
|
46
|
+
template 'theme.css', 'app/assets/stylesheets/theme.css'
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
def create_fonts_override
|
|
50
|
-
template
|
|
50
|
+
template 'fonts.css', 'app/assets/stylesheets/fonts.css'
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
def create_controller_shims
|
|
@@ -69,9 +69,9 @@ module Baldur
|
|
|
69
69
|
def add_stylesheet_import
|
|
70
70
|
return unless File.exist?(tailwind_entrypoint_path)
|
|
71
71
|
|
|
72
|
-
append_unique_line tailwind_entrypoint_path,
|
|
73
|
-
append_unique_line tailwind_entrypoint_path,
|
|
74
|
-
append_unique_line tailwind_entrypoint_path,
|
|
72
|
+
append_unique_line tailwind_entrypoint_path, '@import "../stylesheets/fonts.css";'
|
|
73
|
+
append_unique_line tailwind_entrypoint_path, '@import "../builds/tailwind/baldur.css";'
|
|
74
|
+
append_unique_line tailwind_entrypoint_path, '@import "../stylesheets/theme.css";'
|
|
75
75
|
ensure_stylesheet_import_order
|
|
76
76
|
end
|
|
77
77
|
|
|
@@ -83,19 +83,19 @@ module Baldur
|
|
|
83
83
|
|
|
84
84
|
def ensure_stylesheet_import_order
|
|
85
85
|
source = File.read(tailwind_entrypoint_path)
|
|
86
|
-
fonts_import =
|
|
87
|
-
tailwind_import =
|
|
88
|
-
baldur_import =
|
|
89
|
-
theme_import =
|
|
86
|
+
fonts_import = '@import "../stylesheets/fonts.css";'
|
|
87
|
+
tailwind_import = '@import "tailwindcss";'
|
|
88
|
+
baldur_import = '@import "../builds/tailwind/baldur.css";'
|
|
89
|
+
theme_import = '@import "../stylesheets/theme.css";'
|
|
90
90
|
normalized = source.lines.reject { |line| line.strip == fonts_import }.join
|
|
91
91
|
normalized = if normalized.include?(tailwind_import)
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
normalized.sub("#{tailwind_import}\n", "#{fonts_import}\n#{tailwind_import}\n")
|
|
93
|
+
else
|
|
94
|
+
"#{fonts_import}\n#{normalized}"
|
|
95
|
+
end
|
|
96
96
|
|
|
97
97
|
if normalized.include?(baldur_import) && normalized.include?(theme_import) &&
|
|
98
|
-
|
|
98
|
+
normalized.index(baldur_import) > normalized.index(theme_import)
|
|
99
99
|
normalized = normalized.lines.reject { |line| line.strip == theme_import }.join
|
|
100
100
|
normalized = normalized.sub("#{baldur_import}\n", "#{baldur_import}\n#{theme_import}\n")
|
|
101
101
|
end
|
|
@@ -108,7 +108,7 @@ module Baldur
|
|
|
108
108
|
end
|
|
109
109
|
|
|
110
110
|
def tailwind_entrypoint
|
|
111
|
-
|
|
111
|
+
'app/assets/tailwind/application.css'
|
|
112
112
|
end
|
|
113
113
|
end
|
|
114
114
|
end
|