class UiBibz::Ui::Core::Icons::Glyph
Create a glyph
This element is an extend of UiBibz::Ui::Core::Component
.
Attributes¶ ↑
-
content
- Content of element -
options
- Options of element -
html_options
- Html Options of element
Options¶ ↑
You can add HTML attributes using the html_options
. You can pass arguments in options attribute:
-
name
- String -
size
- Integer -
type
- Symbol -
text
- String -
status
- Symbol (:secondary
,:primary
,:info
,:warning
,:danger
)
Signatures¶ ↑
UiBibz::Ui::Core::Icons::Glyph.new content = nil, options = nil, html_options = nil, &block UiBibz::Ui::Core::Icons::Glyph.new(options = nil, html_options = nil) do content end UiBibz::Ui::Core::Icons::Glyph.new content = {} UiBibz::Ui::Core::Icons::Glyph.new content, options = {}, html_options = {}
Exemples¶ ↑
UiBibz::Ui::Core::Icons::Glyph.new('eye').render UiBibz::Ui::Core::Icons::Glyph.new() do name end.render UiBibz::Ui::Core::Icons::Glyph.new('eye', { size: 3, type: 'fw' }).render UiBibz::Ui::Core::Icons::Glyph.new({ name: 'eye', size: 3, type: 'fw' }).render
Helper¶ ↑
glyph(options = {}) glyph(name, options = {}, html_options = {}) glyph(options = {}, html_options = {}) do name end
Public Instance Methods
pre_render()
click to toggle source
Render html tag
# File lib/ui_bibz/ui/core/icons/glyph.rb, line 63 def pre_render [content_tag(:i, '', html_options), label].compact.join(' ').html_safe end
Private Instance Methods
classes()
click to toggle source
# File lib/ui_bibz/ui/core/icons/glyph.rb, line 78 def classes cls = ['glyph', style, "fa-#{content}"] # , "fa-fw"] cls << "fa-#{size}x" unless size.nil? cls << "fa-rotate-#{rotate}" unless rotate.nil? cls << "fa-flip-#{flip}" unless flip.nil? cls << 'fa-inverse' unless inverse.nil? cls << "fa-stack-#{stack}x" unless stack.nil? cls << "fa-#{type}" unless type.nil? cls end
component_html_classes()
click to toggle source
# File lib/ui_bibz/ui/core/icons/glyph.rb, line 69 def component_html_classes join_classes(classes) end
component_html_data()
click to toggle source
Calls superclass method
UiBibz::Ui::Core::Component#component_html_data
# File lib/ui_bibz/ui/core/icons/glyph.rb, line 73 def component_html_data super transform end
content()
click to toggle source
# File lib/ui_bibz/ui/core/icons/glyph.rb, line 130 def content @options[:name] || @content end
flip()
click to toggle source
# File lib/ui_bibz/ui/core/icons/glyph.rb, line 118 def flip @options[:flip] end
inverse()
click to toggle source
# File lib/ui_bibz/ui/core/icons/glyph.rb, line 114 def inverse @options[:inverse] end
label()
click to toggle source
# File lib/ui_bibz/ui/core/icons/glyph.rb, line 142 def label if options[:text] == false content_tag :span, options[:label], class: 'visually-hidden' else options[:label] end end
match_style()
click to toggle source
# File lib/ui_bibz/ui/core/icons/glyph.rb, line 138 def match_style { solid: 'fas', regular: 'far', light: 'fal', brands: 'fab' } end
rotate()
click to toggle source
# File lib/ui_bibz/ui/core/icons/glyph.rb, line 110 def rotate @options[:rotate] end
size()
click to toggle source
# File lib/ui_bibz/ui/core/icons/glyph.rb, line 89 def size case @options[:size] when :sm 1 when :md 3 when :lg 5 else @options[:size] end end
stack()
click to toggle source
# File lib/ui_bibz/ui/core/icons/glyph.rb, line 106 def stack @options[:stack] end
status()
click to toggle source
# File lib/ui_bibz/ui/core/icons/glyph.rb, line 134 def status "glyph-#{@options[:status]}" unless @options[:status].nil? end
style()
click to toggle source
# File lib/ui_bibz/ui/core/icons/glyph.rb, line 102 def style match_style[@options[:style] || :solid] end
transform()
click to toggle source
# File lib/ui_bibz/ui/core/icons/glyph.rb, line 126 def transform add_html_data 'fa_transform', value: options[:transform] if options[:transform] end
type()
click to toggle source
# File lib/ui_bibz/ui/core/icons/glyph.rb, line 122 def type @options[:type] end