Sha256: 61fad70758e70294b37164ee7b7eea32f03ad02036b87bf10e277da603250cce
Contents?: true
Size: 1.66 KB
Versions: 2
Compression:
Stored size: 1.66 KB
Contents
module UiBibz::Ui # Create a NavLink # # This element is an extend of UiBibz::Ui::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: # * +status+ - State of élement with symbol value: # (+:active+) # * +url+ - String # * +badge+ - String # # ==== Signatures # # UiBibz::Ui::NavLink.new(content, options = nil, html_options = nil) # # UiBibz::Ui::NavLink.new(options = nil, html_options = nil) do # content # end # # ==== Examples # # UiBibz::Ui::NavLink.new(content, { badge: 15, url: '/', status: :active },{ class: 'test' }).render # # UiBibz::Ui::NavLink.new({glyph: { name: 'eye', size: 3 }, { class: 'test' }) do # 'Home' # end.render # class NavLink < Component def initialize content = nil, options = nil, html_options = nil, &block super end def render content_tag :li, content_htm, class_and_html_options.merge({ role: 'presentation' }) end private # content_htm and not content_html for haml bug def content_htm link_to @options[:url], link_html_options do concat glyph_and_content_html concat badge_html if @options[:badge] end end def link_html_options lho = @options[:link_html_options] || {} if @options[:nav_type] == :tabs lho.merge({ "aria-controls" => @options[:selector], "role" => "tab", "data-toggle" => "tab" }) else lho end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ui_bibz-1.0.0 | lib/ui_bibz/ui/nav/components/nav_link.rb |
ui_bibz-0.9.0 | lib/ui_bibz/ui/nav/components/nav_link.rb |