Class: Components::Icon
- Inherits:
-
Base
- Object
- Base
- Components::Icon
- Defined in:
- app/components/icon.rb
Instance Method Summary collapse
- #before_template ⇒ Object
-
#initialize(icon:, id: nil, label: nil, effect: nil, role: "img") ⇒ Icon
constructor
A new instance of Icon.
- #view_template ⇒ Object
Constructor Details
#initialize(icon:, id: nil, label: nil, effect: nil, role: "img") ⇒ Icon
Returns a new instance of Icon.
4 5 6 7 8 9 10 |
# File 'app/components/icon.rb', line 4 def initialize(icon:, id: nil, label: nil, effect: nil, role: "img") @icon = icon @effect = effect @id = id @label = label @role = role end |
Instance Method Details
#before_template ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'app/components/icon.rb', line 12 def before_template prefix = "bi" icon = @icon if icon.starts_with? "ra-" prefix = "ra" icon = @icon.gsub("ra-", "") end @classes = [prefix, "#{prefix}-#{icon}", @effect].compact.join(" ") end |
#view_template ⇒ Object
22 23 24 |
# File 'app/components/icon.rb', line 22 def view_template i class: @classes, role: @role, title: @label, id: @id end |