Class: Arara::IconButtonComponent
- Inherits:
-
ActionView::Component::Base
- Object
- ActionView::Component::Base
- Arara::IconButtonComponent
show all
- Includes:
- BaseComponent
- Defined in:
- app/components/arara/icon_button_component.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#default_html_tag, #html_class, #html_content, #html_tag, included
Constructor Details
#initialize(title: nil, pressed: nil, **kw) ⇒ IconButtonComponent
Returns a new instance of IconButtonComponent.
8
9
10
11
12
|
# File 'app/components/arara/icon_button_component.rb', line 8
def initialize(title: nil, pressed: nil, **kw)
super(tag: "button", **kw)
@title = title
@pressed = pressed
end
|
Instance Attribute Details
#pressed ⇒ Object
Returns the value of attribute pressed.
6
7
8
|
# File 'app/components/arara/icon_button_component.rb', line 6
def pressed
@pressed
end
|
#title ⇒ Object
Returns the value of attribute title.
6
7
8
|
# File 'app/components/arara/icon_button_component.rb', line 6
def title
@title
end
|
Instance Method Details
#aria_data ⇒ Object
20
21
22
23
24
25
|
# File 'app/components/arara/icon_button_component.rb', line 20
def aria_data
data = {}
data[:label] = title if title
data[:pressed] = pressed unless pressed.nil?
data
end
|
#default_data_controller ⇒ Object
40
41
42
|
# File 'app/components/arara/icon_button_component.rb', line 40
def default_data_controller
"mdc-ripple"
end
|
#default_html_class ⇒ Object
14
15
16
17
18
|
# File 'app/components/arara/icon_button_component.rb', line 14
def default_html_class
klasses = ['mdc-icon-button']
klasses << ['mdc-icon-button--on'] if pressed
klasses
end
|
#html_data ⇒ Object
34
35
36
37
38
|
# File 'app/components/arara/icon_button_component.rb', line 34
def html_data
data = super
data.merge!('mdc-ripple-is-unbounded' => "")
data
end
|
#html_options ⇒ Object
27
28
29
30
31
32
|
# File 'app/components/arara/icon_button_component.rb', line 27
def html_options
opts = super
opts.merge!(title: title) if title
opts.merge!(aria: aria_data)
opts
end
|