Class: StimulusPlumbers::Components::PasswordStrength

Inherits:
Plumber::Base
  • Object
show all
Defined in:
lib/stimulus_plumbers/components/password_strength.rb

Constant Summary collapse

LEVEL_KEYS =
%i[weak fine strong].freeze

Instance Attribute Summary

Attributes inherited from Plumber::Base

#template

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Plumber::Base

#initialize, #theme

Methods included from Plumber::Renderer

#set_slots, #slot_block_for, #slot_kwargs_for, #slot_renderable?

Methods included from Plumber::Options::Aria

#labelled_aria

Methods included from Plumber::Options::Html

#merge_html_options

Constructor Details

This class inherits a constructor from StimulusPlumbers::Plumber::Base

Class Method Details

.meter_id_for(input_id) ⇒ Object



9
10
11
# File 'lib/stimulus_plumbers/components/password_strength.rb', line 9

def meter_id_for(input_id)
  "#{input_id}_meter"
end

.rules_id_for(input_id) ⇒ Object



13
14
15
# File 'lib/stimulus_plumbers/components/password_strength.rb', line 13

def rules_id_for(input_id)
  "#{input_id}_rules"
end

Instance Method Details

#render(input:, input_id:, config:) ⇒ Object



18
19
20
21
22
23
# File 'lib/stimulus_plumbers/components/password_strength.rb', line 18

def render(input:, input_id:, config:)
  @config = config
  template.(:div, **wrapper_options(config, input_id)) do
    template.safe_join([input, render_meter(input_id), render_level, render_rules_heading, render_rules(input_id)])
  end
end