Module: Playbook::AlignSelf

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



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

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

Instance Method Details

#align_self_optionsObject



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

def align_self_options
  {
    align_self: "align_self",
  }
end

#align_self_propsObject

rubocop:disable Style/IfInsideElse



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

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

  selected_props.map do |k|
    align_self_value = send(k)
    if align_self_value.is_a?(Hash)
      align_self_value.map do |media_size, align_value|
        "align_self_#{media_size}_#{align_value}" if align_self_values.include? align_value
      end
    else
      "align_self_#{align_self_value}" if align_self_values.include? align_self_value
    end
  end.compact.join(" ")
  # rubocop:enable Style/IfInsideElse
end

#align_self_valuesObject



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

def align_self_values
  %w[auto start end center stretch baseline]
end