Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions app/components/password_toggle_component.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
<%= content_tag(:'lg-password-toggle', class: css_class) do %>
<%= render field if toggle_position == :bottom %>
<%= render ValidatedFieldComponent.new(
form: form,
name: :password,
type: :password,
label: label,
**field_options,
input_html: field_options[:input_html].to_h.merge(
id: input_id,
class: ['password-toggle__input', *field_options.dig(:input_html, :class)],
),
) %>
<div class="password-toggle__toggle-wrapper js">
<input
id="<%= toggle_id %>"
Expand All @@ -14,5 +24,4 @@
<%= toggle_label %>
</label>
</div>
<%= render field if toggle_position == :top %>
<% end %>
14 changes: 0 additions & 14 deletions app/components/password_toggle_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,4 @@ def toggle_id
def input_id
"password-toggle-input-#{unique_id}"
end

def field
ValidatedFieldComponent.new(
form: form,
name: :password,
type: :password,
label: label,
**field_options,
input_html: field_options[:input_html].to_h.merge(
id: input_id,
class: ['password-toggle__input', *field_options.dig(:input_html, :class)],
),
)
end
end
8 changes: 0 additions & 8 deletions spec/components/password_toggle_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@
it 'renders modifier class' do
expect(rendered).to have_css('lg-password-toggle.password-toggle--toggle-top')
end

it 'renders toggle before input' do
expect(rendered).to have_css('.password-toggle__toggle-wrapper + lg-validated-field')
end
end

context 'with bottom toggle position' do
Expand All @@ -64,10 +60,6 @@
it 'renders modifier class' do
expect(rendered).to have_css('lg-password-toggle.password-toggle--toggle-bottom')
end

it 'renders toggle after input' do
expect(rendered).to have_css('lg-validated-field + .password-toggle__toggle-wrapper')
end
end
end

Expand Down