class UiBibz::Ui::Core::Navigations::Link

Create a Link

This element is an extend of UiBibz::Ui::Core::Component.

You can add HTML attributes using the html_options. You can pass arguments in options attribute:

UiBibz::Ui::Core::Navigations::Link.new(content, options = nil, html_options = nil)

UiBibz::Ui::Core::Navigations::Link.new(options = nil, html_options = nil) do
  content
end
UiBibz::Ui::Core::Navigations::Link.new('Home', { glyph: 'home', url: '#url', state: :active },{ class: 'test' }).render

UiBibz::Ui::Core::Navigations::Link.new({ url: '#url', glyph: { name: 'eye', size: 3}}, { class: 'test' }) do
  'Home'
end.render

Public Instance Methods

pre_render() click to toggle source

Render html tag

# File lib/ui_bibz/ui/core/navigations/link.rb, line 46
def pre_render
  link_to glyph_and_content_html, options[:url] || "##{options[:collapse]}", html_options
end

Private Instance Methods

collapse() click to toggle source
# File lib/ui_bibz/ui/core/navigations/link.rb, line 58
def collapse
  {
    role: 'button',
    data: { 'bs-toggle': :collapse },
    aria: {
      controls: options[:collapse],
      expanded: options[:active_collapse].nil? ? false : options[:active_collapse]
    }
  }
end
component_html_options() click to toggle source
# File lib/ui_bibz/ui/core/navigations/link.rb, line 52
def component_html_options
  opts = super
  opts = opts.merge(collapse) unless options[:collapse].nil?
  opts
end
text() click to toggle source
# File lib/ui_bibz/ui/core/navigations/link.rb, line 69
def text
  @options[:text].nil? ? true : @options[:text]
end