Class: DesignSystem::Generic::GridComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/design_system/generic/grid_component.rb

Overview

Grid row rendered by ds_grid. Wraps columns whose widths map to the brand grid-column classes. The column widths are validated (total must not exceed 100%) when the component is built.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers::CssHelper

#css_class_options_merge

Methods included from BrandDerivable

#brand

Constructor Details

#initialize(grid:, **options) ⇒ GridComponent

Returns a new instance of GridComponent.



7
8
9
10
11
12
# File 'app/components/design_system/generic/grid_component.rb', line 7

def initialize(grid:, **options)
  super()
  @grid = grid
  @options = options
  @grid.validate_total_width!
end

Instance Attribute Details

#gridObject (readonly)

Returns the value of attribute grid.



14
15
16
# File 'app/components/design_system/generic/grid_component.rb', line 14

def grid
  @grid
end

#optionsObject (readonly)

Returns the value of attribute options.



14
15
16
# File 'app/components/design_system/generic/grid_component.rb', line 14

def options
  @options
end

Instance Method Details

#column_options(column) ⇒ Object



20
21
22
# File 'app/components/design_system/generic/grid_component.rb', line 20

def column_options(column)
  css_class_options_merge(column[:options].dup, [grid_class(column[:width])])
end

#row_optionsObject



16
17
18
# File 'app/components/design_system/generic/grid_component.rb', line 16

def row_options
  css_class_options_merge(options, ["#{brand}-grid-row"])
end