Module: Playbook::GridAutoFlow

Included in:
KitBase
Defined in:
lib/playbook/grid_auto_flow.rb

Constant Summary collapse

GRID_AUTO_FLOW_VALUES =
%w[row column dense rowDense columnDense].freeze
SCREEN_SIZES =
%w[xs sm md lg xl].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
# File 'lib/playbook/grid_auto_flow.rb', line 5

def self.included(base)
  base.prop :grid_auto_flow
end

Instance Method Details

#grid_auto_flow_optionsObject



28
29
30
# File 'lib/playbook/grid_auto_flow.rb', line 28

def grid_auto_flow_options
  { grid_auto_flow: "grid_auto_flow" }
end

#grid_auto_flow_propsObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/playbook/grid_auto_flow.rb', line 12

def grid_auto_flow_props
  value = grid_auto_flow
  return nil unless value

  if value.is_a?(::Hash)
    css = +""
    css << "grid_auto_flow_#{value[:default].underscore} " if value.key?(:default) && GRID_AUTO_FLOW_VALUES.include?(value[:default])
    value.each do |media_size, flow_value|
      css << "grid_auto_flow_#{media_size}_#{flow_value.underscore} " if SCREEN_SIZES.include?(media_size.to_s) && GRID_AUTO_FLOW_VALUES.include?(flow_value)
    end
    css.strip unless css.empty?
  elsif GRID_AUTO_FLOW_VALUES.include?(value)
    "grid_auto_flow_#{value.underscore}"
  end
end

#grid_auto_flow_valuesObject



32
33
34
# File 'lib/playbook/grid_auto_flow.rb', line 32

def grid_auto_flow_values
  GRID_AUTO_FLOW_VALUES
end