Class: Components::Icon

Inherits:
Base
  • Object
show all
Defined in:
app/components/icon.rb

Instance Method Summary collapse

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