Class: NitroKit::Grid

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

Constant Summary collapse

COLUMNS =
(1..12).to_a.freeze
GAPS =
LayoutOptions::GAPS

Constants inherited from Component

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

Instance Method Summary collapse

Constructor Details

#initialize(cols:, gap: 4, id: nil, html: {}, aria: {}, data: {}, desperately_need_a_class: nil) ⇒ Grid

Returns a new instance of Grid.



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

def initialize(
  cols:,
  gap: 4,
  id: nil,
  html: {},
  aria: {},
  data: {},
  desperately_need_a_class: nil
)
  cols = ResponsiveValue.new(property: :cols, value: cols, allowed: COLUMNS).to_s
  gap = ResponsiveValue.new(property: :gap, value: gap, allowed: GAPS).to_s

  super(
    component: :grid,
    attributes: { id:, data: { cols:, gap: } }.compact,
    html:,
    aria:,
    data:,
    desperately_need_a_class:
  )
end

Instance Method Details

#view_templateObject



30
31
32
# File 'app/components/nitro_kit/grid.rb', line 30

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