Skip to content

Commit 18b2074

Browse files
authored
[Forms] Fix position of caption for checkbox and radio groups (#3072)
Co-authored-by: camertron <[email protected]>
1 parent f5822fc commit 18b2074

File tree

14 files changed

+20
-11
lines changed

14 files changed

+20
-11
lines changed

.changeset/curvy-apes-judge.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/view-components': minor
3+
---
4+
5+
[Forms] Fix position of caption for checkbox and radio groups
-5 Bytes
Loading
-4 Bytes
Loading
-530 Bytes
Loading
-514 Bytes
Loading
10 Bytes
Loading
-4 Bytes
Loading

app/forms/check_box_group_form.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# :nodoc:
44
class CheckBoxGroupForm < ApplicationForm
55
form do |check_form|
6-
check_form.check_box_group(label: "I like to eat, eat, eat:") do |check_group|
6+
check_form.check_box_group(label: "I like to eat, eat, eat:", caption: "Nom nom nom") do |check_group|
77
check_group.check_box(
88
name: "long_a",
99
label: "Ey-ples and ba-naynays",

app/forms/radio_button_group_form.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
# :nodoc:
44
class RadioButtonGroupForm < ApplicationForm
55
form do |radio_form|
6-
radio_form.radio_button_group(name: "channel", label: "How did you hear about us?") do |radio_group|
6+
radio_form.radio_button_group(
7+
name: "channel",
8+
label: "How did you hear about us?",
9+
caption: "We love our listeners"
10+
) do |radio_group|
711
radio_group.radio_button(value: "online", label: "Online advertisement", caption: "Facebook maybe?")
812
radio_group.radio_button(value: "radio", label: "Radio advertisement", caption: "We love us some NPR")
913
radio_group.radio_button(value: "friend", label: "From a friend", caption: "Wow, what a good person")

lib/primer/forms/check_box_group.html.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
<%= @input.label %>
66
<% end %>
77
<% end %>
8+
<div class="mb-2">
9+
<%= render(Caption.new(input: @input)) %>
10+
</div>
811
<%= render(SpacingWrapper.new) do %>
912
<% @input.check_boxes.each do |check_box| %>
1013
<%= render(check_box.to_component) %>
@@ -14,7 +17,4 @@
1417
<div class="mt-2">
1518
<%= render(ValidationMessage.new(input: @input)) %>
1619
</div>
17-
<div class="mt-2">
18-
<%= render(Caption.new(input: @input)) %>
19-
</div>
2020
</div>

0 commit comments

Comments
 (0)