baldur 0.2.3 → 0.2.5
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/TODO.md +1 -0
- data/app/assets/stylesheets/baldur/application/components/confirmation.css +0 -6
- data/app/helpers/baldur/ui_helper_feedback.rb +24 -0
- data/app/views/baldur/components/_confirmation_modal.html.erb +13 -13
- data/lib/baldur/version.rb +1 -1
- data/test/confirmation_modal_helper_test.rb +3 -0
- data/test/snackbar_flash_helper_test.rb +72 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6c30a02aad73679e5b6bb7d00222718c2d41404dc711304bc8c06e93b9263544
|
|
4
|
+
data.tar.gz: beaedad46ac4a8d0bf61b11812c0004675e8a9d707dee05fe54ae589f1ef1ff9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 75fe161cdcd9d876121c3ec9182ce70ce402b982a9b42628b2c19bd92286e695df48dc9252f59b11eb0a58406f690d7df50bb74eed56421b425377a6d1f85773
|
|
7
|
+
data.tar.gz: dd85ce27768bb4802ee67f2b27e11926dedf286a82d4dea893ac6463c47727a174017580ab62dbc08b7b6a9d1a7b269a82a392bbafc635ae73363fbb78b348e1
|
data/TODO.md
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
- [ ] Add end-to-end install verification in dummy app
|
|
10
10
|
|
|
11
11
|
## Showcase App and Docs
|
|
12
|
+
- [ ] Add agent-friendly docs, fetchable by Context7
|
|
12
13
|
- [ ] Add a dedicated dummy app in the extracted gem repo for visual smoke checks
|
|
13
14
|
- [ ] Add a component inventory/showcase page in that dummy app
|
|
14
15
|
- [ ] Add interaction showcase pages for modal, sidebar, menu select, snackbar, and `panel_secondary`
|
|
@@ -2,10 +2,4 @@
|
|
|
2
2
|
.confirmation-modal__input-wrapper {
|
|
3
3
|
margin-top: var(--space-4);
|
|
4
4
|
}
|
|
5
|
-
|
|
6
|
-
[data-confirmation] .text-field__control:focus {
|
|
7
|
-
border-color: var(--color-primary);
|
|
8
|
-
outline: none;
|
|
9
|
-
box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 24%, transparent);
|
|
10
|
-
}
|
|
11
5
|
}
|
|
@@ -23,6 +23,16 @@ module Baldur
|
|
|
23
23
|
baldur_render 'baldur/components/snackbar_stack', snackbars: normalize_snackbars(snackbars)
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
+
FLASH_SNACKBAR_VARIANTS = { success: :success, notice: :notice, alert: :error, warning: :warning }.freeze
|
|
27
|
+
|
|
28
|
+
def snackbar_flash_payloads(flash)
|
|
29
|
+
FLASH_SNACKBAR_VARIANTS.filter_map do |flash_key, variant|
|
|
30
|
+
payload = flash[flash_key]
|
|
31
|
+
next if payload.blank?
|
|
32
|
+
normalize_flash_snackbar(variant, payload)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
26
36
|
def ui_checkbox_tag(name, label: nil, description: nil, value: '1', checked: false, required: false,
|
|
27
37
|
disabled: false, id: nil, data: nil, aria: nil, form: nil, wrapper_class: nil, input_class: nil, &block)
|
|
28
38
|
body = block_given? ? capture(&block) : nil
|
|
@@ -77,6 +87,20 @@ module Baldur
|
|
|
77
87
|
values.to_sentence
|
|
78
88
|
end
|
|
79
89
|
|
|
90
|
+
def normalize_flash_snackbar(variant, payload)
|
|
91
|
+
return { variant: variant, message: payload } if payload.is_a?(String)
|
|
92
|
+
|
|
93
|
+
structured_payload = if payload.is_a?(Hash)
|
|
94
|
+
payload
|
|
95
|
+
elsif defined?(ActionController::Parameters) && payload.is_a?(ActionController::Parameters)
|
|
96
|
+
payload.to_unsafe_h
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
return { variant: variant, message: payload } unless structured_payload
|
|
100
|
+
|
|
101
|
+
structured_payload.symbolize_keys.reverse_merge(variant: variant)
|
|
102
|
+
end
|
|
103
|
+
|
|
80
104
|
def ui_alert_storage_key(collapse_key)
|
|
81
105
|
normalized_key = collapse_key.to_s.parameterize
|
|
82
106
|
return nil if normalized_key.blank?
|
|
@@ -68,19 +68,19 @@
|
|
|
68
68
|
<% end %>
|
|
69
69
|
<% if has_type_to_confirm %>
|
|
70
70
|
<div class="mt-4 space-y-2">
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
71
|
+
<%= ui_text_field_tag(nil, nil,
|
|
72
|
+
label: confirm_input_label,
|
|
73
|
+
placeholder: confirm_input_placeholder,
|
|
74
|
+
input_options: {
|
|
75
|
+
id: confirm_input_id,
|
|
76
|
+
autocomplete: "off",
|
|
77
|
+
data: {
|
|
78
|
+
confirmation_target: "input",
|
|
79
|
+
action: "input->confirmation#validate",
|
|
80
|
+
modal_autofocus: true
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
) %>
|
|
84
84
|
<% if confirm_input_hint.present? %>
|
|
85
85
|
<p class="text-sm text-muted"><%= confirm_input_hint %></p>
|
|
86
86
|
<% end %>
|
data/lib/baldur/version.rb
CHANGED
|
@@ -158,6 +158,8 @@ class BaldurConfirmationModalHelperTest < Minitest::Test
|
|
|
158
158
|
assert_includes html, 'This permanently removes all data.'
|
|
159
159
|
assert_includes html, 'Flush All Data'
|
|
160
160
|
assert_includes html, 'Confirm'
|
|
161
|
+
assert_includes html, 'field text-field'
|
|
162
|
+
assert_includes html, 'field__label'
|
|
161
163
|
end
|
|
162
164
|
|
|
163
165
|
def test_ui_confirmation_modal_type_to_confirm_disables_submit
|
|
@@ -215,6 +217,7 @@ class BaldurConfirmationModalHelperTest < Minitest::Test
|
|
|
215
217
|
|
|
216
218
|
assert_includes html, 'data-controller="modal"'
|
|
217
219
|
refute_includes html, 'confirmation'
|
|
220
|
+
refute_includes html, 'field text-field'
|
|
218
221
|
end
|
|
219
222
|
|
|
220
223
|
def test_ui_confirmation_modal_custom_labels
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
require_relative 'test_helper'
|
|
2
|
+
|
|
3
|
+
class BaldurSnackbarFlashHelperTest < Minitest::Test
|
|
4
|
+
include Baldur::UiHelperFeedback
|
|
5
|
+
|
|
6
|
+
def test_string_success_flash
|
|
7
|
+
flash = { success: "User created." }
|
|
8
|
+
result = snackbar_flash_payloads(flash)
|
|
9
|
+
assert_equal 1, result.length
|
|
10
|
+
assert_equal :success, result[0][:variant]
|
|
11
|
+
assert_equal "User created.", result[0][:message]
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_string_notice_flash
|
|
15
|
+
flash = { notice: "Check your email." }
|
|
16
|
+
result = snackbar_flash_payloads(flash)
|
|
17
|
+
assert_equal 1, result.length
|
|
18
|
+
assert_equal :notice, result[0][:variant]
|
|
19
|
+
assert_equal "Check your email.", result[0][:message]
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test_string_alert_flash
|
|
23
|
+
flash = { alert: "Something went wrong." }
|
|
24
|
+
result = snackbar_flash_payloads(flash)
|
|
25
|
+
assert_equal 1, result.length
|
|
26
|
+
assert_equal :error, result[0][:variant]
|
|
27
|
+
assert_equal "Something went wrong.", result[0][:message]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_string_warning_flash
|
|
31
|
+
flash = { warning: "Rate limited." }
|
|
32
|
+
result = snackbar_flash_payloads(flash)
|
|
33
|
+
assert_equal 1, result.length
|
|
34
|
+
assert_equal :warning, result[0][:variant]
|
|
35
|
+
assert_equal "Rate limited.", result[0][:message]
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_blank_flash_values_filtered
|
|
39
|
+
flash = { success: "", notice: nil, alert: "Failed." }
|
|
40
|
+
result = snackbar_flash_payloads(flash)
|
|
41
|
+
assert_equal 1, result.length
|
|
42
|
+
assert_equal :error, result[0][:variant]
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_multiple_flash_keys
|
|
46
|
+
flash = { success: "Created.", alert: "But something else failed." }
|
|
47
|
+
result = snackbar_flash_payloads(flash)
|
|
48
|
+
assert_equal 2, result.length
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def test_empty_flash
|
|
52
|
+
result = snackbar_flash_payloads({})
|
|
53
|
+
assert_equal [], result
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def test_hash_payload_with_custom_title
|
|
57
|
+
flash = { alert: { title: "Sign in failed", message: "Invalid credentials." } }
|
|
58
|
+
result = snackbar_flash_payloads(flash)
|
|
59
|
+
assert_equal 1, result.length
|
|
60
|
+
assert_equal :error, result[0][:variant]
|
|
61
|
+
assert_equal "Sign in failed", result[0][:title]
|
|
62
|
+
assert_equal "Invalid credentials.", result[0][:message]
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def test_hash_payload_reverse_merges_variant
|
|
66
|
+
flash = { success: { title: "Done!", message: "Record saved." } }
|
|
67
|
+
result = snackbar_flash_payloads(flash)
|
|
68
|
+
assert_equal 1, result.length
|
|
69
|
+
assert_equal :success, result[0][:variant]
|
|
70
|
+
assert_equal "Done!", result[0][:title]
|
|
71
|
+
end
|
|
72
|
+
end
|
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.2.
|
|
4
|
+
version: 0.2.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Varun Murkar
|
|
@@ -218,6 +218,7 @@ files:
|
|
|
218
218
|
- test/marketing_helper_test.rb
|
|
219
219
|
- test/run_all.rb
|
|
220
220
|
- test/sidebar_helper_test.rb
|
|
221
|
+
- test/snackbar_flash_helper_test.rb
|
|
221
222
|
- test/test_helper.rb
|
|
222
223
|
- test/theme_toggle_helper_test.rb
|
|
223
224
|
- test/tmp/install_generator/app/assets/stylesheets/fonts.css
|