Class: Spark::Grid::Column

Inherits:
Component::Base show all
Defined in:
app/components/spark/grid/column.rb

Constant Summary collapse

SPAN_NAME =
{ half: 6, third: 4, fourth: 3, sixth: 2 }.freeze
SPAN =
[*(1..12), *SPAN_NAME.keys, :auto].freeze
OFFSET =
[*(1..11), *SPAN_NAME.keys].freeze

Instance Method Summary collapse

Methods inherited from Component::Base

#selector, #to_s, #unique_id

Constructor Details

#initializeColumn

Returns a new instance of Column.



14
15
16
17
18
# File 'app/components/spark/grid/column.rb', line 14

def initialize(*)
  super
  classname.base = "spark-grid-column"
  classname.add("expand-content") if @expand_content
end

Instance Method Details

#span_name(size) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'app/components/spark/grid/column.rb', line 20

def span_name(size)
  return if size.nil?
  if size.is_a? Integer
    SPAN[size - 1]
  elsif size.is_a? Float
    SPAN[(SPAN.size * size) - 1]
  elsif size = SPAN_NAME[size.to_sym]
    SPAN[(12 / size) - 1]
  end
end