Class: Bootstrap5Helper::CardWithNavTab
- Defined in:
- lib/bootstrap5_helper/card_with_nav_tab.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#content(opts = {}, &block) ⇒ Tab::Content
Builds the Content object for the Tab.
-
#initialize(template, *context_or_options, &block) ⇒ CardWithNavTab
constructor
Class constructor.
-
#nav(*tag_or_options) {|Nav| ... } ⇒ Nav
Builds a custom Nav component for the tabs.
- #to_s ⇒ Object
Methods inherited from Component
#capture, #concat, #config, #content_tag, #parse_arguments, #parse_context_or_options, #parse_tag_or_options, #parse_text_or_options, #uuid
Constructor Details
#initialize(template, context, opts) ⇒ CardWithNavTab #initialize(template, opts) ⇒ CardWithNavTab
Class constructor
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/bootstrap5_helper/card_with_nav_tab.rb', line 20 def initialize(template, *, &block) super(template) @context, args = (*, {}) @attrs = args @id = @attrs.delete(:id) { '' } @class = @attrs.delete(:class) { '' } @data = @attrs.delete(:data) { {} } @content = block || proc { '' } end |
Instance Method Details
#content(opts = {}, &block) ⇒ Tab::Content
Builds the Content object for the Tab.
76 77 78 79 80 |
# File 'lib/bootstrap5_helper/card_with_nav_tab.rb', line 76 def content(opts = {}, &block) content_tag :div, class: 'card-body' do Tab::Content.new(@template, opts, &block).to_s end end |
#nav(tag, opts) ⇒ Nav #nav(opts) ⇒ Nav
Builds a custom Nav component for the tabs.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/bootstrap5_helper/card_with_nav_tab.rb', line 51 def nav(*, &block) tag, args = (*, {}) args[:class] = (args[:class] || '') << ' nav-tabs card-header-tabs' args[:bs_attrs] = (args[:bs_attrs] || {}).merge( { data: { 'bs-toggle' => 'tab', 'bs-display' => 'static' } } ) content_tag :div, class: 'card-header' do Nav.new(@template, tag, args, &block).to_s end end |
#to_s ⇒ Object
TODO:
85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/bootstrap5_helper/card_with_nav_tab.rb', line 85 def to_s content_tag( :div, { class: "card with-nav-tabs-#{@context} #{@class}", id: @id, data: @data }.merge(@attrs) ) do @content.call(self) end end |