Class: NfgUi::Components::Patterns::TileHeader

Inherits:
Base show all
Includes:
Bootstrap::Utilities::Collapsible, Utilities::Iconable, Utilities::Titleable
Defined in:
lib/nfg_ui/components/patterns/tile_header.rb

Overview

TileHeader doc coming soon

Constant Summary

Constants included from Traits

Traits::REGISTERED_TRAITS, Traits::TRAIT_MODULES

Instance Attribute Summary

Attributes inherited from Bootstrap::Components::Base

#body, #options, #view_context

Instance Method Summary collapse

Methods included from Utilities::Iconable

#icon

Methods included from Utilities::Titleable

#title

Methods included from Bootstrap::Utilities::Collapsible

#collapse, #collapsed, #collapsible

Methods included from Utilities::Traitable

#traits, #utility_initialize

Methods included from Utilities::Renderable

#render_if, #render_unless

Methods included from Utilities::Describable

#data, #describe

Methods inherited from Bootstrap::Components::Base

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

Constructor Details

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

Instance Method Details

#buttonObject



17
18
19
# File 'lib/nfg_ui/components/patterns/tile_header.rb', line 17

def button
  options.fetch(:button, nil)
end

#component_familyObject



13
14
15
# File 'lib/nfg_ui/components/patterns/tile_header.rb', line 13

def component_family
  :tile
end

#hrefObject



21
22
23
# File 'lib/nfg_ui/components/patterns/tile_header.rb', line 21

def href
  options.fetch(:href, nil)
end

#renderObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/nfg_ui/components/patterns/tile_header.rb', line 29

def render
  super do
    if title
      concat((:div, class: 'row') do
        concat((:div, class: "col") do
          (:div, class: 'row') do
            concat((:div, class: 'col-12 col-md') do
              concat(NfgUi::Components::Foundations::Typeface.new({ heading: title, icon: icon, class: 'h4' }, view_context).render)
              if subtitle
                concat(NfgUi::Components::Foundations::Typeface.new({ body: subtitle, traits: [:muted], class: 'mt-1 mb-0' }, view_context).render)
              end
            end)

            if button
              concat((:div, class: 'col-12 col-md-auto mt-md-0 mt-2') do
                NfgUi::Components::Elements::Button.new({theme: :secondary, href: href, body: button}, view_context).render

              end)
            end
          end
        end)

        if collapsible
          concat((:div, class: 'col-auto pl-0') do
            NfgUi::Components::Elements::Button.new({ traits: [:link], collapse: collapse, data: { collapse_icon: collapse_icon, collapsed_icon: collapsed_icon } }, view_context).render do

              # The button cannot host a data-toggle for tooltip
              # and a data-toggle for collapse

              # In order to accomodate the tooltip, we have to
              # render the icon manually without using the button's
              # options so that we're applying the tooltip on the
              # icon and not the button.
              NfgUi::Components::Foundations::Icon.new({ traits: ["#{contextual_collapsible_icon} fw"], tooltip: 'Show / hide additional information' }, view_context).render
            end
          end)
        end
      end)
    end
    concat((block_given? ? yield : body))
  end
end

#subtitleObject



25
26
27
# File 'lib/nfg_ui/components/patterns/tile_header.rb', line 25

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