Class: Practical::Views::IconComponent

Inherits:
BaseComponent
  • Object
show all
Includes:
ActiveModel::Serializers::JSON
Defined in:
app/components/practical/views/icon_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ElementHelper

#grab, #mix

Constructor Details

#initialize(name:, family:, variant: nil, fixed_width: true, label: nil, options: {}) ⇒ IconComponent

Returns a new instance of IconComponent.



18
19
20
21
22
23
24
25
# File 'app/components/practical/views/icon_component.rb', line 18

def initialize(name:, family:, variant: nil, fixed_width: true, label: nil, options: {})
  self.name = name
  self.family = family
  self.variant = variant
  self.fixed_width = fixed_width
  self.label = label
  self.options = options
end

Instance Attribute Details

#familyObject

Returns the value of attribute family.



6
7
8
# File 'app/components/practical/views/icon_component.rb', line 6

def family
  @family
end

#fixed_widthObject

Returns the value of attribute fixed_width.



6
7
8
# File 'app/components/practical/views/icon_component.rb', line 6

def fixed_width
  @fixed_width
end

#labelObject

Returns the value of attribute label.



6
7
8
# File 'app/components/practical/views/icon_component.rb', line 6

def label
  @label
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'app/components/practical/views/icon_component.rb', line 6

def name
  @name
end

#optionsObject

Returns the value of attribute options.



6
7
8
# File 'app/components/practical/views/icon_component.rb', line 6

def options
  @options
end

#variantObject

Returns the value of attribute variant.



6
7
8
# File 'app/components/practical/views/icon_component.rb', line 6

def variant
  @variant
end

Instance Method Details

#attributesObject



14
15
16
# File 'app/components/practical/views/icon_component.rb', line 14

def attributes
  { "name" => nil, "family" => nil, "variant" => nil, "fixed_width" => nil, "label" => nil, "options" => nil }
end

#attributes=(hash) ⇒ Object



8
9
10
11
12
# File 'app/components/practical/views/icon_component.rb', line 8

def attributes=(hash)
  hash.each do |key, value|
    public_send("#{key}=", value)
  end
end

#callObject



27
28
29
30
31
32
33
34
35
# File 'app/components/practical/views/icon_component.rb', line 27

def call
  tag.wa_icon(**mix({
    "name": name,
    "family": family,
    "variant": variant,
    "fixed-width": fixed_width,
    "label": label
  }, options))
end