Class: Layout::Grid::ColumnComponent
- Inherits:
-
SparkComponents::Component
- Object
- SparkComponents::Component
- Layout::Grid::ColumnComponent
- Defined in:
- app/components/spark/layout/grid/column_component.rb
Constant Summary collapse
- SPAN_CLASSES =
(1..12).to_a
Instance Method Summary collapse
Instance Method Details
#before_render ⇒ Object
11 12 13 14 15 16 |
# File 'app/components/spark/layout/grid/column_component.rb', line 11 def before_render @span ||= parent.span if parent && parent.respond_to?(:span) data_attr span: span_name(span) || 0 data_attr offset: span_name(offset) add_class "fill-column" if @fill end |
#render ⇒ Object
18 19 20 |
# File 'app/components/spark/layout/grid/column_component.rb', line 18 def render content_tag(:div, @yield, tag_attrs) end |
#span_name(size) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/components/spark/layout/grid/column_component.rb', line 22 def span_name(size) if size.is_a? Integer SPAN_CLASSES[size - 1] elsif size.is_a? Float SPAN_CLASSES[(SPAN_CLASSES.size * size) - 1] else size = case size when :half then 2 when :third then 3 when :fourth then 4 when :sixth then 6 else return size end SPAN_CLASSES[(SPAN_CLASSES.size / size) - 1] end end |