Class: NitroKit::Button
- Defined in:
- app/components/nitro_kit/button.rb
Constant Summary collapse
- VARIANTS =
%i[default primary destructive ghost]
Instance Attribute Summary collapse
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#icon ⇒ Object
readonly
Returns the value of attribute icon.
-
#icon_right ⇒ Object
readonly
Returns the value of attribute icon_right.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#variant ⇒ Object
readonly
Returns the value of attribute variant.
Attributes inherited from Component
Instance Method Summary collapse
-
#initialize(text = nil, href: nil, variant: :default, size: :md, icon: nil, icon_right: nil, **attrs) ⇒ Button
constructor
A new instance of Button.
- #view_template(&block) ⇒ Object
Methods inherited from Component
Constructor Details
#initialize(text = nil, href: nil, variant: :default, size: :md, icon: nil, icon_right: nil, **attrs) ⇒ Button
Returns a new instance of Button.
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 |
# File 'app/components/nitro_kit/button.rb', line 7 def initialize( text = nil, href: nil, variant: :default, size: :md, icon: nil, icon_right: nil, **attrs ) @text = text @href = href @icon = icon @icon_right = icon_right @size = size @variant = variant super( attrs, class: [ base_class, variant_class, size_class ] ) end |
Instance Attribute Details
#href ⇒ Object (readonly)
Returns the value of attribute href.
33 34 35 |
# File 'app/components/nitro_kit/button.rb', line 33 def href @href end |
#icon ⇒ Object (readonly)
Returns the value of attribute icon.
33 34 35 |
# File 'app/components/nitro_kit/button.rb', line 33 def icon @icon end |
#icon_right ⇒ Object (readonly)
Returns the value of attribute icon_right.
33 34 35 |
# File 'app/components/nitro_kit/button.rb', line 33 def icon_right @icon_right end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
33 34 35 |
# File 'app/components/nitro_kit/button.rb', line 33 def size @size end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
33 34 35 |
# File 'app/components/nitro_kit/button.rb', line 33 def text @text end |
#variant ⇒ Object (readonly)
Returns the value of attribute variant.
33 34 35 |
# File 'app/components/nitro_kit/button.rb', line 33 def variant @variant end |
Instance Method Details
#view_template(&block) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/components/nitro_kit/button.rb', line 42 def view_template(&block) if href a(href:, **attrs) do contents(&block) end else (type: :button, **attrs) do contents(&block) end end end |