dsfr-form_builder 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/dsfr-form_builder.rb +39 -0
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0bc0aed96262591bbeeeb63159fa94ca318ab11b9de0c88d294a0d7083390bf5
4
- data.tar.gz: 5e2fabca8dcb56d0daf8de0dbb0ea4c4f26a258c9a2258b20b9ee5decc58d71a
3
+ metadata.gz: aff91dd2eb3c542a1f433c991f7192ee7e65ed067b12515231f5fa53a1ee3813
4
+ data.tar.gz: b98b1557af59d4d6d271a4ed430db74439badf97119ffdc1f01abf274b55ac43
5
5
  SHA512:
6
- metadata.gz: 3875f3099634c72fb24d81887ed86096d511c15b598048cbe2f3be0464086bdeeb5406d4481864f98d1b87722494455660a1b8de6b8201d502c637930b09314b
7
- data.tar.gz: be2d320662631073b6a17c3b05072e24dcdc5f8b81a1d6df1e748dd25a5aa17f27a6f29e986e066883a377c9f8614ddca45622e78be038956bde4ce85f2a364a
6
+ metadata.gz: c7388eb869cc537c7925bd98485197293e08f9ad0317833a1b7ac2e1ffb516c75146c4e9d0daedb559820c060326086d9865135302f36a0ec8f730673b3c6320
7
+ data.tar.gz: 460021e34f3557451b66f0c93b4f677bb14713b374c9f73ad006e20a2192d6b833158648b566927e5e0f300e0022d5b8b693c9acbdaddb73c3fb05d35038082d
@@ -16,6 +16,10 @@ module Dsfr
16
16
  dsfr_input_field(attribute, :text_field, opts)
17
17
  end
18
18
 
19
+ def dsfr_text_area(attribute, opts = {})
20
+ dsfr_input_field(attribute, :text_area, opts)
21
+ end
22
+
19
23
  def dsfr_email_field(attribute, opts = {})
20
24
  dsfr_input_field(attribute, :email_field, opts)
21
25
  end
@@ -77,6 +81,41 @@ module Dsfr
77
81
  select(attribute, choices, { include_blank: opts[:include_blank] }, class: "fr-select")
78
82
  end
79
83
 
84
+ def dsfr_radio_buttons(attribute, choices, legend: nil, hint: nil, **opts)
85
+ legend_content = @template.safe_join([
86
+ legend || @object.class.human_attribute_name(attribute),
87
+ hint ? hint_tag(hint) : nil
88
+ ].compact)
89
+ @template.content_tag(:fieldset, class: "fr-fieldset") do
90
+ @template.safe_join(
91
+ [
92
+ @template.content_tag(:legend, legend_content, class: "fr-fieldset__legend--regular fr-fieldset__legend"),
93
+ choices.map { |c| dsfr_radio_option(attribute, value: c[:value], label_text: c[:label], hint: c[:hint], **opts) }
94
+ ]
95
+ )
96
+ end
97
+ end
98
+
99
+ def dsfr_radio_option(attribute, value:, label_text:, hint:, **opts)
100
+ @template.content_tag(:div, class: "fr-fieldset__element") do
101
+ @template.content_tag(:div, class: "fr-radio-group") do
102
+ @template.safe_join(
103
+ [
104
+ radio_button(attribute, value, **opts),
105
+ label([ attribute, value ].join("_").to_sym) do
106
+ @template.safe_join(
107
+ [
108
+ label_text,
109
+ hint.present? ? @template.content_tag(:span, hint, class: "fr-hint-text") : nil
110
+ ]
111
+ )
112
+ end
113
+ ]
114
+ )
115
+ end
116
+ end
117
+ end
118
+
80
119
  def dsfr_label_with_hint(attribute, opts = {})
81
120
  label_class = "fr-label #{opts[:class]}"
82
121
  label(attribute, class: label_class) do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dsfr-form_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - BetaGouv developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-23 00:00:00.000000000 Z
11
+ date: 2025-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview