Class: DaisyUI::Tab
Constant Summary
Constants inherited from Base
Base::BOOLS, Base::COLOR_MODIFIERS
Instance Method Summary collapse
- #content(**options, &block) ⇒ Object
-
#initialize(*modifiers, label: nil, id: nil) ⇒ Tab
constructor
A new instance of Tab.
- #view_template(&block) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(*modifiers, label: nil, id: nil) ⇒ Tab
Returns a new instance of Tab.
6 7 8 9 10 |
# File 'lib/daisy_ui/tab.rb', line 6 def initialize(*modifiers, label: nil, id: nil, **) super(*modifiers, **) @label = label @id = id end |
Instance Method Details
#content(**options, &block) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/daisy_ui/tab.rb', line 28 def content(*, **, &block) unless id raise ArgumentError, "You must pass an id to Tabs#new if you want to add content" end @content = lambda do content_classes = component_classes("tab-content", options:) div role: :tabpanel, class: content_classes, **, &block end end |
#view_template(&block) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/daisy_ui/tab.rb', line 12 def view_template(&block) block&.call(self) if @content render TabWithContent.new( *modifiers, label: @label, id:, content: @content, ** ) else render TabWithoutContent.new(*modifiers, label: @label, **) end end |