Class: Kanso::ButtonComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Kanso::ButtonComponent
- Includes:
- ClassCombinable
- Defined in:
- app/components/kanso/button_component.rb
Constant Summary collapse
- THEME_CLASSES =
{ primary: "bg-indigo-500 text-white hover:bg-indigo-600 active:bg-indigo-700", danger: "bg-red-600 text-white hover:bg-red-700 active:bg-red-800", default: "bg-white text-indigo-600 border border-indigo-600 focus:ring-indigo-500/50 hover:bg-indigo-50 hover:border-indigo-700 active:bg-indigo-700 active:text-white" }.freeze
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(theme: :default, tag: :button, url: nil, method: nil, **options) ⇒ ButtonComponent
constructor
A new instance of ButtonComponent.
Methods included from ClassCombinable
Constructor Details
#initialize(theme: :default, tag: :button, url: nil, method: nil, **options) ⇒ ButtonComponent
Returns a new instance of ButtonComponent.
13 14 15 16 17 18 19 |
# File 'app/components/kanso/button_component.rb', line 13 def initialize(theme: :default, tag: :button, url: nil, method: nil, **) @theme = theme @tag = tag @url = url @method = method @options = end |
Instance Method Details
#call ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'app/components/kanso/button_component.rb', line 21 def call if @url (@url, method: @method, **) do content end else content_tag(@tag, content, ) end end |