Module: Playbook::JustifyContent

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

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

rubocop:enable Style/IfInsideElse



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

def justify_content_options
  {
    justify_content: "justify_content",
  }
end

#justify_content_propsObject

rubocop:disable Style/IfInsideElse



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

def justify_content_props
  selected_props = justify_content_options.keys.select { |sk| try(sk) }
  return nil unless selected_props.present?

  selected_props.map do |k|
    justify_content_value = send(k)
    if justify_content_value.is_a?(Hash)
      justify_content_value.map do |media_size, justify_value|
        "justify_content_#{media_size}_#{justify_value.underscore}" if justify_content_values.include? justify_value
      end
    else
      "justify_content_#{justify_content_value.underscore}" if justify_content_values.include? justify_content_value
    end
  end.compact.join(" ")
end

#justify_content_valuesObject



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

def justify_content_values
  %w[start end center spaceBetween spaceAround spaceEvenly]
end