Class: Arara::ButtonComponent
- Inherits:
-
ActionView::Component::Base
- Object
- ActionView::Component::Base
- Arara::ButtonComponent
- Includes:
- BaseComponent
- Defined in:
- app/components/arara/button_component.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
private.
-
#icon ⇒ Object
readonly
private.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #default_data_controller ⇒ Object
- #has_icon? ⇒ Boolean
- #html_class ⇒ Object
- #html_content ⇒ Object
- #html_options ⇒ Object
-
#initialize(variant: "text", content: "Label", dense: false, icon: nil, type: nil, name: nil, value: nil, tag: "button", **kw) ⇒ ButtonComponent
constructor
A new instance of ButtonComponent.
Methods included from BaseComponent
#default_html_class, #default_html_tag, #html_data, #html_tag, included
Constructor Details
#initialize(variant: "text", content: "Label", dense: false, icon: nil, type: nil, name: nil, value: nil, tag: "button", **kw) ⇒ ButtonComponent
Returns a new instance of ButtonComponent.
6 7 8 9 10 11 12 13 14 |
# File 'app/components/arara/button_component.rb', line 6 def initialize(variant: "text", content: "Label", dense: false, icon: nil, type: nil, name: nil, value: nil, tag: "button", **kw) @dense = dense @icon = icon @html_class = html_class @type = type @name = name @value = value super(tag: tag, variant: variant, content: content, **kw) end |
Instance Attribute Details
#data ⇒ Object (readonly)
private
17 18 19 |
# File 'app/components/arara/button_component.rb', line 17 def data @data end |
#icon ⇒ Object (readonly)
private
17 18 19 |
# File 'app/components/arara/button_component.rb', line 17 def icon @icon end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'app/components/arara/button_component.rb', line 4 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'app/components/arara/button_component.rb', line 4 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
4 5 6 |
# File 'app/components/arara/button_component.rb', line 4 def value @value end |
Instance Method Details
#default_data_controller ⇒ Object
33 34 35 |
# File 'app/components/arara/button_component.rb', line 33 def default_data_controller "mdc-ripple" end |
#has_icon? ⇒ Boolean
29 30 31 |
# File 'app/components/arara/button_component.rb', line 29 def has_icon? @icon.present? end |
#html_class ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'app/components/arara/button_component.rb', line 19 def html_class klass = ["mdc-button"] klass.push("mdc-button--dense") if @dense klass.push("mdc-button--raised") if @user_variant == "raised" klass.push("mdc-button--unelevated") if @user_variant == "unelevated" klass.push("mdc-button--outlined") if @user_variant == "outlined" klass.push("#{@html_class}") if @html_class klass end |
#html_content ⇒ Object
44 45 46 47 48 |
# File 'app/components/arara/button_component.rb', line 44 def html_content return content if content return value if value user_content end |
#html_options ⇒ Object
37 38 39 40 41 42 |
# File 'app/components/arara/button_component.rb', line 37 def opts = super opts.merge!( class: html_class, data: html_data, type: type, name: name, value: value ) end |