-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathicon_component.rb
More file actions
36 lines (30 loc) · 900 Bytes
/
icon_component.rb
File metadata and controls
36 lines (30 loc) · 900 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# frozen_string_literal: true
class PracticalViews::IconComponent < PracticalViews::BaseComponent
include ActiveModel::Serializers::JSON
attr_accessor :name, :family, :variant, :fixed_width, :label, :options
def attributes=(hash)
hash.each do |key, value|
public_send("#{key}=", value)
end
end
def attributes
{ "name" => nil, "family" => nil, "variant" => nil, "fixed_width" => nil, "label" => nil, "options" => nil }
end
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
def call
tag.wa_icon(**mix({
"name": name,
"family": family,
"variant": variant,
"fixed-width": fixed_width,
"label": label
}, options))
end
end