Class: NitroKit::Container

Inherits:
Component
  • Object
show all
Defined in:
app/components/nitro_kit/container.rb

Constant Summary collapse

SIZES =
%i[sm md lg xl].freeze

Constants inherited from Component

NitroKit::Component::ADDITIVE_DATA_ATTRIBUTES, NitroKit::Component::COMPONENT_OWNED_DATA_ATTRIBUTES, NitroKit::Component::FORBIDDEN_ATTRIBUTES, NitroKit::Component::RESERVED_DATA_ATTRIBUTES

Instance Method Summary collapse

Constructor Details

#initialize(size:, id: nil, html: {}, aria: {}, data: {}, desperately_need_a_class: nil) ⇒ Container

Returns a new instance of Container.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/components/nitro_kit/container.rb', line 7

def initialize(
  size:,
  id: nil,
  html: {},
  aria: {},
  data: {},
  desperately_need_a_class: nil
)
  size = validate_choice!(:size, size, SIZES)

  super(
    component: :container,
    attributes: { id: }.compact,
    html:,
    aria:,
    data:,
    size:,
    desperately_need_a_class:
  )
end

Instance Method Details

#view_templateObject



28
29
30
# File 'app/components/nitro_kit/container.rb', line 28

def view_template
  div(**root_attributes) { yield if block_given? }
end