Skip to content

Commit 4dd7f90

Browse files
authored
ADD CHECKBOX_GROUP (#126)
* FIX CheckboxGroup * BUG replicated * 1st OK * 1st OK * FOO, BAR * standardrb --fix * 1st OK
1 parent 4a51907 commit 4dd7f90

File tree

6 files changed

+97
-0
lines changed

6 files changed

+97
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Here is the list of components that are being built. For reference, see here htt
1414
✅ Calendar
1515
✅ Card
1616
✅ Checkbox
17+
✅ CheckboxGroup
1718
✅ Codeblock
1819
✅ Collapsible
1920
⚪️ Combobox

app/controllers/docs_controller.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ def checkbox
7878
render Docs::CheckboxView.new
7979
end
8080

81+
def checkbox_group
82+
render Docs::CheckboxGroupView.new
83+
end
84+
8185
def clipboard
8286
render Docs::ClipboardView.new
8387
end

app/views/components/shared/menu.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ def components
7272
{name: "Calendar", path: helpers.docs_calendar_path},
7373
# { name: "Chart", path: helpers.docs_chart_path, badge: "New" },
7474
{name: "Checkbox", path: helpers.docs_checkbox_path},
75+
{name: "CheckboxGroup", path: helpers.docs_checkbox_group_path},
7576
{name: "Clipboard", path: helpers.docs_clipboard_path},
7677
{name: "Codeblock", path: helpers.docs_codeblock_path},
7778
{name: "Collapsible", path: helpers.docs_collapsible_path},

app/views/docs/checkbox_group_view.rb

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# frozen_string_literal: true
2+
3+
class Docs::CheckboxGroupView < ApplicationView
4+
def view_template
5+
component = "CheckboxGroup"
6+
7+
div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do
8+
render Docs::Header.new(title: "CheckboxGroup", description: "A control that allows the user to toggle between checked and not checked.")
9+
10+
Heading(level: 2) { "Usage" }
11+
12+
render Docs::VisualCodeExample.new(title: "Example", context: self) do
13+
<<~RUBY
14+
CheckboxGroup(data_required: true) do
15+
div(class: "flex flex-col gap-2") do
16+
div(class: "flex flex-row items-center gap-2") do
17+
Checkbox(value: "FOO", id: "FOO")
18+
FormFieldLabel(for: "FOO") { "FOO" }
19+
end
20+
21+
div(class: "flex flex-row items-center gap-2") do
22+
Checkbox(value: "BAR", id: "BAR")
23+
FormFieldLabel(for: "BAR") { "BAR" }
24+
end
25+
end
26+
end
27+
RUBY
28+
end
29+
30+
render Docs::VisualCodeExample.new(title: "With Form", context: self) do
31+
<<~RUBY
32+
form(class: "flex flex-col gap-2") do
33+
FormField do
34+
FormFieldLabel { "CHECKBOX_GROUP" }
35+
36+
FormFieldHint { "HINT_FOR_CHECKBOX_GROUP" }
37+
38+
CheckboxGroup(data_required: true) do
39+
div(class: "flex flex-col gap-2") do
40+
div(class: "flex flex-row items-center gap-2") do
41+
Checkbox(
42+
id: "FOO",
43+
value: "FOO",
44+
checked: false,
45+
name: "CHECKBOX_GROUP[]",
46+
data: {value_missing: "CUSTOM_MESSAGE"}
47+
)
48+
49+
FormFieldLabel(for: "FOO") { "FOO" }
50+
end
51+
52+
div(class: "flex flex-row items-center gap-2") do
53+
Checkbox(
54+
id: "BAR",
55+
value: "BAR",
56+
checked: true,
57+
name: "CHECKBOX_GROUP[]",
58+
data: {value_missing: "CUSTOM_MESSAGE"}
59+
)
60+
61+
FormFieldLabel(for: "BAR") { "BAR" }
62+
end
63+
end
64+
end
65+
66+
FormFieldError()
67+
end
68+
69+
Button(type: "submit") { "SUBMIT_BUTTON" }
70+
end
71+
RUBY
72+
end
73+
74+
render Docs::ComponentsTable.new(component_references(component, Docs::VisualCodeExample.collected_code), component_files(component))
75+
end
76+
end
77+
end

config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
get "calendar", to: "docs#calendar", as: :docs_calendar
2828
get "chart", to: "docs#chart", as: :docs_chart
2929
get "checkbox", to: "docs#checkbox", as: :docs_checkbox
30+
get "checkbox_group", to: "docs#checkbox_group", as: :docs_checkbox_group
3031
get "clipboard", to: "docs#clipboard", as: :docs_clipboard
3132
get "codeblock", to: "docs#codeblock", as: :docs_codeblock
3233
get "collapsible", to: "docs#collapsible", as: :docs_collapsible
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# frozen_string_literal: true
2+
3+
module RBUI
4+
class CheckboxGroupPreview < Lookbook::Preview
5+
# Default CheckboxGroup
6+
# ---------------
7+
def default
8+
render(TestView.new) do
9+
CheckboxGroup(id: "terms")
10+
end
11+
end
12+
end
13+
end

0 commit comments

Comments
 (0)