Class: Panda::Core::UI::Button
- Defined in:
- app/components/panda/core/UI/button.rb
Overview
Modern ViewComponent-based button component with type-safe props.
Supports both
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#disabled ⇒ Object
readonly
Returns the value of attribute disabled.
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#variant ⇒ Object
readonly
Returns the value of attribute variant.
Instance Method Summary collapse
- #default_attrs ⇒ Object
-
#initialize(text: "", variant: :default, size: :medium, disabled: false, type: "button", href: nil, **attrs) ⇒ Button
constructor
A new instance of Button.
Constructor Details
#initialize(text: "", variant: :default, size: :medium, disabled: false, type: "button", href: nil, **attrs) ⇒ Button
Returns a new instance of Button.
37 38 39 40 41 42 43 44 45 |
# File 'app/components/panda/core/UI/button.rb', line 37 def initialize(text: "", variant: :default, size: :medium, disabled: false, type: "button", href: nil, **attrs) @text = text @variant = variant @size = size @disabled = disabled @type = type @href = href super(**attrs) end |
Instance Attribute Details
#disabled ⇒ Object (readonly)
Returns the value of attribute disabled.
47 48 49 |
# File 'app/components/panda/core/UI/button.rb', line 47 def disabled @disabled end |
#href ⇒ Object (readonly)
Returns the value of attribute href.
47 48 49 |
# File 'app/components/panda/core/UI/button.rb', line 47 def href @href end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
47 48 49 |
# File 'app/components/panda/core/UI/button.rb', line 47 def size @size end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
47 48 49 |
# File 'app/components/panda/core/UI/button.rb', line 47 def text @text end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
47 48 49 |
# File 'app/components/panda/core/UI/button.rb', line 47 def type @type end |
#variant ⇒ Object (readonly)
Returns the value of attribute variant.
47 48 49 |
# File 'app/components/panda/core/UI/button.rb', line 47 def variant @variant end |
Instance Method Details
#default_attrs ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/components/panda/core/UI/button.rb', line 49 def default_attrs base = { class: } if @href base[:href] = @href else base[:type] = @type base[:disabled] = @disabled if @disabled end base end |