Class: Ui::Toggle::Component

Inherits:
BaseComponent
  • Object
show all
Defined in:
lib/uikit_rails/templates/components/toggle/component.rb

Overview

Pressable toggle button.

Constant Summary collapse

VARIANTS =
%i[default outline].freeze
SIZES =
%i[sm md lg].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(variant: :default, size: :md, pressed: false, **html_attrs) ⇒ Component

Returns a new instance of Component.



12
13
14
15
16
17
18
# File 'lib/uikit_rails/templates/components/toggle/component.rb', line 12

def initialize(variant: :default, size: :md, pressed: false, **html_attrs)
  @variant = variant.to_sym
  @size = size.to_sym
  @pressed = pressed
  @html_attrs = html_attrs
  super()
end

Instance Attribute Details

#html_attrsObject (readonly)

Returns the value of attribute html_attrs.



10
11
12
# File 'lib/uikit_rails/templates/components/toggle/component.rb', line 10

def html_attrs
  @html_attrs
end

#pressedObject (readonly)

Returns the value of attribute pressed.



10
11
12
# File 'lib/uikit_rails/templates/components/toggle/component.rb', line 10

def pressed
  @pressed
end

#sizeObject (readonly)

Returns the value of attribute size.



10
11
12
# File 'lib/uikit_rails/templates/components/toggle/component.rb', line 10

def size
  @size
end

#variantObject (readonly)

Returns the value of attribute variant.



10
11
12
# File 'lib/uikit_rails/templates/components/toggle/component.rb', line 10

def variant
  @variant
end

Instance Method Details

#callObject



20
21
22
# File 'lib/uikit_rails/templates/components/toggle/component.rb', line 20

def call
  (:button, content, **computed_attrs)
end