Module: Playbook::Hover

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



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

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

Instance Method Details

#hover_attributesObject



35
36
37
# File 'lib/playbook/hover.rb', line 35

def hover_attributes
  %w[background shadow scale color]
end

#hover_background_valuesObject



23
24
25
# File 'lib/playbook/hover.rb', line 23

def hover_background_values
  []
end

#hover_color_valuesObject



27
28
29
# File 'lib/playbook/hover.rb', line 27

def hover_color_values
  []
end

#hover_optionsObject



9
10
11
12
13
# File 'lib/playbook/hover.rb', line 9

def hover_options
  {
    hover: "hover",
  }
end

#hover_propsObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/playbook/hover.rb', line 39

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

  responsive = selected_props.present? && try(selected_props.first).is_a?(::Hash)
  css = ""
  selected_props.each do |prop|
    value = send(prop)
    prefix = hover_options[prop]
    if responsive
      value.each do |key, val|
        if %i[background color].include?(key)
          css += "#{prefix}_#{key}_#{val} " if hover_attributes.include?(key.to_s)
        elsif hover_attributes.include?(key.to_s) && send("hover_#{key}_values").include?(val.to_s)
          css += "#{prefix}_#{key}_#{val} "
        end
      end
    elsif send("hover_#{prop}_values").include?(value)
      css += "#{prefix}_#{value} "
    end
  end

  css.strip unless css.blank?
end

#hover_scale_valuesObject



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

def hover_scale_values
  %w[sm md lg]
end

#hover_shadow_valuesObject



15
16
17
# File 'lib/playbook/hover.rb', line 15

def hover_shadow_values
  %w[deep deeper deepest]
end

#hover_valuesObject



31
32
33
# File 'lib/playbook/hover.rb', line 31

def hover_values
  hover_options.keys.select { |sk| try(sk) }
end