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
muted
truncate].freeze

Instance Method Summary collapse

Instance Method Details

#body_traitObject



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

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.



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

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

#heading_traitObject



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

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

#subheading_traitObject



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

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

#title_traitObject



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

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

#truncate_traitObject

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



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

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