Class: UiHelpers::Icon
- Defined in:
- lib/ui_helpers/elements/icon.rb
Direct Known Subclasses
Button::OnlyIcon, Button::PrimaryIcon, Button::SecondaryIcon, LinkIcon
Constant Summary collapse
- ICONS =
{}
Instance Attribute Summary collapse
-
#h_offset ⇒ Object
Returns the value of attribute h_offset.
-
#height ⇒ Object
Returns the value of attribute height.
-
#name ⇒ Object
Returns the value of attribute name.
-
#v_offset ⇒ Object
Returns the value of attribute v_offset.
-
#width ⇒ Object
Returns the value of attribute width.
Attributes inherited from Element
Instance Method Summary collapse
Methods inherited from Element
#capture, #classes, #classes=, #initialize, #style=, #tag, #with_html_options
Constructor Details
This class inherits a constructor from UiHelpers::Element
Instance Attribute Details
#h_offset ⇒ Object
Returns the value of attribute h_offset.
4 5 6 |
# File 'lib/ui_helpers/elements/icon.rb', line 4 def h_offset @h_offset end |
#height ⇒ Object
Returns the value of attribute height.
4 5 6 |
# File 'lib/ui_helpers/elements/icon.rb', line 4 def height @height end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/ui_helpers/elements/icon.rb', line 4 def name @name end |
#v_offset ⇒ Object
Returns the value of attribute v_offset.
4 5 6 |
# File 'lib/ui_helpers/elements/icon.rb', line 4 def v_offset @v_offset end |
#width ⇒ Object
Returns the value of attribute width.
4 5 6 |
# File 'lib/ui_helpers/elements/icon.rb', line 4 def width @width end |
Instance Method Details
#background_style ⇒ Object
198 199 200 201 202 203 |
# File 'lib/ui_helpers/elements/icon.rb', line 198 def background_style offsets = [h_offset, v_offset] ICONS[name.to_s].gsub(/-?\d+(?=px)/) do |s| s.to_i + (offsets.delete_at(0)||0) end end |
#height_style ⇒ Object
194 195 196 |
# File 'lib/ui_helpers/elements/icon.rb', line 194 def height_style "height: #{height||16 + ((v_offset||0)*1.5).round}px;" end |
#width_style ⇒ Object
190 191 192 |
# File 'lib/ui_helpers/elements/icon.rb', line 190 def width_style "width: #{width||16 + ((h_offset||0)*1.5).round}px;" end |