Module: Playbook::FlexDirection

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
# File 'lib/playbook/flex_direction.rb', line 5

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

Instance Method Details

#flex_direction_optionsObject

rubocop:enable Style/IfInsideElse



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

def flex_direction_options
  {
    flex_direction: "flex_direction",
  }
end

#flex_direction_propsObject

rubocop:disable Style/IfInsideElse



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

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

  selected_props.map do |k|
    flex_direction_value = send(k)
    if flex_direction_value.is_a?(Hash)
      flex_direction_value.map do |media_size, flex_value|
        "flex_direction_#{media_size}_#{flex_value.underscore}" if flex_direction_values.include? flex_value
      end
    else
      "flex_direction_#{flex_direction_value.underscore}" if flex_direction_values.include? flex_direction_value
    end
  end.compact.join(" ")
end

#flex_direction_valuesObject



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

def flex_direction_values
  %w[row column rowReverse columnReverse]
end