Class: Layout::GridComponent

Inherits:
SparkComponents::Component
  • Object
show all
Defined in:
app/components/spark/layout/grid_component.rb

Instance Method Summary collapse

Instance Method Details

#after_initObject



12
13
14
# File 'app/components/spark/layout/grid_component.rb', line 12

def after_init
  @span = 12 / @cols if @cols
end

#before_renderObject



16
17
18
19
20
21
22
23
# File 'app/components/spark/layout/grid_component.rb', line 16

def before_render
  add_class(join_class("gutter-#{gutter}")) if gutter
  add_class(join_class("gutter-#{gutter}-match")) if gutter && gutter_match
  data_attr column_min: min
  data_attr column_break: @break
  add_class join_class("no-wrap") unless wrap
  add_class join_class("reverse") if reverse
end

#renderObject



25
26
27
28
29
30
31
32
33
# File 'app/components/spark/layout/grid_component.rb', line 25

def render
  (:div, tag_attrs) do
    concat (:div, class: join_class("columns")) {
      columns.each { |column| 
        concat column 
      }
    }
  end
end