Class: Optics::Icon::Component
Constant Summary
collapse
- SIZES =
%w[normal large x-large].freeze
- WEIGHTS =
%w[light normal semi-bold bold].freeze
- EMPHASES =
%w[low normal high].freeze
Instance Method Summary
collapse
accepts, #class_for, #class_names, #class_names_for, #container_class, #data_for, #data_method, #data_target, #data_values, #identifier, inherited, #initialize, requires
Instance Method Details
#call ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'app/components/optics/icon/component.rb', line 18
def call
content_tag(
:span,
class: classes,
'aria-label': title,
title:,
data:,
**@attributes.except(:class)
) do
name
end
end
|
#classes ⇒ Object
31
32
33
34
35
36
37
38
39
40
|
# File 'app/components/optics/icon/component.rb', line 31
def classes
class_names(
'material-symbols-outlined',
@attributes[:class],
size_class,
weight_class,
emphasis_class,
'icon--filled': filled
).join(' ')
end
|
#emphasis_class ⇒ Object
54
55
56
57
58
|
# File 'app/components/optics/icon/component.rb', line 54
def emphasis_class
return if emphasis == 'normal'
"icon--#{emphasis}-emphasis"
end
|
#size_class ⇒ Object
42
43
44
45
46
|
# File 'app/components/optics/icon/component.rb', line 42
def size_class
return if size == 'normal'
"icon--#{size}"
end
|
#weight_class ⇒ Object
48
49
50
51
52
|
# File 'app/components/optics/icon/component.rb', line 48
def weight_class
return if weight == 'normal'
"icon--weight-#{weight}"
end
|