Class: NfgUi::Bootstrap::Components::Card

Inherits:
Base
  • Object
show all
Includes:
Utilities::Themeable
Defined in:
lib/nfg_ui/bootstrap/components/card.rb

Overview

Bootstrap Card Component getbootstrap.com/docs/4.1/components/cards/

Direct Known Subclasses

Components::Patterns::Card

Instance Attribute Summary

Attributes inherited from Base

#body, #options, #view_context

Instance Method Summary collapse

Methods included from Utilities::Themeable

#outlined, #theme

Methods inherited from Base

#data, #href, #html_options, #id, #initialize, #style

Constructor Details

This class inherits a constructor from NfgUi::Bootstrap::Components::Base

Instance Method Details

#component_familyObject



11
12
13
# File 'lib/nfg_ui/bootstrap/components/card.rb', line 11

def component_family
  :card
end


15
16
17
# File 'lib/nfg_ui/bootstrap/components/card.rb', line 15

def footer
  options.fetch(:footer, '')
end

#headingObject



19
20
21
# File 'lib/nfg_ui/bootstrap/components/card.rb', line 19

def heading
  options.fetch(:heading, '')
end

#renderObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/nfg_ui/bootstrap/components/card.rb', line 31

def render
  (:div, html_options) do
    capture do
      if heading.present?
        concat(NfgUi::Bootstrap::Components::CardHeader.new({ heading: heading }, view_context).render)
      end

      concat(NfgUi::Bootstrap::Components::CardBody.new({}, view_context).render {
        capture do
          concat((:h5, title, class: 'card-title')) if title.present?
          concat((:h6, subtitle, class: 'card-subtitle')) if subtitle.present?
          concat(block_given? ? yield : body)
        end
      })

      if footer.present?
        concat(NfgUi::Bootstrap::Components::CardFooter.new({ body: footer }, view_context).render)
      end
    end
  end
end

#subtitleObject



23
24
25
# File 'lib/nfg_ui/bootstrap/components/card.rb', line 23

def subtitle
  options.fetch(:subtitle, '')
end

#titleObject



27
28
29
# File 'lib/nfg_ui/bootstrap/components/card.rb', line 27

def title
  options.fetch(:title, '')
end