Module: Playbook::JustifyItems

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

Constant Summary collapse

JUSTIFY_ITEMS_VALUES =
%w[start end center stretch].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_items.rb', line 5

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

Instance Method Details

#justify_items_optionsObject



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

def justify_items_options
  { justify_items: "justify_items" }
end

#justify_items_propsObject



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

def justify_items_props
  value = justify_items
  return nil unless value

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

#justify_items_valuesObject



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

def justify_items_values
  JUSTIFY_ITEMS_VALUES
end