class UiHelpers::Button
Attributes
primary_icon[RW]
secondary_icon[RW]
text[RW]
title[RW]
value[RW]
Public Instance Methods
any_icons?()
click to toggle source
# File lib/ui_helpers/elements/button.rb, line 54 def any_icons? primary_icon || secondary_icon end
content(&block)
click to toggle source
# File lib/ui_helpers/elements/button.rb, line 58 def content(&block) capture do |buffer| if scope == "icon-only" buffer << OnlyIcon.new(@template, :name => primary_icon).tag(:span) elsif scope.include?("icon") && primary_icon buffer << PrimaryIcon.new(@template, :name => primary_icon).tag(:span) end buffer << Text.new(@template).tag(:span, text||" ", &block) if scope.include?("icon") && secondary_icon buffer << SecondaryIcon.new(@template, :name => secondary_icon).tag(:span) end end end
scope()
click to toggle source
# File lib/ui_helpers/elements/button.rb, line 36 def scope if text && any_icons? if primary_icon && secondary_icon "text-icons" # text + primary_icon + secondary_icon elsif primary_icon "text-icon-primary" # text + primary_icon elsif secondary_icon "text-icon-secondary" # text + secondary_icon end elsif text "text-only" # text only elsif primary_icon && secondary_icon "icons-only" # primary_icon + secondary_icon elsif any_icons? "icon-only" # just 1 icon end end