baldur 0.1.7 → 0.2.0
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/README.md +78 -376
- data/TODO.md +47 -5
- data/app/assets/javascripts/baldur/controllers/confirmation_controller.js +23 -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/helpers/baldur/ui_helper.rb +25 -0
- 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/baldur.gemspec +4 -4
- data/lib/baldur/version.rb +1 -1
- data/lib/generators/baldur/install/install_generator.rb +1 -0
- data/test/confirmation_modal_helper_test.rb +241 -0
- data/test/test_helper.rb +1 -1
- data/test/tmp/install_generator/app/javascript/controllers/confirmation_controller.js +1 -0
- metadata +16 -8
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
require_relative "test_helper"
|
|
2
|
+
require "action_controller"
|
|
3
|
+
require_relative "../lib/generators/baldur/install/install_generator"
|
|
4
|
+
|
|
5
|
+
class BaldurConfirmationModalHelperTest < Minitest::Test
|
|
6
|
+
class TestController < ActionController::Base
|
|
7
|
+
append_view_path File.expand_path("../app/views", __dir__)
|
|
8
|
+
helper Baldur::UiHelper
|
|
9
|
+
helper Baldur::RenderHelper
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_ui_modal_host_renders_host_wrapper
|
|
13
|
+
html = TestController.render(
|
|
14
|
+
inline: <<~ERB,
|
|
15
|
+
<%= ui_modal_host(id: "test-modal") do %>
|
|
16
|
+
<p>Modal content</p>
|
|
17
|
+
<% end %>
|
|
18
|
+
ERB
|
|
19
|
+
formats: [:html]
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
assert_includes html, 'id="test-modal"'
|
|
23
|
+
assert_includes html, 'data-controller="modal"'
|
|
24
|
+
assert_includes html, 'data-modal-selector-value="#test-modal"'
|
|
25
|
+
assert_includes html, 'data-modal="true"'
|
|
26
|
+
assert_includes html, 'aria-hidden="true"'
|
|
27
|
+
assert_includes html, "Modal content"
|
|
28
|
+
assert_includes html, 'class="fixed inset-0 z-50'
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_ui_modal_host_with_custom_classes
|
|
32
|
+
html = TestController.render(
|
|
33
|
+
inline: <<~ERB,
|
|
34
|
+
<%= ui_modal_host(id: "custom-modal", classes: "my-extra-class") do %>
|
|
35
|
+
<p>Custom</p>
|
|
36
|
+
<% end %>
|
|
37
|
+
ERB
|
|
38
|
+
formats: [:html]
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
assert_includes html, "my-extra-class"
|
|
42
|
+
assert_includes html, "Custom"
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_ui_confirmation_modal_renders_basic_structure
|
|
46
|
+
html = TestController.render(
|
|
47
|
+
inline: '<%=
|
|
48
|
+
ui_confirmation_modal(
|
|
49
|
+
host_id: "delete-modal",
|
|
50
|
+
dialog_id: "delete-dialog",
|
|
51
|
+
title: "Delete item?"
|
|
52
|
+
)
|
|
53
|
+
%>',
|
|
54
|
+
formats: [:html]
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
assert_includes html, 'id="delete-modal"'
|
|
58
|
+
assert_includes html, 'id="delete-dialog"'
|
|
59
|
+
assert_includes html, 'data-controller="modal"'
|
|
60
|
+
assert_includes html, "Delete item?"
|
|
61
|
+
assert_includes html, "Confirm"
|
|
62
|
+
assert_includes html, "Cancel"
|
|
63
|
+
assert_includes html, 'data-modal-close="true"'
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def test_ui_confirmation_modal_with_danger_tone_shows_icon
|
|
67
|
+
html = TestController.render(
|
|
68
|
+
inline: '<%=
|
|
69
|
+
ui_confirmation_modal(
|
|
70
|
+
host_id: "danger-modal",
|
|
71
|
+
dialog_id: "danger-dialog",
|
|
72
|
+
title: "Discard collection?",
|
|
73
|
+
tone: :danger
|
|
74
|
+
)
|
|
75
|
+
%>',
|
|
76
|
+
formats: [:html]
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
assert_includes html, "color-error"
|
|
80
|
+
assert_includes html, "Discard collection?"
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def test_ui_confirmation_modal_default_tone_no_icon
|
|
84
|
+
html = TestController.render(
|
|
85
|
+
inline: '<%=
|
|
86
|
+
ui_confirmation_modal(
|
|
87
|
+
host_id: "default-modal",
|
|
88
|
+
dialog_id: "default-dialog",
|
|
89
|
+
title: "Proceed?"
|
|
90
|
+
)
|
|
91
|
+
%>',
|
|
92
|
+
formats: [:html]
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
refute_includes html, "color-error"
|
|
96
|
+
assert_includes html, "Proceed?"
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def test_ui_confirmation_modal_danger_tone_sets_danger_button_variant
|
|
100
|
+
html = TestController.render(
|
|
101
|
+
inline: '<%=
|
|
102
|
+
ui_confirmation_modal(
|
|
103
|
+
host_id: "danger-btn-modal",
|
|
104
|
+
dialog_id: "danger-btn-dialog",
|
|
105
|
+
title: "Discard?",
|
|
106
|
+
tone: :danger
|
|
107
|
+
)
|
|
108
|
+
%>',
|
|
109
|
+
formats: [:html]
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
assert_includes html, "button--error"
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def test_ui_confirmation_modal_default_tone_sets_primary_button_variant
|
|
116
|
+
html = TestController.render(
|
|
117
|
+
inline: '<%=
|
|
118
|
+
ui_confirmation_modal(
|
|
119
|
+
host_id: "primary-btn-modal",
|
|
120
|
+
dialog_id: "primary-btn-dialog",
|
|
121
|
+
title: "Proceed?"
|
|
122
|
+
)
|
|
123
|
+
%>',
|
|
124
|
+
formats: [:html]
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
assert_includes html, "button--filled"
|
|
128
|
+
refute_includes html, "button--error"
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def test_ui_confirmation_modal_with_type_to_confirm
|
|
132
|
+
html = TestController.render(
|
|
133
|
+
inline: '<%=
|
|
134
|
+
ui_confirmation_modal(
|
|
135
|
+
host_id: "flush-modal",
|
|
136
|
+
dialog_id: "flush-dialog",
|
|
137
|
+
title: "Flush All Data",
|
|
138
|
+
description: "This cannot be undone.",
|
|
139
|
+
tone: :danger,
|
|
140
|
+
confirm_label: "Confirm",
|
|
141
|
+
type_to_confirm: {
|
|
142
|
+
expected_text: "confirm",
|
|
143
|
+
label: "Type confirm to continue",
|
|
144
|
+
placeholder: "confirm",
|
|
145
|
+
hint: "This permanently removes all data."
|
|
146
|
+
}
|
|
147
|
+
)
|
|
148
|
+
%>',
|
|
149
|
+
formats: [:html]
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
assert_includes html, "modal confirmation"
|
|
153
|
+
assert_includes html, "confirmation-case-sensitive-value"
|
|
154
|
+
assert_includes html, 'data-confirmation-target="input"'
|
|
155
|
+
assert_includes html, 'data-confirmation-target="submit"'
|
|
156
|
+
assert_includes html, "confirmation#validate"
|
|
157
|
+
assert_includes html, "Type confirm to continue"
|
|
158
|
+
assert_includes html, "This permanently removes all data."
|
|
159
|
+
assert_includes html, "Flush All Data"
|
|
160
|
+
assert_includes html, "Confirm"
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def test_ui_confirmation_modal_type_to_confirm_disables_submit
|
|
164
|
+
html = TestController.render(
|
|
165
|
+
inline: '<%=
|
|
166
|
+
ui_confirmation_modal(
|
|
167
|
+
host_id: "disabled-modal",
|
|
168
|
+
dialog_id: "disabled-dialog",
|
|
169
|
+
title: "Delete?",
|
|
170
|
+
type_to_confirm: {
|
|
171
|
+
expected_text: "DELETE",
|
|
172
|
+
label: "Type DELETE"
|
|
173
|
+
}
|
|
174
|
+
)
|
|
175
|
+
%>',
|
|
176
|
+
formats: [:html]
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
assert_includes html, "disabled"
|
|
180
|
+
assert_includes html, "Type DELETE"
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
def test_ui_confirmation_modal_type_to_confirm_case_insensitive
|
|
184
|
+
html = TestController.render(
|
|
185
|
+
inline: '<%=
|
|
186
|
+
ui_confirmation_modal(
|
|
187
|
+
host_id: "ci-modal",
|
|
188
|
+
dialog_id: "ci-dialog",
|
|
189
|
+
title: "Delete?",
|
|
190
|
+
type_to_confirm: {
|
|
191
|
+
expected_text: "delete",
|
|
192
|
+
case_sensitive: false
|
|
193
|
+
}
|
|
194
|
+
)
|
|
195
|
+
%>',
|
|
196
|
+
formats: [:html]
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
assert_includes html, "confirmation-case-sensitive-value"
|
|
200
|
+
refute_includes html, "case-sensitive-value=\"true\""
|
|
201
|
+
assert_includes html, "case-sensitive-value="false""
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
def test_ui_confirmation_modal_without_type_to_confirm_has_no_confirmation_controller
|
|
205
|
+
html = TestController.render(
|
|
206
|
+
inline: '<%=
|
|
207
|
+
ui_confirmation_modal(
|
|
208
|
+
host_id: "simple-modal",
|
|
209
|
+
dialog_id: "simple-dialog",
|
|
210
|
+
title: "Are you sure?"
|
|
211
|
+
)
|
|
212
|
+
%>',
|
|
213
|
+
formats: [:html]
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
assert_includes html, 'data-controller="modal"'
|
|
217
|
+
refute_includes html, "confirmation"
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
def test_ui_confirmation_modal_custom_labels
|
|
221
|
+
html = TestController.render(
|
|
222
|
+
inline: '<%=
|
|
223
|
+
ui_confirmation_modal(
|
|
224
|
+
host_id: "custom-modal",
|
|
225
|
+
dialog_id: "custom-dialog",
|
|
226
|
+
title: "Discard?",
|
|
227
|
+
confirm_label: "Discard",
|
|
228
|
+
cancel_label: "Go back"
|
|
229
|
+
)
|
|
230
|
+
%>',
|
|
231
|
+
formats: [:html]
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
assert_includes html, "Discard"
|
|
235
|
+
assert_includes html, "Go back"
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
def test_install_generator_includes_confirmation_controller
|
|
239
|
+
assert_includes Baldur::Generators::InstallGenerator::CORE_CONTROLLERS, "confirmation"
|
|
240
|
+
end
|
|
241
|
+
end
|
data/test/test_helper.rb
CHANGED
|
@@ -13,4 +13,4 @@ require_relative "../app/helpers/baldur/ui_helper_unavailable"
|
|
|
13
13
|
require_relative "../app/helpers/baldur/ui_helper_forms"
|
|
14
14
|
require_relative "../app/helpers/baldur/marketing_helper"
|
|
15
15
|
require_relative "../app/helpers/baldur/ui_helper_sidebar"
|
|
16
|
-
require_relative "../app/helpers/baldur/ui_helper"
|
|
16
|
+
require_relative "../app/helpers/baldur/ui_helper"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "baldur/controllers/confirmation_controller"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: baldur
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Varun Murkar
|
|
@@ -43,30 +43,31 @@ dependencies:
|
|
|
43
43
|
requirements:
|
|
44
44
|
- - ">="
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version:
|
|
46
|
+
version: 7.0.0
|
|
47
47
|
type: :runtime
|
|
48
48
|
prerelease: false
|
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
50
50
|
requirements:
|
|
51
51
|
- - ">="
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version:
|
|
53
|
+
version: 7.0.0
|
|
54
54
|
- !ruby/object:Gem::Dependency
|
|
55
55
|
name: tailwindcss-rails
|
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
|
57
57
|
requirements:
|
|
58
58
|
- - ">="
|
|
59
59
|
- !ruby/object:Gem::Version
|
|
60
|
-
version: 4.
|
|
60
|
+
version: 4.3.0
|
|
61
61
|
type: :runtime
|
|
62
62
|
prerelease: false
|
|
63
63
|
version_requirements: !ruby/object:Gem::Requirement
|
|
64
64
|
requirements:
|
|
65
65
|
- - ">="
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: 4.
|
|
68
|
-
description: Baldur
|
|
69
|
-
Stimulus
|
|
67
|
+
version: 4.3.0
|
|
68
|
+
description: Baldur helps Rails teams ship polished UI faster with install generators,
|
|
69
|
+
reusable ui_* helpers, Tailwind components, and Stimulus wiring for apps using Propshaft,
|
|
70
|
+
importmap-rails, stimulus-rails, and tailwindcss-rails.
|
|
70
71
|
executables: []
|
|
71
72
|
extensions: []
|
|
72
73
|
extra_rdoc_files: []
|
|
@@ -78,6 +79,7 @@ files:
|
|
|
78
79
|
- TODO.md
|
|
79
80
|
- app/assets/javascripts/baldur/controllers/accordion_controller.js
|
|
80
81
|
- app/assets/javascripts/baldur/controllers/alert_controller.js
|
|
82
|
+
- app/assets/javascripts/baldur/controllers/confirmation_controller.js
|
|
81
83
|
- app/assets/javascripts/baldur/controllers/date_field_controller.js
|
|
82
84
|
- app/assets/javascripts/baldur/controllers/details_menu_controller.js
|
|
83
85
|
- app/assets/javascripts/baldur/controllers/form_submit_controller.js
|
|
@@ -111,6 +113,7 @@ files:
|
|
|
111
113
|
- app/assets/stylesheets/baldur/application/components/card.css
|
|
112
114
|
- app/assets/stylesheets/baldur/application/components/chart.css
|
|
113
115
|
- app/assets/stylesheets/baldur/application/components/chip.css
|
|
116
|
+
- app/assets/stylesheets/baldur/application/components/confirmation.css
|
|
114
117
|
- app/assets/stylesheets/baldur/application/components/dialog.css
|
|
115
118
|
- app/assets/stylesheets/baldur/application/components/forms.css
|
|
116
119
|
- app/assets/stylesheets/baldur/application/components/layout.css
|
|
@@ -157,12 +160,14 @@ files:
|
|
|
157
160
|
- app/views/baldur/components/_card.html.erb
|
|
158
161
|
- app/views/baldur/components/_chart_card.html.erb
|
|
159
162
|
- app/views/baldur/components/_checkbox.html.erb
|
|
163
|
+
- app/views/baldur/components/_confirmation_modal.html.erb
|
|
160
164
|
- app/views/baldur/components/_date_field.html.erb
|
|
161
165
|
- app/views/baldur/components/_google_sign_in_button.html.erb
|
|
162
166
|
- app/views/baldur/components/_kebab_menu.html.erb
|
|
163
167
|
- app/views/baldur/components/_kpi.html.erb
|
|
164
168
|
- app/views/baldur/components/_menu_select.html.erb
|
|
165
169
|
- app/views/baldur/components/_modal.html.erb
|
|
170
|
+
- app/views/baldur/components/_modal_host.html.erb
|
|
166
171
|
- app/views/baldur/components/_pagination.html.erb
|
|
167
172
|
- app/views/baldur/components/_segmented_buttons.html.erb
|
|
168
173
|
- app/views/baldur/components/_settings_nav.html.erb
|
|
@@ -202,6 +207,7 @@ files:
|
|
|
202
207
|
- lib/generators/baldur/install_panel_right/install_panel_right_generator.rb
|
|
203
208
|
- lib/generators/baldur/install_panel_secondary/install_panel_secondary_generator.rb
|
|
204
209
|
- script/verify_host_install
|
|
210
|
+
- test/confirmation_modal_helper_test.rb
|
|
205
211
|
- test/csp_rendering_test.rb
|
|
206
212
|
- test/gemspec_test.rb
|
|
207
213
|
- test/install_generator_test.rb
|
|
@@ -215,6 +221,7 @@ files:
|
|
|
215
221
|
- test/tmp/install_generator/app/assets/tailwind/application.css
|
|
216
222
|
- test/tmp/install_generator/app/helpers/ui_helper.rb
|
|
217
223
|
- test/tmp/install_generator/app/javascript/controllers/accordion_controller.js
|
|
224
|
+
- test/tmp/install_generator/app/javascript/controllers/confirmation_controller.js
|
|
218
225
|
- test/tmp/install_generator/app/javascript/controllers/date_field_controller.js
|
|
219
226
|
- test/tmp/install_generator/app/javascript/controllers/details_menu_controller.js
|
|
220
227
|
- test/tmp/install_generator/app/javascript/controllers/form_submit_controller.js
|
|
@@ -264,5 +271,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
264
271
|
requirements: []
|
|
265
272
|
rubygems_version: 4.0.6
|
|
266
273
|
specification_version: 4
|
|
267
|
-
summary:
|
|
274
|
+
summary: Batteries-included Rails UI engine for the importmap, Stimulus, Tailwind
|
|
275
|
+
stack
|
|
268
276
|
test_files: []
|