Class: PhlexyUI::Tab
Instance Method Summary collapse
- #content(**options) ⇒ Object
-
#initialize(id: nil) ⇒ Tab
constructor
A new instance of Tab.
- #view_template {|_self| ... } ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(id: nil) ⇒ Tab
6 7 8 9 |
# File 'lib/phlexy_ui/tab.rb', line 6 def initialize(*, id: nil, **) super(*, **) @id = id end |
Instance Method Details
#content(**options) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/phlexy_ui/tab.rb', line 27 def content(*, **, &) unless id raise ArgumentError, "You must pass an id to Tabs#new if you want to add content" end @content = -> do generate_classes!( # "tab-content" component_html_class: :"tab-content", options: ).then do |classes| div role: :tabpanel, class: classes, **, & end end end |
#view_template {|_self| ... } ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/phlexy_ui/tab.rb', line 11 def view_template(&) yield(self) if block_given? if @content render TabWithContent.new( *base_modifiers, id:, content: @content, **, & ) else render TabWithoutContent.new(*base_modifiers, id:, **, &) end end |