Class: EasyUi::ButtonComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- EasyUi::ButtonComponent
- Defined in:
- app/components/easy_ui/button_component.rb
Instance Method Summary collapse
- #classes ⇒ Object
-
#initialize(name = nil, options = nil, html_options = nil, &block) ⇒ ButtonComponent
constructor
A new instance of ButtonComponent.
Constructor Details
#initialize(name = nil, options = nil, html_options = nil, &block) ⇒ ButtonComponent
Returns a new instance of ButtonComponent.
3 4 5 6 7 8 9 |
# File 'app/components/easy_ui/button_component.rb', line 3 def initialize(name = nil, = nil, = nil, &block) @name = name @options = @html_options = || {} @variant = @html_options.delete(:variant) || :primary end |
Instance Method Details
#classes ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'app/components/easy_ui/button_component.rb', line 11 def classes base = "px-4 py-2 rounded-xl font-medium transition" variants = { primary: "bg-blue-500 text-white hover:bg-blue-700", secondary: "bg-slate-200 text-slate-700 hover:bg-slate-400", danger: "bg-red-500 text-white hover:bg-red-700" } "#{base} #{variants[@variant.to_sym]}" end |