stimulus-password-strength 0.1.3 → 0.1.4
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/CHANGELOG.md +7 -0
- data/app/javascript/stimulus_password_strength_controller.js +5 -3
- data/app/views/stimulus_password_strength/_field.html.erb +9 -7
- data/lib/stimulus_password_strength/configuration.rb +11 -3
- data/lib/stimulus_password_strength/helper.rb +8 -0
- data/lib/stimulus_password_strength/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 680420b026742db8f17192cf372b51fa045aa79a23551709f11eed0875ce2f61
|
|
4
|
+
data.tar.gz: 451f9156e8c9c49ea463161cfd0b7a8f00b6e21387e15f2b50300dbaee0dfc2c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dfed9354d3578d4b0588081883fc37c66f003556379f1e13af8290b9248fd61d169364c1b59eae8d8d64dfb6e8f1caf16aa86866eb662fb8ecbb40b0b53f2ceb
|
|
7
|
+
data.tar.gz: ca2d4ca534ad631e78bb5deed5a996c9b8f8d82b7ab45f76e3419eb816bdf7c8525a73035b9a43167d05a4e374fe37414dfd7b7e964a6a191cc40cd3e7929233
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.4
|
|
4
|
+
|
|
5
|
+
- fixed a rendering bug where the password strength bar could stay visually hidden even though the label updated
|
|
6
|
+
- moved critical strength-bar and requirement layout fallbacks into inline styles so host-app Tailwind overrides cannot collapse the bar height or visibility
|
|
7
|
+
- preserved requirement base typography when pending/met/unmet states are updated in Stimulus
|
|
8
|
+
- expanded test coverage for the new style fallback properties and visible-bar behavior
|
|
9
|
+
|
|
3
10
|
## 0.1.3
|
|
4
11
|
|
|
5
12
|
- clarified the public README around adaptive usage modes: UI-only integration vs conversion-focused signup simplification
|
|
@@ -31,6 +31,7 @@ export default class extends Controller {
|
|
|
31
31
|
if (password.length === 0) {
|
|
32
32
|
this.statusRowTarget.style.visibility = "hidden"
|
|
33
33
|
this.strengthTrackTarget.style.visibility = "hidden"
|
|
34
|
+
this.strengthBarTarget.style.visibility = "hidden"
|
|
34
35
|
this.strengthBarTarget.style.width = "0%"
|
|
35
36
|
this.strengthBarTarget.style.backgroundColor = ""
|
|
36
37
|
this.strengthTextTarget.textContent = ""
|
|
@@ -41,6 +42,7 @@ export default class extends Controller {
|
|
|
41
42
|
|
|
42
43
|
this.statusRowTarget.style.visibility = "visible"
|
|
43
44
|
this.strengthTrackTarget.style.visibility = "visible"
|
|
45
|
+
this.strengthBarTarget.style.visibility = "visible"
|
|
44
46
|
const score = this.scoreFor(password)
|
|
45
47
|
const widths = [10, 25, 50, 75, 100]
|
|
46
48
|
const labels = ["weak", "weak", "fair", "good", "strong"]
|
|
@@ -131,7 +133,7 @@ export default class extends Controller {
|
|
|
131
133
|
if (password.length === 0) {
|
|
132
134
|
element.setAttribute("aria-hidden", "false")
|
|
133
135
|
element.innerHTML = this.escapeHtml(element.dataset.label)
|
|
134
|
-
element.style.cssText = `${element.dataset.pendingStyle}; visibility: visible;`
|
|
136
|
+
element.style.cssText = `${element.dataset.baseStyle}; ${element.dataset.pendingStyle}; visibility: visible;`
|
|
135
137
|
return
|
|
136
138
|
}
|
|
137
139
|
|
|
@@ -140,8 +142,8 @@ export default class extends Controller {
|
|
|
140
142
|
? this.metRequirementMarkup(element)
|
|
141
143
|
: this.escapeHtml(this.requirementLabel(element, password))
|
|
142
144
|
element.style.cssText = isMet
|
|
143
|
-
? `${element.dataset.metStyle}; visibility: visible;`
|
|
144
|
-
: `${element.dataset.unmetStyle}; visibility: visible;`
|
|
145
|
+
? `${element.dataset.baseStyle}; ${element.dataset.metStyle}; visibility: visible;`
|
|
146
|
+
: `${element.dataset.baseStyle}; ${element.dataset.unmetStyle}; visibility: visible;`
|
|
145
147
|
})
|
|
146
148
|
}
|
|
147
149
|
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
<div class="<%= label_row_class %>">
|
|
19
19
|
<%= form.label attribute, label, class: label_class %>
|
|
20
20
|
|
|
21
|
-
<div class="<%= header_aux_class %>">
|
|
21
|
+
<div class="<%= header_aux_class %>" style="<%= header_aux_style %>">
|
|
22
22
|
<% if requirements.any? %>
|
|
23
23
|
<div class="<%= requirements_class %>" style="<%= requirements_style %>">
|
|
24
24
|
<% requirements.each do |requirement| %>
|
|
@@ -32,8 +32,9 @@
|
|
|
32
32
|
data-pending-style="<%= requirement_pending_style %>"
|
|
33
33
|
data-met-style="<%= requirement_met_style %>"
|
|
34
34
|
data-unmet-style="<%= requirement_unmet_style %>"
|
|
35
|
+
data-base-style="<%= requirement_style %>"
|
|
35
36
|
class="<%= requirement_class %>"
|
|
36
|
-
style="<%= requirement_pending_style %>"><%= requirement[:label] %></p>
|
|
37
|
+
style="<%= requirement_style %>; <%= requirement_pending_style %>"><%= requirement[:label] %></p>
|
|
37
38
|
<% end %>
|
|
38
39
|
</div>
|
|
39
40
|
<% end %>
|
|
@@ -41,8 +42,8 @@
|
|
|
41
42
|
</div>
|
|
42
43
|
|
|
43
44
|
<div data-password-strength-target="statusRow" class="<%= status_row_class %>" style="<%= status_row_style %>; visibility: hidden;">
|
|
44
|
-
<div data-password-strength-target="strengthTrack" class="<%= bar_track_class %>" style="
|
|
45
|
-
<div data-password-strength-target="strengthBar" class="<%= bar_base_class %>" style="width: 0%"></div>
|
|
45
|
+
<div data-password-strength-target="strengthTrack" class="<%= bar_track_class %>" style="<%= bar_track_style %>">
|
|
46
|
+
<div data-password-strength-target="strengthBar" class="<%= bar_base_class %>" style="<%= bar_style %>; width: 0%"></div>
|
|
46
47
|
</div>
|
|
47
48
|
|
|
48
49
|
<p data-password-strength-target="strengthText" class="<%= text_base_class %>" style="<%= text_style %>" aria-live="polite"></p>
|
|
@@ -61,15 +62,16 @@
|
|
|
61
62
|
data-pending-style="<%= requirement_pending_style %>"
|
|
62
63
|
data-met-style="<%= requirement_met_style %>"
|
|
63
64
|
data-unmet-style="<%= requirement_unmet_style %>"
|
|
65
|
+
data-base-style="<%= requirement_style %>"
|
|
64
66
|
class="<%= requirement_class %>"
|
|
65
|
-
style="<%= requirement_pending_style %>"><%= requirement[:label] %></p>
|
|
67
|
+
style="<%= requirement_style %>; <%= requirement_pending_style %>"><%= requirement[:label] %></p>
|
|
66
68
|
<% end %>
|
|
67
69
|
</div>
|
|
68
70
|
<% end %>
|
|
69
71
|
|
|
70
72
|
<div data-password-strength-target="statusRow" class="<%= status_row_class %>" style="<%= status_row_style %>; visibility: hidden;">
|
|
71
|
-
<div data-password-strength-target="strengthTrack" class="<%= bar_track_class %>" style="
|
|
72
|
-
<div data-password-strength-target="strengthBar" class="<%= bar_base_class %>" style="width: 0%"></div>
|
|
73
|
+
<div data-password-strength-target="strengthTrack" class="<%= bar_track_class %>" style="<%= bar_track_style %>">
|
|
74
|
+
<div data-password-strength-target="strengthBar" class="<%= bar_base_class %>" style="<%= bar_style %>; width: 0%"></div>
|
|
73
75
|
</div>
|
|
74
76
|
|
|
75
77
|
<p data-password-strength-target="strengthText" class="<%= text_base_class %>" style="<%= text_style %>" aria-live="polite"></p>
|
|
@@ -6,15 +6,19 @@ module StimulusPasswordStrength
|
|
|
6
6
|
:label_row_class,
|
|
7
7
|
:label_class,
|
|
8
8
|
:header_aux_class,
|
|
9
|
+
:header_aux_style,
|
|
9
10
|
:status_row_class,
|
|
10
11
|
:status_row_style,
|
|
11
12
|
:requirements_class,
|
|
12
13
|
:requirements_style,
|
|
13
14
|
:requirement_class,
|
|
15
|
+
:requirement_style,
|
|
14
16
|
:input_class,
|
|
15
17
|
:toggle_class,
|
|
16
18
|
:bar_track_class,
|
|
19
|
+
:bar_track_style,
|
|
17
20
|
:bar_base_class,
|
|
21
|
+
:bar_style,
|
|
18
22
|
:text_base_class,
|
|
19
23
|
:text_style,
|
|
20
24
|
:hint_class,
|
|
@@ -29,17 +33,21 @@ module StimulusPasswordStrength
|
|
|
29
33
|
@label_row_class = "flex items-end justify-between gap-3"
|
|
30
34
|
@label_class = "block text-sm font-medium text-gray-700"
|
|
31
35
|
@header_aux_class = "flex justify-end"
|
|
36
|
+
@header_aux_style = "display: flex; justify-content: flex-end; align-items: center;"
|
|
32
37
|
@status_row_class = "flex min-h-5 items-center gap-2"
|
|
33
|
-
@status_row_style = "min-height: 1rem;"
|
|
38
|
+
@status_row_style = "display: flex; align-items: center; gap: 0.5rem; min-height: 1rem;"
|
|
34
39
|
@requirements_class = "flex justify-end gap-2"
|
|
35
|
-
@requirements_style = "min-height: 1rem;"
|
|
40
|
+
@requirements_style = "display: flex; justify-content: flex-end; align-items: center; gap: 0.5rem; min-height: 1rem;"
|
|
36
41
|
@requirement_class = "text-xs text-right leading-tight"
|
|
42
|
+
@requirement_style = "font-size: 0.75rem; line-height: 1rem; text-align: right;"
|
|
37
43
|
@input_class = "w-full rounded-xl border border-gray-300 px-4 py-3 pr-16 shadow-sm focus:border-blue-500 focus:ring-2 focus:ring-blue-200"
|
|
38
44
|
@toggle_class = "absolute right-3 top-1/2 -translate-y-1/2 cursor-pointer text-xs font-medium text-gray-500 hover:text-gray-700"
|
|
39
45
|
@bar_track_class = "h-1.5 w-20 overflow-hidden rounded-full bg-gray-100"
|
|
46
|
+
@bar_track_style = "height: 0.375rem; width: 5rem; overflow: hidden; border-radius: 9999px; background-color: #f3f4f6; visibility: hidden; flex-shrink: 0;"
|
|
40
47
|
@bar_base_class = "h-full rounded-full transition-all duration-300"
|
|
48
|
+
@bar_style = "display: block; height: 100%; border-radius: 9999px; visibility: hidden; transition: width 300ms ease, background-color 300ms ease;"
|
|
41
49
|
@text_base_class = "text-xs"
|
|
42
|
-
@text_style = "min-width: 2.5rem; text-align: right; white-space: nowrap;"
|
|
50
|
+
@text_style = "display: block; min-width: 2.5rem; text-align: right; white-space: nowrap;"
|
|
43
51
|
@hint_class = "mt-1 text-xs text-gray-500"
|
|
44
52
|
@requirement_pending_style = "color: #6b7280;"
|
|
45
53
|
@requirement_met_style = "color: #047857;"
|
|
@@ -16,14 +16,18 @@ module StimulusPasswordStrength
|
|
|
16
16
|
label_row_class = options.delete(:label_row_class) || config.label_row_class
|
|
17
17
|
label_class = options.delete(:label_class) || config.label_class
|
|
18
18
|
header_aux_class = options.delete(:header_aux_class) || config.header_aux_class
|
|
19
|
+
header_aux_style = options.delete(:header_aux_style) || config.header_aux_style
|
|
19
20
|
status_row_class = options.delete(:status_row_class) || config.status_row_class
|
|
20
21
|
status_row_style = options.delete(:status_row_style) || config.status_row_style
|
|
21
22
|
requirements_class = options.delete(:requirements_class) || config.requirements_class
|
|
22
23
|
requirements_style = options.delete(:requirements_style) || config.requirements_style
|
|
23
24
|
requirement_class = options.delete(:requirement_class) || config.requirement_class
|
|
25
|
+
requirement_style = options.delete(:requirement_style) || config.requirement_style
|
|
24
26
|
toggle_class = options.delete(:toggle_class) || config.toggle_class
|
|
25
27
|
bar_track_class = options.delete(:bar_track_class) || config.bar_track_class
|
|
28
|
+
bar_track_style = options.delete(:bar_track_style) || config.bar_track_style
|
|
26
29
|
bar_base_class = options.delete(:bar_base_class) || config.bar_base_class
|
|
30
|
+
bar_style = options.delete(:bar_style) || config.bar_style
|
|
27
31
|
text_base_class = options.delete(:text_base_class) || config.text_base_class
|
|
28
32
|
text_style = options.delete(:text_style) || config.text_style
|
|
29
33
|
hint_class = options.delete(:hint_class) || config.hint_class
|
|
@@ -46,14 +50,18 @@ module StimulusPasswordStrength
|
|
|
46
50
|
label_row_class: label_row_class,
|
|
47
51
|
label_class: label_class,
|
|
48
52
|
header_aux_class: header_aux_class,
|
|
53
|
+
header_aux_style: header_aux_style,
|
|
49
54
|
status_row_class: status_row_class,
|
|
50
55
|
status_row_style: status_row_style,
|
|
51
56
|
requirements_class: requirements_class,
|
|
52
57
|
requirements_style: requirements_style,
|
|
53
58
|
requirement_class: requirement_class,
|
|
59
|
+
requirement_style: requirement_style,
|
|
54
60
|
toggle_class: toggle_class,
|
|
55
61
|
bar_track_class: bar_track_class,
|
|
62
|
+
bar_track_style: bar_track_style,
|
|
56
63
|
bar_base_class: bar_base_class,
|
|
64
|
+
bar_style: bar_style,
|
|
57
65
|
text_base_class: text_base_class,
|
|
58
66
|
text_style: text_style,
|
|
59
67
|
hint_class: hint_class,
|