-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the radio button component to the doc (#155)
- Loading branch information
1 parent
c8291b1
commit 5232f11
Showing
5 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
module RubyUI | ||
class RadioButton < Base | ||
def view_template | ||
input(**attrs) | ||
end | ||
|
||
private | ||
|
||
def default_attrs | ||
{ | ||
type: "radio", | ||
data: { | ||
ruby_ui__form_field_target: "input", | ||
action: "change->ruby-ui--form-field#onInput invalid->ruby-ui--form-field#onInvalid" | ||
}, | ||
class: "h-4 w-4 p-0 border-primary rounded-full flex-none" | ||
} | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
class Docs::RadioButtonView < ApplicationView | ||
def view_template | ||
component = "RadioButton" | ||
|
||
div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do | ||
render Docs::Header.new(title: "Radio Button", description: "A control that allows users to make a single selection from a list of options.") | ||
|
||
Heading(level: 2) { "Usage" } | ||
|
||
render Docs::VisualCodeExample.new(title: "Example", context: self) do | ||
<<~RUBY | ||
div(class: "flex items-center space-x-2") do | ||
RadioButton(id: "default") | ||
FormFieldLabel(for: "default") { "Default" } | ||
end | ||
RUBY | ||
end | ||
|
||
render Docs::VisualCodeExample.new(title: "Checked", context: self) do | ||
<<~RUBY | ||
div(class: "flex items-center space-x-2") do | ||
RadioButton(id: "checked", checked: true) | ||
FormFieldLabel(for: "checked") { "Checked" } | ||
end | ||
RUBY | ||
end | ||
|
||
render Components::ComponentSetup::Tabs.new(component_name: component) | ||
|
||
render Docs::ComponentsTable.new(component_files(component)) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters