class NfgUi::Components::Foundations::Typeface

Typeface doc coming soon

Public Instance Methods

as() click to toggle source
Calls superclass method
# 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
body() click to toggle source
Calls superclass method
# File lib/nfg_ui/components/foundations/typeface.rb, line 55
def body
  super || heading || title || caption || subheading
end
caption() click to toggle source
# File lib/nfg_ui/components/foundations/typeface.rb, line 51
def caption
  options.fetch(:caption, nil)
end
heading() click to toggle source
# File lib/nfg_ui/components/foundations/typeface.rb, line 43
def heading
  options.fetch(:heading, nil)
end
render() click to toggle source
# 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
subheading() click to toggle source
# File lib/nfg_ui/components/foundations/typeface.rb, line 47
def subheading
  options.fetch(:subheading, nil)
end

Private Instance Methods

base_element() click to toggle source

def text_or_icon

icon ? view_context.ui.nfg(:icon, icon, text: text) : text

end

# File lib/nfg_ui/components/foundations/typeface.rb, line 65
def base_element
  as
end
body_tag() click to toggle source
# File lib/nfg_ui/components/foundations/typeface.rb, line 96
def body_tag
  :p
end
caption_tag() click to toggle source
# File lib/nfg_ui/components/foundations/typeface.rb, line 92
def caption_tag
  :p
end
component_css_class() click to toggle source
# File lib/nfg_ui/components/foundations/typeface.rb, line 84
def component_css_class
  ''
end
css_classes() click to toggle source
# File lib/nfg_ui/components/foundations/typeface.rb, line 73
def css_classes
  [
    super,
    ('font-size-sm' if caption)
  ].join(' ').squish
end
default_html_wrapper_element() click to toggle source
# File lib/nfg_ui/components/foundations/typeface.rb, line 112
def default_html_wrapper_element
  body_tag
end
default_theme() click to toggle source
# File lib/nfg_ui/components/foundations/typeface.rb, line 80
def default_theme
  nil
end
heading_tag() click to toggle source
# File lib/nfg_ui/components/foundations/typeface.rb, line 100
def heading_tag
  :h5
end
non_html_attribute_options() click to toggle source
# File lib/nfg_ui/components/foundations/typeface.rb, line 88
def non_html_attribute_options
  super.push(:heading, :body, :title, :caption, :subheading)
end
outlineable?() click to toggle source
# File lib/nfg_ui/components/foundations/typeface.rb, line 116
def outlineable?
  false
end
subheading_tag() click to toggle source
# File lib/nfg_ui/components/foundations/typeface.rb, line 108
def subheading_tag
  :h6
end
theme_css_class_prefix() click to toggle source
# File lib/nfg_ui/components/foundations/typeface.rb, line 69
def theme_css_class_prefix
  'text-'
end
title_tag() click to toggle source
# File lib/nfg_ui/components/foundations/typeface.rb, line 104
def title_tag
  :h6
end