Class: Protos::Collapse

Inherits:
Component
  • Object
show all
Defined in:
lib/protos/collapse.rb,
lib/protos/collapse/title.rb,
lib/protos/collapse/content.rb

Defined Under Namespace

Classes: Content, Title

Constant Summary collapse

Icons =
Types::Coercible::Symbol.enum(:arrow, :plus)
ICONS =
{
  arrow: "collapse-arrow",
  plus: "collapse-plus"
}.freeze
States =
Types::Coercible::Symbol.enum(:default, :open, :close)
STATES =
{
  default: "",
  open: "collapse-open",
  close: "collapse-close"
}.freeze

Instance Method Summary collapse

Methods inherited from Component

#initialize

Constructor Details

This class inherits a constructor from Protos::Component

Instance Method Details

#contentObject



55
# File 'lib/protos/collapse.rb', line 55

def content(...) = render Content.new(...)

#titleObject



53
# File 'lib/protos/collapse.rb', line 53

def title(*, **, &) = render Title.new(*, input_id: @input_name, **, &)

#view_templateObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/protos/collapse.rb', line 35

def view_template
  div(**attrs) do
    if @input_type
      input(
        type: @input_type,
        id: @input_name,
        name: @input_name,
        autocomplete: :off,
        aria_label: "Toggle accordion",
        # form: "" prevents the radio button from being submitted if its
        # within a form
        form: ""
      )
    end
    yield if block_given?
  end
end