Class: Brainzlab::Components::Button

Inherits:
Base
  • Object
show all
Defined in:
lib/brainzlab/components/button.rb

Constant Summary collapse

VARIANTS =
{
  primary: 'btn-primary',
  secondary: 'btn-secondary',
  ghost: 'btn-ghost',
  danger: 'btn-danger'
}.freeze
SIZES =
{
  sm: 'btn-sm',
  md: nil,
  lg: 'btn-lg'
}.freeze

Instance Method Summary collapse

Methods inherited from Base

#classes

Constructor Details

#initialize(variant: :primary, size: :md, lift: false, disabled: false, type: 'button', **attrs) ⇒ Button

Returns a new instance of Button.



19
20
21
22
23
24
25
26
# File 'lib/brainzlab/components/button.rb', line 19

def initialize(variant: :primary, size: :md, lift: false, disabled: false, type: 'button', **attrs)
  @variant = variant
  @size = size
  @lift = lift
  @disabled = disabled
  @type = type
  @attrs = attrs
end

Instance Method Details

#view_templateObject



28
29
30
31
32
33
34
35
36
# File 'lib/brainzlab/components/button.rb', line 28

def view_template(&)
  button(
    type: @type,
    class: button_classes,
    disabled: @disabled,
    **@attrs,
    &
  )
end