mirror of
https://github.com/manyfold3d/manyfold.git
synced 2026-10-23 04:02:19 -05:00
28 lines
881 B
Ruby
28 lines
881 B
Ruby
class Components::PasswordInputRow < Components::InputRow
|
|
def initialize(form:, attribute:, label:, strength_meter: false, help: nil, options: {})
|
|
@strength_meter = strength_meter
|
|
@field_options = {class: "form-control"}.merge(options)
|
|
if strength_meter
|
|
@field_options["data-controller"] = "zxcvbn"
|
|
@field_options["data-action"] = "input->zxcvbn#onInput"
|
|
end
|
|
super(form: form, attribute: attribute, label: label, help: help, options: options)
|
|
end
|
|
|
|
def input_group
|
|
div do
|
|
raw @form.password_field(@attribute, @field_options) # rubocop:disable Rails/OutputSafety
|
|
strength_meter
|
|
end
|
|
end
|
|
|
|
def strength_meter
|
|
return unless @strength_meter
|
|
div class: "progress" do
|
|
div class: "progress-bar w-0 zxcvbn-meter", data: {zxcvbn_min_score: Devise.min_password_score} do
|
|
whitespace
|
|
end
|
|
end
|
|
end
|
|
end
|