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
- #body_trait ⇒ Object
-
#caption_trait ⇒ Object
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…
- #heading_trait ⇒ Object
- #subheading_trait ⇒ Object
- #title_trait ⇒ Object
-
#truncate_trait ⇒ Object
Add the css class ‘text-truncate’ to a typeface component.
Instance Method Details
#body_trait ⇒ Object
15 16 17 |
# File 'lib/nfg_ui/components/traits/typeface.rb', line 15 def body_trait self.as = body_tag end |
#caption_trait ⇒ Object
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 self.as = [:caption] = body end |
#heading_trait ⇒ Object
30 31 32 33 |
# File 'lib/nfg_ui/components/traits/typeface.rb', line 30 def heading_trait self.as = heading_tag [:heading] = body end |
#subheading_trait ⇒ Object
35 36 37 38 |
# File 'lib/nfg_ui/components/traits/typeface.rb', line 35 def subheading_trait self.as = subheading_tag [:subheading] = body end |
#title_trait ⇒ Object
40 41 42 43 |
# File 'lib/nfg_ui/components/traits/typeface.rb', line 40 def title_trait self.as = title_tag [:title] = body end |
#truncate_trait ⇒ Object
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 [:class] = [.try(:[], :class), 'text-truncate'].join(' ').squish end |