Module: Playbook::JustifySelf

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

Constant Summary collapse

JUSTIFY_SELF_VALUES =
%w[auto 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_self.rb', line 5

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

Instance Method Details

#justify_self_optionsObject



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

def justify_self_options
  { justify_self: "justify_self" }
end

#justify_self_propsObject



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

def justify_self_props
  value = justify_self
  return nil unless value

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

#justify_self_valuesObject



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

def justify_self_values
  JUSTIFY_SELF_VALUES
end