Module: Playbook::TextAlign

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



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

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

Instance Method Details

#text_align_optionsObject

rubocop:enable Style/IfInsideElse



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

def text_align_options
  {
    text_align: "text_align",
  }
end

#text_align_propsObject

rubocop:disable Style/IfInsideElse



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

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

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

#text_align_valuesObject



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

def text_align_values
  %w[start end left right center justify justify-all match-parent]
end