Class: NfgUi::Components::Elements::SlatItem

Inherits:
Base show all
Includes:
Bootstrap::Utilities::Headable, Bootstrap::Utilities::Sizable, Traits::Size, Traits::SlatItem
Defined in:
lib/nfg_ui/components/elements/slat_item.rb

Overview

Slat doc coming soon

Constant Summary

Constants included from Traits::SlatItem

Traits::SlatItem::TRAITS

Constants included from Traits::Size

Traits::Size::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::SlatItem

#truncate_trait

Methods included from Traits::Size

#lg_trait, #md_trait, #sm_trait, #xl_trait

Methods included from Bootstrap::Utilities::Sizable

#size

Methods included from Bootstrap::Utilities::Headable

#heading

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

#captionObject



14
15
16
# File 'lib/nfg_ui/components/elements/slat_item.rb', line 14

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

#component_familyObject



18
19
20
# File 'lib/nfg_ui/components/elements/slat_item.rb', line 18

def component_family
  :slats
end

#renderObject



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

def render
  (base_element, slat_item_html_options) do
    if slat_header
      concat((:h6, slat_header, class: 'display-4 slat-column-header', **tooltip_html_options))
    end
    if heading
      if href
        concat((:a, href: view_context.url_for(href)) {
          NfgUi::Components::Foundations::Typeface.new({ subheading: heading, tooltip: tooltip }, view_context).render
        })
      else
        concat(NfgUi::Components::Foundations::Typeface.new({ subheading: heading, tooltip: tooltip }, view_context).render)
      end
    end
    concat(block_given? ? yield : body)
    if caption
      concat(NfgUi::Components::Foundations::Typeface.new({ caption: caption, class: 'mb-0', tooltip: (tooltip unless heading) }, view_context).render)
    end
  end
end

#slat_headerObject



22
23
24
# File 'lib/nfg_ui/components/elements/slat_item.rb', line 22

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

#tooltipObject

Leverage custom tooltip implementation so that tooltips are connected to slat item text and not the slat item containing div (resulting in better UI)



29
30
31
# File 'lib/nfg_ui/components/elements/slat_item.rb', line 29

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