Class: FA::Layer

Inherits:
Base
  • Object
show all
Defined in:
lib/fa/layer.rb

Overview

FontAwesome 5 (Pro) Helper for generating layered icons and spans

Since:

  • 0.1.0

Direct Known Subclasses

Build

Constant Summary

Constants inherited from Base

Base::MODES, Base::STYLES

Instance Method Summary collapse

Methods inherited from Base

p, #safe

Constructor Details

#initialize(icons = [], title: nil, grow: 0, css: '') ⇒ Layer

Creates a new Layer instance

Add icons or spans to the stack from bottom to top

Note: scaling counters does not work well with :grow, so should use the older “fa-3x” syntax in :css instead.

Parameters:

  • icons (Array) (defaults to: [])

    The complete hash configurations for each icon/span

  • title (String) (defaults to: nil)

    The tooltip text

  • grow (Integer) (defaults to: 0)

    An additional global scaling factor added in

  • css (String) (defaults to: '')

    Additional arbitrary CSS classes, space-delimited

Since:

  • 0.1.0



17
18
19
20
21
22
# File 'lib/fa/layer.rb', line 17

def initialize(icons = [], title: nil, grow: 0, css: '')
  @icons = icons
  @title = title
  @grow = grow
  @css = css
end

Instance Method Details

#rawObject

Outputs the formatted stack of icons and spans directly.

Since:

  • 0.1.0



25
26
27
28
29
30
31
32
# File 'lib/fa/layer.rb', line 25

def raw
  @icons.each do |i|
    i[:options] = combine_options(i, combine_grows(i, @grow))
    i[:options][:title] = @title
  end

  build { parse_all(@icons).join }
end