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 |
# File 'lib/bootstrap5_helper/card_with_nav_tab.rb', line 20 def initialize(template, *, &block) super(template) @context, args = (*, {}) @id = args.fetch(:id, '') @class = args.fetch(:class, '') @data = args.fetch(:data, nil) @content = block || proc { '' } end |
Instance Method Details
#content(opts = {}, &block) ⇒ Tab::Content
Builds the Content object for the Tab.
73 74 75 76 77 |
# File 'lib/bootstrap5_helper/card_with_nav_tab.rb', line 73 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.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/bootstrap5_helper/card_with_nav_tab.rb', line 49 def nav(*, &block) tag, args = (*, {}) args[:class] = (args[:class] || '') << ' nav-tabs card-header-tabs' args[:data] = (args[:data] || {}).merge('bs-toggle' => 'tab') args[:child] = (args[:child] || {}).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:
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/bootstrap5_helper/card_with_nav_tab.rb', line 82 def to_s content_tag( :div, class: "card with-nav-tabs-#{@context} #{@class}", id: @id, data: @data ) do @content.call(self) end end |