Class: NfgUi::Components::Patterns::Tile

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

Overview

Tile doc coming soon

Constant Summary

Constants included from Traits::Collapse

Traits::Collapse::TRAITS

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 Traits::Collapse

#collapsed_trait, #collapsible_trait, #navbar_trait

Methods included from Utilities::Titleable

#title

Methods included from Utilities::Iconable

#icon

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, #href, #html_options, #id, #initialize, #style

Constructor Details

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

Instance Method Details

#component_familyObject



19
20
21
# File 'lib/nfg_ui/components/patterns/tile.rb', line 19

def component_family
  :tile
end

#headingObject



15
16
17
# File 'lib/nfg_ui/components/patterns/tile.rb', line 15

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

#renderObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/nfg_ui/components/patterns/tile.rb', line 27

def render
  super do
    if render_in_body
      if title.present?
        concat(NfgUi::Components::Patterns::TileHeader.new({ title: title, icon: icon, collapsible: collapsible, collapse: ("#collapse_#{id}" if collapsible) }, view_context).render)
      end
      if collapsible
        concat(NfgUi::Components::Patterns::Collapse.new({ id: "collapse_#{id}", collapsed: collapsed }, view_context).render {
          NfgUi::Components::Patterns::TileBody.new({ heading: heading }, view_context).render do
            (block_given? ? yield : body)
          end
        })
      else
        concat(NfgUi::Components::Patterns::TileBody.new({ heading: heading }, view_context).render {
          (block_given? ? yield : body)
        })
      end
    else
      (block_given? ? yield : body)
    end
  end
end

#render_in_bodyObject



23
24
25
# File 'lib/nfg_ui/components/patterns/tile.rb', line 23

def render_in_body
  options.fetch(:render_in_body, true)
end