Class: NitroKit::CheckboxGroup
- Defined in:
- app/components/nitro_kit/checkbox_group.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Attributes inherited from Component
Instance Method Summary collapse
-
#initialize(options = nil, **attrs) ⇒ CheckboxGroup
constructor
A new instance of CheckboxGroup.
- #item(text = nil, **attrs, &block) ⇒ Object
- #title(text = nil, **attrs, &block) ⇒ Object
- #view_template ⇒ Object
Methods inherited from Component
Constructor Details
#initialize(options = nil, **attrs) ⇒ CheckboxGroup
Returns a new instance of CheckboxGroup.
5 6 7 8 9 10 11 12 |
# File 'app/components/nitro_kit/checkbox_group.rb', line 5 def initialize( = nil, **attrs) @options = super( attrs, class: "flex items-start flex-col gap-2" ) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
14 15 16 |
# File 'app/components/nitro_kit/checkbox_group.rb', line 14 def @options end |
Instance Method Details
#item(text = nil, **attrs, &block) ⇒ Object
34 35 36 37 38 39 40 |
# File 'app/components/nitro_kit/checkbox_group.rb', line 34 def item(text = nil, **attrs, &block) builder do render(Checkbox.new(**attrs)) do text_or_block(text, &block) end end end |
#title(text = nil, **attrs, &block) ⇒ Object
26 27 28 29 30 31 32 |
# File 'app/components/nitro_kit/checkbox_group.rb', line 26 def title(text = nil, **attrs, &block) builder do render(Label.new(**attrs)) do text_or_block(text, &block) end end end |
#view_template ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'app/components/nitro_kit/checkbox_group.rb', line 16 def view_template div(**attrs) do if block_given? yield else .map { |option| item(*option) } end end end |