Skip to content

Commit eac2ab9

Browse files
committed
refactor(haml): migrate Dsfr::InputComponent to ERB
1 parent ca94686 commit eac2ab9

2 files changed

Lines changed: 87 additions & 49 deletions

File tree

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<%= content_tag(:div, input_group_opts) do %>
2+
<%= @form.label @attribute, label_opts do %>
3+
<% capture do %>
4+
<%= label %>
5+
6+
<% if required? %>
7+
<%= render EditableChamp::AsteriskMandatoryComponent.new %>
8+
<% end %>
9+
10+
<% if hint_renderable? %>
11+
<span class="fr-hint-text"><%= hint %></span>
12+
<% end %>
13+
<% end %>
14+
<% end %>
15+
16+
<% if button.present? %>
17+
<div class="fr-input-wrap fr-input-wrap--addon">
18+
<%= @form.public_send(@input_type, @attribute, input_opts) %>
19+
<%= button %>
20+
</div>
21+
<% else %>
22+
<%= @form.public_send(@input_type, @attribute, input_opts) %>
23+
<% end %>
24+
25+
<% if errors_on_attribute? %>
26+
<% if error_messages.size == 1 %>
27+
<p class="fr-error-text" id="<%= error_id %>">
28+
<%= error_messages.first %>
29+
</p>
30+
<% else %>
31+
<div class="fr-error-text" id="<%= error_id %>">
32+
<ul class="list-style-type-none fr-pl-0">
33+
<% error_messages.each do |error_message| %>
34+
<li><%= error_message %></li>
35+
<% end %>
36+
</ul>
37+
</div>
38+
<% end %>
39+
<% elsif describedby.present? %>
40+
<%= describedby %>
41+
<% end %>
42+
43+
<% if password? %>
44+
<div class="fr-password__checkbox fr-checkbox-group fr-checkbox-group--sm">
45+
<input
46+
id="<%= show_password_id %>"
47+
aria-label="<%= aria_label_show_confirmation %>"
48+
type="checkbox"
49+
>
50+
51+
<label
52+
class="fr--password__checkbox fr-label"
53+
for="<%= show_password_id %>"
54+
>
55+
<%= t('.show_password.label') %>
56+
</label>
57+
</div>
58+
<% end %>
59+
60+
<% if email? %>
61+
<div
62+
class="suspect-email hidden"
63+
data-email-input-target="ariaRegion"
64+
tabindex="-1"
65+
>
66+
<%= render Dsfr::AlertComponent.new(title: t('.email_suggest.mistake'), state: '', extra_class_names: 'fr-alert--info') do |c| %>
67+
<% c.with_body do %>
68+
<p>
69+
<%= t('.email_suggest.wanna_say') %>
70+
<span data-email-input-target="suggestion">exemple@gmail.com</span>
71+
<%= "?" %>
72+
</p>
73+
74+
<p>
75+
<%= button_tag type: 'button', class: 'fr-btn fr-btn--sm fr-mr-3w', data: { action: 'click->email-input#accept' } do %>
76+
<%= t('utils.yes') %>
77+
<% end %>
78+
79+
<%= button_tag type: 'button', class: 'fr-btn fr-btn--sm', data: { action: 'click->email-input#discard' } do %>
80+
<%= t('utils.no') %>
81+
<% end %>
82+
</p>
83+
<% end %>
84+
<% end %>
85+
</div>
86+
<% end %>
87+
<% end %>

app/components/dsfr/input_component/input_component.html.haml

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)