Sha256: 140663f09eb65b6515cd496d16fac86b9bdc341c6c128bb9347ac133b8e827d0

Contents?: true

Size: 990 Bytes

Versions: 36

Compression:

Stored size: 990 Bytes

Contents

# frozen_string_literal: true

module GlyphExtension
  # Render glyph and content html
  def glyph_and_content_html(content_html = nil)
    options[:glyph] ? generate_glyph(content_html) : content_html || content
  end

  # Render glyph html
  def generate_glyph(content_html)
    glyph_options = if options[:glyph].is_a?(Hash)
                      options[:glyph]
                    elsif options[:glyph]
                      { name: options[:glyph] }
                    else
                      {}
                    end

    glyph_options = glyph_options.tap do |h|
      h[:text] = options[:text]
      h[:label] = options[:label] || content_html || content
      h[:shortcut] = options[:shortcut] unless options[:shortcut].nil?
    end

    # UiBibz::Utils::GlyphChanger.new(glyph_options[:name], glyph_options).render unless glyph_options[:name].nil?
    UiBibz::Ui::Core::Icons::Glyph.new(glyph_options[:name], glyph_options).render if glyph_options[:name].present?
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
ui_bibz-3.0.13 lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb
ui_bibz-3.0.12 lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb
ui_bibz-3.0.11 lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb
ui_bibz-3.0.10 lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb
ui_bibz-3.0.9 lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb
ui_bibz-3.0.8 lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb
ui_bibz-3.0.7 lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb
ui_bibz-3.0.6 lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb
ui_bibz-3.0.5 lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb
ui_bibz-3.0.4 lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb
ui_bibz-3.0.3 lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb
ui_bibz-3.0.2 lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb
ui_bibz-3.0.1 lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb
ui_bibz-3.0.0 lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb
ui_bibz-3.0.0.beta19 lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb
ui_bibz-3.0.0.beta18 lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb
ui_bibz-3.0.0.beta17 lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb
ui_bibz-3.0.0.beta16 lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb
ui_bibz-3.0.0.beta15 lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb
ui_bibz-3.0.0.beta14 lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb