Class: DaisyUI::Tab
- Inherits:
-
Base
- Object
- Phlex::HTML
- Base
- DaisyUI::Tab
show all
- Defined in:
- lib/daisy_ui/tab.rb
Constant Summary
Constants inherited
from Base
Base::BOOLS, Base::COLOR_MODIFIERS
Instance Method Summary
collapse
Methods inherited from Base
inherited, register_modifiers
Constructor Details
#initialize(*modifiers, label: nil, id: nil) ⇒ 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(*, **options, &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, **options, &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,
**options
)
else
render TabWithoutContent.new(*modifiers, label: @label, **options)
end
end
|