Class: JetUi::Btn::Component
- Inherits:
-
JetUi::BaseComponent
- Object
- ViewComponent::Base
- JetUi::BaseComponent
- JetUi::Btn::Component
- Defined in:
- app/components/jet_ui/btn/component.rb
Constant Summary collapse
- SIZES =
%i[xs sm md lg icon_xs icon_sm icon_md icon_lg].freeze
- DEFAULT_SIZE =
:md- VARIANTS =
%i[default outline secondary danger ghost link].freeze
- DEFAULT_VARIANT =
:default
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(variant: DEFAULT_VARIANT, url: nil, size: DEFAULT_SIZE, rounded: false, block: false, circle: false, method: nil, **options) ⇒ Component
constructor
A new instance of Component.
Constructor Details
#initialize(variant: DEFAULT_VARIANT, url: nil, size: DEFAULT_SIZE, rounded: false, block: false, circle: false, method: nil, **options) ⇒ Component
Returns a new instance of Component.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/components/jet_ui/btn/component.rb', line 12 def initialize(variant: DEFAULT_VARIANT, url: nil, size: DEFAULT_SIZE, rounded: false, block: false, circle: false, method: nil, **) @variant = VARIANTS.include?(variant) ? variant : DEFAULT_VARIANT @url = url @size = SIZES.include?(size.to_sym) ? size.to_sym : DEFAULT_SIZE @rounded = rounded @block = block @circle = circle @method = method @options = end |
Instance Method Details
#call ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/components/jet_ui/btn/component.rb', line 24 def call if @url && @method @url, class: classes, method: @method, **@options do content end elsif @url link_to content, @url, class: classes, **@options else content, type: 'button', class: classes, **@options end end |