Module: Playbook::Hover

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

Constant Summary collapse

HOVER_SHADOW_VALUES =
%w[deep deeper deepest].freeze
HOVER_SCALE_VALUES =
%w[sm md lg].freeze
HOVER_BACKGROUND_VALUES =
[].freeze
HOVER_COLOR_VALUES =
[].freeze
HOVER_UNDERLINE_VALUES =
[true, false].freeze
HOVER_VISIBLE_VALUES =
%w[true false].freeze
HOVER_ATTRIBUTES =
%w[background shadow scale color underline visible].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



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

def self.included(base)
  base.prop :hover
  base.prop :group_hover, type: Playbook::Props::Boolean, default: false
end

Instance Method Details

#hover_attributesObject



50
51
52
# File 'lib/playbook/hover.rb', line 50

def hover_attributes
  HOVER_ATTRIBUTES
end

#hover_background_valuesObject



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

def hover_background_values
  HOVER_BACKGROUND_VALUES
end

#hover_color_valuesObject



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

def hover_color_values
  HOVER_COLOR_VALUES
end

#hover_optionsObject



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

def hover_options
  { hover: "hover" }
end

#hover_propsObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/playbook/hover.rb', line 54

def hover_props
  value = hover
  gh = group_hover

  return nil if !value && !gh

  css = +""
  if value
    if value.is_a?(::Hash)
      value.each do |key, val|
        if %i[background color].include?(key)
          css << "hover_#{key}-#{val} " if HOVER_ATTRIBUTES.include?(key.to_s)
        elsif key == :underline && val == true
          css << "hover_underline "
        elsif HOVER_ATTRIBUTES.include?(key.to_s) && send("hover_#{key}_values").include?(val.to_s)
          css << "hover_#{key}_#{val} "
        end
      end
    elsif send("hover_hover_values").include?(value)
      css << "hover_#{value} "
    end
  end

  css << "group_hover " if gh
  css.strip unless css.empty?
end

#hover_scale_valuesObject



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

def hover_scale_values
  HOVER_SCALE_VALUES
end

#hover_shadow_valuesObject



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

def hover_shadow_values
  HOVER_SHADOW_VALUES
end

#hover_underline_valuesObject



38
39
40
# File 'lib/playbook/hover.rb', line 38

def hover_underline_values
  HOVER_UNDERLINE_VALUES
end

#hover_valuesObject



46
47
48
# File 'lib/playbook/hover.rb', line 46

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

#hover_visible_valuesObject



42
43
44
# File 'lib/playbook/hover.rb', line 42

def hover_visible_values
  HOVER_VISIBLE_VALUES
end