Module: NfgUi::Components::Traits::Typeface

Included in:
Foundations::Typeface
Defined in:
lib/nfg_ui/components/traits/typeface.rb

Overview

Access to pre-designed Alert traits

Constant Summary collapse

TRAITS =
%i[body
caption
heading
subheading
title
truncate].freeze

Instance Method Summary collapse

Instance Method Details

#body_traitObject



15
16
17
# File 'lib/nfg_ui/components/traits/typeface.rb', line 15

def body_trait
  self.as = body_tag
end

#caption_traitObject

TODO: this was a tricky one and needs specs (as well as other traits need this spec) Write a spec that tests that the typeface is ACTUALLY a caption this was identified earlier as not happening because we’d set the as option but it wasn’t spitting out the caption css_class… after some exploring it turned out the component didn’t understand that it was actually a caption… it just looked like one.



25
26
27
28
# File 'lib/nfg_ui/components/traits/typeface.rb', line 25

def caption_trait
  self.as = caption_tag
  options[:caption] = body
end

#heading_traitObject



30
31
32
33
# File 'lib/nfg_ui/components/traits/typeface.rb', line 30

def heading_trait
  self.as = heading_tag
  options[:heading] = body
end

#subheading_traitObject



35
36
37
38
# File 'lib/nfg_ui/components/traits/typeface.rb', line 35

def subheading_trait
  self.as = subheading_tag
  options[:subheading] = body
end

#title_traitObject



40
41
42
43
# File 'lib/nfg_ui/components/traits/typeface.rb', line 40

def title_trait
  self.as = title_tag
  options[:title] = body
end

#truncate_traitObject

Add the css class ‘text-truncate’ to a typeface component



46
47
48
# File 'lib/nfg_ui/components/traits/typeface.rb', line 46

def truncate_trait
  options[:class] = [options.try(:[], :class), 'text-truncate'].join(' ').squish
end