Class: NitroKit::RadioGroup
- Includes:
- ActionView::Helpers::FormTagHelper
- Defined in:
- app/components/nitro_kit/radio_group.rb
Instance Attribute Summary collapse
-
#group_value ⇒ Object
readonly
Returns the value of attribute group_value.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes inherited from Component
Instance Method Summary collapse
-
#initialize(name, value: nil, **options) ⇒ RadioGroup
constructor
A new instance of RadioGroup.
- #item(value, text = nil, **options) ⇒ Object
- #title(text = nil, **options) ⇒ Object
- #view_template ⇒ Object
Methods inherited from Component
Constructor Details
#initialize(name, value: nil, **options) ⇒ RadioGroup
Returns a new instance of RadioGroup.
5 6 7 8 9 |
# File 'app/components/nitro_kit/radio_group.rb', line 5 def initialize(name, value: nil, **) super(**) @name = name @group_value = value end |
Instance Attribute Details
#group_value ⇒ Object (readonly)
Returns the value of attribute group_value.
11 12 13 |
# File 'app/components/nitro_kit/radio_group.rb', line 11 def group_value @group_value end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
11 12 13 |
# File 'app/components/nitro_kit/radio_group.rb', line 11 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'app/components/nitro_kit/radio_group.rb', line 11 def name @name end |
Instance Method Details
#item(value, text = nil, **options) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/components/nitro_kit/radio_group.rb', line 23 def item(value, text = nil, **) render( RadioButton.new( name, id:, value:, checked: group_value.presence == value, ** ) ) { text || yield } end |
#title(text = nil, **options) ⇒ Object
19 20 21 |
# File 'app/components/nitro_kit/radio_group.rb', line 19 def title(text = nil, **) render(Label.new(**)) { text || yield } end |
#view_template ⇒ Object
13 14 15 16 17 |
# File 'app/components/nitro_kit/radio_group.rb', line 13 def view_template div(class: "flex items-start flex-col gap-2") do yield end end |