ds_fr: add radio_button_list component
This commit is contained in:
parent
94b9873bcd
commit
2135d3c4e7
2 changed files with 20 additions and 0 deletions
7
app/components/dsfr/radio_button_list_component.rb
Normal file
7
app/components/dsfr/radio_button_list_component.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class Dsfr::RadioButtonListComponent < ApplicationComponent
|
||||
def initialize(form:, target:, buttons:)
|
||||
@form = form
|
||||
@target = target
|
||||
@buttons = buttons
|
||||
end
|
||||
end
|
|
@ -0,0 +1,13 @@
|
|||
%fieldset.fr-fieldset{ 'aria-labelledby': 'radio-hint-element-legend radio-hint-element-messages' }
|
||||
%legend.fr-fieldset__legend--regular.fr-fieldset__legend
|
||||
= content
|
||||
|
||||
- @buttons.map { _1.values_at(:label, :value, :hint) }.each do |label, value, hint|
|
||||
.fr-fieldset__element
|
||||
.fr-radio-group
|
||||
= @form.radio_button @target, value
|
||||
= @form.label @target, value: value, class: 'fr-label' do
|
||||
- capture do
|
||||
= label
|
||||
%span.fr-hint-text= hint
|
||||
.fr-messages-group{ 'aria-live': 'assertive' }
|
Loading…
Add table
Reference in a new issue