Class: NfgUi::Components::Foundations::Typeface

Inherits:
Base show all
Includes:
Bootstrap::Utilities::Themeable, Bootstrap::Utilities::Tooltipable, Bootstrap::Utilities::Wrappable, Traits::Muted, Traits::Theme, Traits::Typeface, Utilities::Iconable, Utilities::Titleable
Defined in:
lib/nfg_ui/components/foundations/typeface.rb

Overview

Typeface doc coming soon

Constant Summary

Constants included from Traits::Typeface

Traits::Typeface::TRAITS

Constants included from Traits::Theme

Traits::Theme::COLOR_TRAITS, Traits::Theme::TRAITS

Constants included from Traits::Muted

Traits::Muted::TRAITS

Constants included from Traits

Traits::REGISTERED_TRAITS, Traits::TRAIT_MODULES

Instance Attribute Summary

Attributes inherited from Bootstrap::Components::Base

#options, #view_context

Instance Method Summary collapse

Methods included from Traits::Typeface

#body_trait, #caption_trait, #heading_trait, #subheading_trait, #title_trait, #truncate_trait

Methods included from Traits::Theme

#danger_trait, #dark_trait, #info_trait, #light_trait, #outlined_trait, #primary_trait, #secondary_trait, #success_trait, #warning_trait, #white_trait

Methods included from Traits::Muted

#muted_trait

Methods included from Utilities::Titleable

#title

Methods included from Utilities::Iconable

#icon

Methods included from Bootstrap::Utilities::Tooltipable

#data, #disabled_component_tooltip_wrapper_html_options, #html_options, #tooltip

Methods included from Bootstrap::Utilities::Disableable

#disabled

Methods included from Bootstrap::Utilities::Themeable

#outlined, #theme

Methods included from Bootstrap::Utilities::Wrappable

#utility_initialize

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

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

Constructor Details

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

Instance Method Details

#asObject



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/nfg_ui/components/foundations/typeface.rb', line 29

def as
  if heading
    heading_tag
  elsif subheading
    subheading_tag
  elsif title
    title_tag
  elsif caption
    caption_tag
  else
    super
  end
end

#bodyObject



55
56
57
# File 'lib/nfg_ui/components/foundations/typeface.rb', line 55

def body
  super || heading || title || caption || subheading
end

#captionObject



51
52
53
# File 'lib/nfg_ui/components/foundations/typeface.rb', line 51

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

#headingObject



43
44
45
# File 'lib/nfg_ui/components/foundations/typeface.rb', line 43

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

#renderObject



19
20
21
22
23
24
25
26
27
# File 'lib/nfg_ui/components/foundations/typeface.rb', line 19

def render
  super do
    if icon
      NfgUi::Components::Foundations::Icon.new({ icon: icon, text: body }, view_context).render
    else
      body
    end
  end
end

#subheadingObject



47
48
49
# File 'lib/nfg_ui/components/foundations/typeface.rb', line 47

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