baldur 0.1.7 → 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/README.md +78 -376
- data/TODO.md +53 -5
- data/app/assets/javascripts/baldur/controllers/confirmation_controller.js +23 -0
- data/app/assets/stylesheets/baldur/application/components/auth-page.css +7 -0
- data/app/assets/stylesheets/baldur/application/components/confirmation.css +11 -0
- data/app/assets/stylesheets/baldur/application/components/sidebar.css +234 -0
- data/app/assets/stylesheets/baldur.css +1 -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 +159 -121
- 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/_confirmation_modal.html.erb +99 -0
- data/app/views/baldur/components/_modal_host.html.erb +10 -0
- data/app/views/baldur/components/_sidebar.html.erb +30 -30
- 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 +20 -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 +241 -0
- 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/app/javascript/controllers/confirmation_controller.js +1 -0
- data/test/tmp/install_generator/config/initializers/baldur.rb +7 -7
- metadata +20 -8
|
@@ -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,99 @@
|
|
|
1
|
+
<%
|
|
2
|
+
host_id = local_assigns.fetch(:host_id)
|
|
3
|
+
dialog_id = local_assigns.fetch(:dialog_id)
|
|
4
|
+
title = local_assigns.fetch(:title)
|
|
5
|
+
description = local_assigns[:description]
|
|
6
|
+
tone = (local_assigns[:tone] || :default).to_sym
|
|
7
|
+
confirm_label = local_assigns.fetch(:confirm_label, "Confirm")
|
|
8
|
+
cancel_label = local_assigns.fetch(:cancel_label, "Cancel")
|
|
9
|
+
confirm_button_options = local_assigns.fetch(:confirm_button_options, {})
|
|
10
|
+
cancel_button_options = local_assigns.fetch(:cancel_button_options, {})
|
|
11
|
+
type_to_confirm = local_assigns[:type_to_confirm]
|
|
12
|
+
body = local_assigns.fetch(:body, nil) unless defined?(body)
|
|
13
|
+
|
|
14
|
+
confirm_variant = tone == :danger ? :danger : :primary
|
|
15
|
+
confirm_btn_opts = { label: confirm_label, variant: confirm_variant, type: :submit }.merge(confirm_button_options.except(:data))
|
|
16
|
+
if confirm_button_options[:data].present?
|
|
17
|
+
confirm_btn_opts[:data] = confirm_button_options[:data]
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
cancel_btn_opts = { label: cancel_label, variant: :ghost }.merge(cancel_button_options.except(:data))
|
|
21
|
+
cancel_btn_opts[:data] = { modal_close: true }.merge(cancel_button_options[:data] || {})
|
|
22
|
+
|
|
23
|
+
has_type_to_confirm = type_to_confirm.is_a?(Hash)
|
|
24
|
+
expected_text = has_type_to_confirm ? type_to_confirm[:expected_text].to_s : nil
|
|
25
|
+
confirm_input_id = has_type_to_confirm ? "#{dialog_id}-confirm-input" : nil
|
|
26
|
+
confirm_input_label = has_type_to_confirm ? type_to_confirm[:label].to_s : nil
|
|
27
|
+
confirm_input_placeholder = has_type_to_confirm ? (type_to_confirm[:placeholder].to_s.presence || expected_text) : nil
|
|
28
|
+
confirm_input_hint = has_type_to_confirm ? type_to_confirm[:hint] : nil
|
|
29
|
+
case_sensitive = has_type_to_confirm ? (type_to_confirm[:case_sensitive] != false) : true
|
|
30
|
+
|
|
31
|
+
if has_type_to_confirm
|
|
32
|
+
confirm_btn_opts[:disabled] = true
|
|
33
|
+
confirm_btn_opts[:data] = (confirm_btn_opts[:data] || {}).merge(confirmation_target: "submit")
|
|
34
|
+
end
|
|
35
|
+
%>
|
|
36
|
+
<div id="<%= host_id %>"
|
|
37
|
+
class="fixed inset-0 z-50 hidden flex items-center justify-center bg-black/40 p-4"
|
|
38
|
+
data-controller="modal<%= has_type_to_confirm ? " confirmation" : "" %>"
|
|
39
|
+
<%= has_type_to_confirm ? 'data-confirmation-case-sensitive-value="' + case_sensitive.to_s + '"' : '' %>
|
|
40
|
+
data-modal-selector-value="#<%= host_id %>"
|
|
41
|
+
data-modal="true"
|
|
42
|
+
aria-hidden="true">
|
|
43
|
+
<div id="<%= dialog_id %>" class="dialog motion-fade-scale">
|
|
44
|
+
<div class="flex items-start justify-between gap-4">
|
|
45
|
+
<div>
|
|
46
|
+
<h3 class="text-xl font-semibold text-[color:var(--color-on-surface)]">
|
|
47
|
+
<% if tone == :danger %>
|
|
48
|
+
<span class="inline-flex items-center gap-2">
|
|
49
|
+
<%= ui_icon("triangle-alert", class_name: "h-5 w-5 text-[color:var(--color-error)]") %>
|
|
50
|
+
<%= title %>
|
|
51
|
+
</span>
|
|
52
|
+
<% else %>
|
|
53
|
+
<%= title %>
|
|
54
|
+
<% end %>
|
|
55
|
+
</h3>
|
|
56
|
+
<% if description.present? %>
|
|
57
|
+
<p class="text-sm text-[color:color-mix(in srgb,var(--color-on-surface) 75%,transparent)]"><%= description %></p>
|
|
58
|
+
<% end %>
|
|
59
|
+
</div>
|
|
60
|
+
<button type="button" class="icon-button" aria-label="Close modal" data-modal-close="true">
|
|
61
|
+
<%= ui_icon("x", class_name: "h-5 w-5") %>
|
|
62
|
+
</button>
|
|
63
|
+
</div>
|
|
64
|
+
<% if body.present? %>
|
|
65
|
+
<div class="mt-4 space-y-3 text-sm text-[color:var(--color-on-surface)]">
|
|
66
|
+
<%= body %>
|
|
67
|
+
</div>
|
|
68
|
+
<% end %>
|
|
69
|
+
<% if has_type_to_confirm %>
|
|
70
|
+
<div class="mt-4 space-y-2">
|
|
71
|
+
<% if confirm_input_label.present? %>
|
|
72
|
+
<label for="<%= confirm_input_id %>" class="field__label text-sm font-medium text-[color:var(--color-on-surface)]"><%= confirm_input_label %></label>
|
|
73
|
+
<% end %>
|
|
74
|
+
<div class="text-field__input">
|
|
75
|
+
<input id="<%= confirm_input_id %>"
|
|
76
|
+
type="text"
|
|
77
|
+
autocomplete="off"
|
|
78
|
+
class="text-field__control"
|
|
79
|
+
data-confirmation-target="input"
|
|
80
|
+
data-action="input->confirmation#validate"
|
|
81
|
+
<%= confirm_input_placeholder.present? ? "placeholder=\"#{confirm_input_placeholder}\"".html_safe : "" %>
|
|
82
|
+
data-modal-autofocus="true" />
|
|
83
|
+
</div>
|
|
84
|
+
<% if confirm_input_hint.present? %>
|
|
85
|
+
<p class="text-sm text-muted"><%= confirm_input_hint %></p>
|
|
86
|
+
<% end %>
|
|
87
|
+
<% if expected_text.present? %>
|
|
88
|
+
<span hidden data-confirmation-target="expectedText"><%= expected_text %></span>
|
|
89
|
+
<% end %>
|
|
90
|
+
</div>
|
|
91
|
+
<% end %>
|
|
92
|
+
<div class="mt-6 flex flex-wrap items-center gap-3">
|
|
93
|
+
<div class="ml-auto flex flex-wrap gap-3 justify-end">
|
|
94
|
+
<%= render "baldur/components/button", **cancel_btn_opts %>
|
|
95
|
+
<%= render "baldur/components/button", **confirm_btn_opts %>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<% classes = local_assigns[:classes] %>
|
|
2
|
+
<% body = local_assigns.fetch(:body, nil) unless defined?(body) %>
|
|
3
|
+
<div id="<%= id %>"
|
|
4
|
+
class="fixed inset-0 z-50 hidden flex items-center justify-center bg-black/40 p-4 <%= classes %>"
|
|
5
|
+
data-controller="modal"
|
|
6
|
+
data-modal-selector-value="#<%= id %>"
|
|
7
|
+
data-modal="true"
|
|
8
|
+
aria-hidden="true">
|
|
9
|
+
<%= body %>
|
|
10
|
+
</div>
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
]
|
|
20
20
|
)
|
|
21
21
|
end
|
|
22
|
-
brand_markup = link_to(brand_markup, resolved_brand[:href], class: "
|
|
22
|
+
brand_markup = link_to(brand_markup, resolved_brand[:href], class: "sidebar__brand-link") if resolved_brand[:href].present?
|
|
23
23
|
|
|
24
24
|
render_nav_link = lambda do |link, mobile: false|
|
|
25
25
|
options = link[:html_options].deep_dup
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
options[:aria] = (options[:aria] || {}).merge(current: (link[:active] ? "page" : nil))
|
|
30
30
|
|
|
31
31
|
if mobile
|
|
32
|
-
mobile_class = link[:active] ? "
|
|
33
|
-
options[:class] = [
|
|
32
|
+
mobile_class = link[:active] ? "sidebar-mobile__link sidebar-mobile__link--active" : "sidebar-mobile__link"
|
|
33
|
+
options[:class] = [mobile_class, options[:class]].compact.join(" ")
|
|
34
34
|
link_to(link[:path], **options) do
|
|
35
35
|
safe_join(
|
|
36
36
|
[
|
|
37
|
-
ui_icon(link[:icon], class_name: "
|
|
37
|
+
ui_icon(link[:icon], class_name: "sidebar-mobile__icon"),
|
|
38
38
|
content_tag(:span, link[:name])
|
|
39
39
|
]
|
|
40
40
|
)
|
|
@@ -53,13 +53,13 @@
|
|
|
53
53
|
end
|
|
54
54
|
%>
|
|
55
55
|
|
|
56
|
-
<div class="<%= ["sidebar-shell
|
|
56
|
+
<div class="<%= ["sidebar-shell", shell_class].compact.join(" ") %>"
|
|
57
57
|
data-controller="sidebar"
|
|
58
58
|
data-sidebar-storage-key-value="baldur-sidebar-collapsed"
|
|
59
59
|
data-sidebar-collapsed-value="<%= collapsed %>">
|
|
60
|
-
<aside class="sidebar
|
|
60
|
+
<aside class="sidebar sidebar-shell__desktop"
|
|
61
61
|
aria-label="Primary navigation">
|
|
62
|
-
<div class="sidebar__header
|
|
62
|
+
<div class="sidebar__header">
|
|
63
63
|
<%= brand_markup %>
|
|
64
64
|
<button type="button"
|
|
65
65
|
class="icon-button sidebar__toggle"
|
|
@@ -72,20 +72,20 @@
|
|
|
72
72
|
</div>
|
|
73
73
|
|
|
74
74
|
<% if header_content.present? %>
|
|
75
|
-
<div class="sidebar__menu
|
|
75
|
+
<div class="sidebar__menu sidebar__slot sidebar__slot--header">
|
|
76
76
|
<%= header_content %>
|
|
77
77
|
</div>
|
|
78
78
|
<% end %>
|
|
79
79
|
|
|
80
|
-
<nav class="
|
|
80
|
+
<nav class="sidebar__nav" aria-label="Primary navigation links">
|
|
81
81
|
<% primary_links.each do |link| %>
|
|
82
82
|
<%= render_nav_link.call(link) %>
|
|
83
83
|
<% end %>
|
|
84
84
|
|
|
85
85
|
<% if secondary_links.any? %>
|
|
86
|
-
<div class="
|
|
86
|
+
<div class="sidebar__section-divider"></div>
|
|
87
87
|
<% if secondary_label.present? %>
|
|
88
|
-
<p class="sidebar__section-label
|
|
88
|
+
<p class="sidebar__section-label"><%= secondary_label %></p>
|
|
89
89
|
<% end %>
|
|
90
90
|
<% secondary_links.each do |link| %>
|
|
91
91
|
<%= render_nav_link.call(link) %>
|
|
@@ -93,9 +93,9 @@
|
|
|
93
93
|
<% end %>
|
|
94
94
|
</nav>
|
|
95
95
|
|
|
96
|
-
|
|
97
|
-
<div class="sidebar__footer
|
|
98
|
-
<div class="sidebar__footer-inner
|
|
96
|
+
<% if footer_content.present? %>
|
|
97
|
+
<div class="sidebar__footer">
|
|
98
|
+
<div class="sidebar__footer-inner">
|
|
99
99
|
<%= footer_content %>
|
|
100
100
|
</div>
|
|
101
101
|
</div>
|
|
@@ -104,37 +104,37 @@
|
|
|
104
104
|
<button type="button" class="sidebar__toggle-hit-area" aria-label="Toggle navigation" data-action="click->sidebar#toggle"></button>
|
|
105
105
|
</aside>
|
|
106
106
|
|
|
107
|
-
<div class="
|
|
108
|
-
<div class="
|
|
109
|
-
<div><%= brand_markup %></div>
|
|
107
|
+
<div class="sidebar-mobile" data-controller="mobile-sidebar">
|
|
108
|
+
<div class="sidebar-mobile__topbar">
|
|
109
|
+
<div class="sidebar-mobile__brand"><%= brand_markup %></div>
|
|
110
110
|
<button type="button" class="icon-button" aria-label="Toggle navigation" data-action="mobile-sidebar#toggle">
|
|
111
111
|
<%= ui_icon("menu", class_name: "h-6 w-6") %>
|
|
112
112
|
</button>
|
|
113
113
|
</div>
|
|
114
114
|
|
|
115
|
-
<div id="mobile-sidebar" class="
|
|
116
|
-
<div class="
|
|
117
|
-
<div class="
|
|
118
|
-
<div class="
|
|
119
|
-
<button type="button" class="icon-button
|
|
120
|
-
<%= ui_icon("x", class_name: "
|
|
115
|
+
<div id="mobile-sidebar" class="sidebar-mobile__panel hidden" data-mobile-sidebar-target="panel">
|
|
116
|
+
<div class="bg-scrim sidebar-mobile__scrim" data-action="click->mobile-sidebar#close"></div>
|
|
117
|
+
<div class="sidebar-mobile__surface">
|
|
118
|
+
<div class="sidebar-mobile__close-shell">
|
|
119
|
+
<button type="button" class="icon-button sidebar-mobile__close" aria-label="Close navigation" data-action="mobile-sidebar#close">
|
|
120
|
+
<%= ui_icon("x", class_name: "sidebar-mobile__close-icon") %>
|
|
121
121
|
</button>
|
|
122
122
|
</div>
|
|
123
123
|
|
|
124
|
-
<div class="
|
|
124
|
+
<div class="sidebar-mobile__content">
|
|
125
125
|
<% if mobile_header_content.present? %>
|
|
126
|
-
<div class="
|
|
126
|
+
<div class="sidebar-mobile__slot sidebar-mobile__slot--header"><%= mobile_header_content %></div>
|
|
127
127
|
<% end %>
|
|
128
128
|
|
|
129
|
-
<nav class="
|
|
129
|
+
<nav class="sidebar-mobile__nav" aria-label="Mobile primary navigation links">
|
|
130
130
|
<% primary_links.each do |link| %>
|
|
131
131
|
<%= render_nav_link.call(link, mobile: true) %>
|
|
132
132
|
<% end %>
|
|
133
133
|
|
|
134
134
|
<% if secondary_links.any? %>
|
|
135
|
-
<div class="
|
|
135
|
+
<div class="sidebar-mobile__section-divider"></div>
|
|
136
136
|
<% if secondary_label.present? %>
|
|
137
|
-
<p class="
|
|
137
|
+
<p class="sidebar-mobile__section-label"><%= secondary_label %></p>
|
|
138
138
|
<% end %>
|
|
139
139
|
<% secondary_links.each do |link| %>
|
|
140
140
|
<%= render_nav_link.call(link, mobile: true) %>
|
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
</div>
|
|
145
145
|
|
|
146
146
|
<% if mobile_footer_content.present? %>
|
|
147
|
-
<div class="
|
|
147
|
+
<div class="sidebar-mobile__slot sidebar-mobile__slot--footer">
|
|
148
148
|
<%= mobile_footer_content %>
|
|
149
149
|
</div>
|
|
150
150
|
<% end %>
|
|
@@ -152,7 +152,7 @@
|
|
|
152
152
|
</div>
|
|
153
153
|
</div>
|
|
154
154
|
|
|
155
|
-
<div class="
|
|
155
|
+
<div class="sidebar-shell__main">
|
|
156
156
|
<%= body_content %>
|
|
157
157
|
</div>
|
|
158
158
|
</div>
|