Class: Protos::Swap

Inherits:
Component show all
Defined in:
lib/protos/swap.rb,
lib/protos/swap/on.rb,
lib/protos/swap/off.rb

Defined Under Namespace

Classes: Off, On

Instance Method Summary collapse

Methods inherited from Component

#initialize

Constructor Details

This class inherits a constructor from Protos::Component

Instance Method Details

#offObject



24
# File 'lib/protos/swap.rb', line 24

def off(...) = render Off.new(...)

#onObject



22
# File 'lib/protos/swap.rb', line 22

def on(...) = render On.new(...)

#view_templateObject

DOCS: The swap component is a checkbox that can be toggled on and off to display different content. daisyui.com/components/swap/



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/protos/swap.rb', line 9

def view_template
  label(**attrs) do
    input(
      type: :checkbox,
      class: css[:input],
      autocomplete: :off,
      form: "",
      aria_label: "swap"
    )
    yield if block_given?
  end
end