Class: FA::Build
Overview
FontAwesome 5 (Pro) Helper for piecewise building layered icons and spans
Constant Summary
Constants inherited from Base
FA::Base::MODES, FA::Base::STYLES
Class Method Summary collapse
-
.p(*args, &block) ⇒ Object
Shortcut for create and output safe.
Instance Method Summary collapse
-
#icon(icon, **options) ⇒ Object
Adds an icon to the stack using the same argument format.
-
#initialize(icons = {}, title: nil, grow: 0, css: '') {|_self| ... } ⇒ Build
constructor
Creates a new Layer instance.
-
#raw ⇒ Object
Outputs the formatted stack of icons and spans directly.
-
#span(type, text, **options) ⇒ Object
Adds a span to the stack using the same argument format.
Methods inherited from Base
Constructor Details
#initialize(icons = {}, title: nil, grow: 0, css: '') {|_self| ... } ⇒ Build
Creates a new Layer instance
Add icons or spans to the stack from bottom to top
This is a variand of FA::Layer, to allow for DSL building stacks
Note: scaling counters does not work well with :grow, so should use the older “fa-3x” syntax in :css instead.
19 20 21 22 23 |
# File 'lib/fa/build.rb', line 19 def initialize(icons = {}, title: nil, grow: 0, css: '') super @contents = '' yield(self) if block_given? end |
Class Method Details
.p(*args, &block) ⇒ Object
Shortcut for create and output safe
43 44 45 |
# File 'lib/fa/build.rb', line 43 def self.p(*args, &block) new(*args).instance_eval(&block).safe end |
Instance Method Details
#icon(icon, **options) ⇒ Object
Adds an icon to the stack using the same argument format.
31 32 33 34 |
# File 'lib/fa/build.rb', line 31 def icon(icon, **) @contents += FA::Icon.p(icon, ()) self end |
#raw ⇒ Object
Outputs the formatted stack of icons and spans directly.
26 27 28 |
# File 'lib/fa/build.rb', line 26 def raw build { @contents } end |