Module: Playbook::ZIndex

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

Constant Summary collapse

Z_INDEX_VALUES =
%w[1 2 3 4 5 6 7 8 9 10 max].freeze
SCREEN_SIZES =
%w[xs sm md lg xl].freeze

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



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

def screen_size_values
  SCREEN_SIZES
end

#z_index_optionsObject



16
17
18
# File 'lib/playbook/z_index.rb', line 16

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

#z_index_propsObject



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

def z_index_props
  value = z_index
  return nil unless value

  if value.is_a?(::Hash)
    css = +""
    css << "z_index_#{value[:default]} " if value.key?(:default) && Z_INDEX_VALUES.include?(value[:default].to_s)
    value.each do |key, val|
      css << "z_index_#{key}_#{val} " if SCREEN_SIZES.include?(key.to_s) && Z_INDEX_VALUES.include?(val.to_s)
    end
    css.strip unless css.empty?
  elsif Z_INDEX_VALUES.include?(value)
    "z_index_#{value}"
  end
end

#z_index_valuesObject



12
13
14
# File 'lib/playbook/z_index.rb', line 12

def z_index_values
  Z_INDEX_VALUES
end