Class: Layout::GridComponent
- Inherits:
-
SparkComponents::Component
- Object
- SparkComponents::Component
- Layout::GridComponent
- Defined in:
- app/components/spark/layout/grid_component.rb
Constant Summary collapse
- COLUMN =
[1,2,3,4,6,12].freeze
- GUTTER =
i[small base medium large xl].freeze
Instance Method Summary collapse
Instance Method Details
#after_init ⇒ Object
13 14 15 16 17 |
# File 'app/components/spark/layout/grid_component.rb', line 13 def after_init raise "Grids do not support both cols and span. Set `span` (default span for colums), or `cols` (the number of columns per row)" if span && cols @gutter ||= :base if gutter_match @span = 12 / @cols if @cols end |
#before_render ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'app/components/spark/layout/grid_component.rb', line 19 def before_render base_class "spark-grid" add_class(join_class("gutter-#{gutter}")) if gutter add_class(join_class("gutter-#{gutter}-match")) if gutter && gutter_match data_attr column_min: min add_class join_class("no-wrap") unless wrap end |
#render ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'app/components/spark/layout/grid_component.rb', line 28 def render content_tag(:div, tag_attrs) do concat content_tag(:div, class: join_class(:columns)) { columns.each { |column| concat column } } end end |