Module: Playbook::JustifyContent

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

Constant Summary collapse

JUSTIFY_CONTENT_VALUES =
%w[start end center spaceBetween spaceAround spaceEvenly].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/justify_content.rb', line 5

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

Instance Method Details

#justify_content_optionsObject



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

def justify_content_options
  { justify_content: "justify_content" }
end

#justify_content_propsObject



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

def justify_content_props
  value = justify_content
  return nil unless value

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

#justify_content_valuesObject



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

def justify_content_values
  JUSTIFY_CONTENT_VALUES
end