Module: Playbook::FlexWrap

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

Constant Summary collapse

FLEX_WRAP_VALUES =
%w[wrap nowrap wrapReverse].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/flex_wrap.rb', line 5

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

Instance Method Details

#flex_wrap_optionsObject



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

def flex_wrap_options
  { flex_wrap: "flex_wrap" }
end

#flex_wrap_propsObject



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

def flex_wrap_props
  value = flex_wrap
  return nil unless value

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

#flex_wrap_valuesObject



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

def flex_wrap_values
  FLEX_WRAP_VALUES
end