class NfgUi::Bootstrap::Components::Card

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

Public Instance Methods

component_family() click to toggle source
# File lib/nfg_ui/bootstrap/components/card.rb, line 11
def component_family
  :card
end
heading() click to toggle source
# File lib/nfg_ui/bootstrap/components/card.rb, line 19
def heading
  options.fetch(:heading, '')
end
render() { |: body)| ... } click to toggle source
# File lib/nfg_ui/bootstrap/components/card.rb, line 31
def render
  content_tag(: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(content_tag(:h5, title, class: 'card-title')) if title.present?
          concat(content_tag(: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
subtitle() click to toggle source
# File lib/nfg_ui/bootstrap/components/card.rb, line 23
def subtitle
  options.fetch(:subtitle, '')
end
title() click to toggle source
# File lib/nfg_ui/bootstrap/components/card.rb, line 27
def title
  options.fetch(:title, '')
end

Private Instance Methods

css_classes() click to toggle source
# File lib/nfg_ui/bootstrap/components/card.rb, line 55
def css_classes
  return super unless theme.presence && theme != :light
  [
    super,
    (outlined ? "text-#{theme}" : 'text-white')
  ].join(' ').squish
end
default_theme() click to toggle source
# File lib/nfg_ui/bootstrap/components/card.rb, line 63
def default_theme
  nil
end
non_html_attribute_options() click to toggle source
# File lib/nfg_ui/bootstrap/components/card.rb, line 67
def non_html_attribute_options
  super.push(:footer, :heading, :subtitle, :title)
end
outlined_css_class_prefix() click to toggle source
# File lib/nfg_ui/bootstrap/components/card.rb, line 71
def outlined_css_class_prefix
  'border-'
end
theme_css_class_prefix() click to toggle source
# File lib/nfg_ui/bootstrap/components/card.rb, line 75
def theme_css_class_prefix
  outlined ? '' : 'bg-'
end