Module: NdrUi::Bootstrap::CardHelper
- Includes:
- CssHelper
- Included in:
- NdrUi::BootstrapHelper
- Defined in:
- app/helpers/ndr_ui/bootstrap/card_helper.rb
Overview
This provides accordion
Constant Summary collapse
- CARD_TYPES =
%w[primary secondary success danger warning info light dark].freeze
Instance Method Summary collapse
-
#bootstrap_card_body_tag(&block) ⇒ Object
Creates a simple bootstrap card body.
-
#bootstrap_card_list(title, options = {}, &block) ⇒ Object
Creates a bootstrap card wrapper.
-
#bootstrap_card_tag(heading, controls = nil, options = {}, &block) ⇒ Object
Creates a bootstrap card wrapper.
-
#bootstrap_well_tag(options = {}, &block) ⇒ Object
Bootstrap v4 dropped Wells for Card component create a wrapper for Wells - a Card without heading.
Methods included from CssHelper
Instance Method Details
#bootstrap_card_body_tag(&block) ⇒ Object
Creates a simple bootstrap card body.
Signatures
bootstrap_card_body_tag do
#content for card body
end
Examples
<%= bootstrap_card_body_tag do %>
Check it out!!
<% end %>
# => <div class="card-body">Check it out!!</div>
60 61 62 63 64 |
# File 'app/helpers/ndr_ui/bootstrap/card_helper.rb', line 60 def bootstrap_card_body_tag(&block) return unless block_given? content_tag(:div, capture(&block), class: 'card-body') end |
#bootstrap_card_list(title, options = {}, &block) ⇒ Object
Creates a bootstrap card wrapper. the heading is wrapped in a card-header. The content is wrapped in a ul.list-group to enable seamless lists. It doesn’t support controls (controls = nil).
69 70 71 72 73 |
# File 'app/helpers/ndr_ui/bootstrap/card_helper.rb', line 69 def bootstrap_card_list(title, = {}, &block) bootstrap_card_tag(title, nil, ) do content_tag(:div, capture(&block), class: 'list-group list-group-flush') end end |
#bootstrap_card_tag(heading, controls = nil, options = {}, &block) ⇒ Object
Creates a bootstrap card wrapper. the heading is wrapped in a card-header. The content is not wrapped in a card-body to enable seamless tables and lists.
Signatures
bootstrap_card_tag(heading, = {}) do
#content for card
end
Examples
<%= bootstrap_card_tag 'Apples', type: :warning, id: 'fruit' do %>
Check it out!!
<% end %>
# => <div id="fruit" class="card mb-3 text-bg-warning">
<div class="card-header d-flex">
<h4 class="card-title">Apples</h4>
<div class="ms-auto"></div>
</div>
Check it out!!
</div>
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/helpers/ndr_ui/bootstrap/card_helper.rb', line 30 def bootstrap_card_tag(heading, controls = nil, = {}, &block) return unless block_given? .stringify_keys! classes = %w[card mb-3] classes << "bg-#{.delete('type')}-subtle" if CARD_TYPES.include?(['type'].to_s) = (, classes) header = content_tag(:div, class: "card-header#{' d-flex' if controls.present?}") do concat content_tag(:h4, heading, class: 'card-title') concat content_tag(:div, controls, class: 'ms-auto') if controls.present? end content_tag(:div, header + capture(&block), ) end |
#bootstrap_well_tag(options = {}, &block) ⇒ Object
Bootstrap v4 dropped Wells for Card component create a wrapper for Wells - a Card without heading
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'app/helpers/ndr_ui/bootstrap/card_helper.rb', line 77 def bootstrap_well_tag( = {}, &block) return unless block_given? .stringify_keys! classes = %w[card mb-3] classes << (CARD_TYPES.include?(['type'].to_s) ? "bg-#{.delete('type')}-subtle" : 'text-bg-light') classes += ['class'].to_s.split if ['class'].present? ['class'] = classes.uniq.join(' ') content_tag(:div, ) do bootstrap_card_body_tag do capture(&block) end end end |