Class: NitroKit::Fieldset
- Defined in:
- app/components/nitro_kit/fieldset.rb
Instance Attribute Summary
Attributes inherited from Component
Instance Method Summary collapse
- #description(text = nil, **attrs, &block) ⇒ Object
- #html_legend ⇒ Object
-
#initialize(legend: nil, description: nil, **attrs) ⇒ Fieldset
constructor
A new instance of Fieldset.
- #legend(text = nil, **attrs, &block) ⇒ Object
- #view_template ⇒ Object
Methods inherited from Component
Constructor Details
#initialize(legend: nil, description: nil, **attrs) ⇒ Fieldset
5 6 7 8 9 10 11 12 |
# File 'app/components/nitro_kit/fieldset.rb', line 5 def initialize(legend: nil, description: nil, **attrs) @legend = legend @description = description super( attrs, class: base_class ) end |
Instance Method Details
#description(text = nil, **attrs, &block) ⇒ Object
33 34 35 36 37 38 39 |
# File 'app/components/nitro_kit/fieldset.rb', line 33 def description(text = nil, **attrs, &block) builder do div(**mattr(attrs, class: description_class, data: { slot: "text" })) do text_or_block(text, &block) end end end |
#html_legend ⇒ Object
23 |
# File 'app/components/nitro_kit/fieldset.rb', line 23 alias :html_legend :legend |
#legend(text = nil, **attrs, &block) ⇒ Object
25 26 27 28 29 30 31 |
# File 'app/components/nitro_kit/fieldset.rb', line 25 def legend(text = nil, **attrs, &block) builder do html_legend(**mattr(attrs, class: legend_class)) do text_or_block(text, &block) end end end |
#view_template ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'app/components/nitro_kit/fieldset.rb', line 14 def view_template fieldset(**attrs) do legend(@legend) if @legend description(@description) if @description yield end end |