Sha256: 063efedbfcf91e48e62af157c56fdde3e58143f374d402f732f48bc940e647e6

Contents?: true

Size: 1.49 KB

Versions: 60

Compression:

Stored size: 1.49 KB

Contents

# frozen_string_literal: true

module NfgUi
  module Components
    module Traits
      # Access to pre-designed Alert traits
      module Typeface
        TRAITS = %i[body
                    caption
                    heading
                    subheading
                    title
                    muted
                    truncate].freeze

        def body_trait
          self.as = body_tag
        end

        # 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.
        def caption_trait
          self.as = caption_tag
          options[:caption] = body
        end

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

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

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

        # Add the css class 'text-truncate' to a typeface component
        def truncate_trait
          options[:class] = [options.try(:[], :class), 'text-truncate'].join(' ').squish
        end
      end
    end
  end
end

Version data entries

60 entries across 60 versions & 1 rubygems

Version Path
nfg_ui-0.11.7 lib/nfg_ui/components/traits/typeface.rb
nfg_ui-0.11.6 lib/nfg_ui/components/traits/typeface.rb
nfg_ui-0.11.5 lib/nfg_ui/components/traits/typeface.rb
nfg_ui-0.11.4 lib/nfg_ui/components/traits/typeface.rb
nfg_ui-0.11.3 lib/nfg_ui/components/traits/typeface.rb
nfg_ui-0.11.2 lib/nfg_ui/components/traits/typeface.rb
nfg_ui-0.11.1.1 lib/nfg_ui/components/traits/typeface.rb
nfg_ui-0.11.1 lib/nfg_ui/components/traits/typeface.rb
nfg_ui-0.11.0 lib/nfg_ui/components/traits/typeface.rb
nfg_ui-0.10.15.1 lib/nfg_ui/components/traits/typeface.rb
nfg_ui-0.10.15 lib/nfg_ui/components/traits/typeface.rb
nfg_ui-0.10.14 lib/nfg_ui/components/traits/typeface.rb
nfg_ui-0.10.13 lib/nfg_ui/components/traits/typeface.rb
nfg_ui-0.10.12 lib/nfg_ui/components/traits/typeface.rb
nfg_ui-0.10.11 lib/nfg_ui/components/traits/typeface.rb
nfg_ui-0.10.10 lib/nfg_ui/components/traits/typeface.rb
nfg_ui-0.10.9 lib/nfg_ui/components/traits/typeface.rb
nfg_ui-0.10.8.2 lib/nfg_ui/components/traits/typeface.rb
nfg_ui-0.10.8.1 lib/nfg_ui/components/traits/typeface.rb
nfg_ui-0.10.7 lib/nfg_ui/components/traits/typeface.rb