Module: Playbook::ZIndex

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



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

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

Instance Method Details

#screen_size_valuesObject



19
20
21
# File 'lib/playbook/z_index.rb', line 19

def screen_size_values
  %w[xs sm md lg xl]
end

#z_index_optionsObject



13
14
15
16
17
# File 'lib/playbook/z_index.rb', line 13

def z_index_options
  {
    z_index: "z-index",
  }
end

#z_index_propsObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/playbook/z_index.rb', line 23

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

  responsive = selected_props.present? && try(:z_index).is_a?(::Hash)
  css = ""
  if responsive
    z_index_value = send(:z_index)
    z_index_value.each do |key, value|
      css += "z_index_#{key}_#{value} " if screen_size_values.include?(key.to_s) && z_index_values.include?(value.to_s)
    end
  else
    selected_props.each do |k|
      z_index_value = send(k)
      css += "z_index_#{z_index_value} " if z_index_values.include? z_index_value
    end
  end

  css unless css.blank?
end

#z_index_valuesObject



9
10
11
# File 'lib/playbook/z_index.rb', line 9

def z_index_values
  %w[1 2 3 4 5 6 7 8 9 10]
end