Module: Playbook::Hover
- Included in:
- KitBase
- Defined in:
- lib/playbook/hover.rb
Class Method Summary collapse
Instance Method Summary collapse
- #hover_attributes ⇒ Object
- #hover_background_values ⇒ Object
- #hover_color_values ⇒ Object
- #hover_options ⇒ Object
- #hover_props ⇒ Object
- #hover_scale_values ⇒ Object
- #hover_shadow_values ⇒ Object
- #hover_values ⇒ Object
Class Method Details
Instance Method Details
#hover_attributes ⇒ Object
36 37 38 |
# File 'lib/playbook/hover.rb', line 36 def hover_attributes %w[background shadow scale color] end |
#hover_background_values ⇒ Object
24 25 26 |
# File 'lib/playbook/hover.rb', line 24 def hover_background_values [] end |
#hover_color_values ⇒ Object
28 29 30 |
# File 'lib/playbook/hover.rb', line 28 def hover_color_values [] end |
#hover_options ⇒ Object
10 11 12 13 14 |
# File 'lib/playbook/hover.rb', line 10 def { hover: "hover", } end |
#hover_props ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/playbook/hover.rb', line 40 def hover_props selected_props = .keys.select { |sk| try(sk) } return nil if selected_props.nil? && group_hover.nil? responsive = selected_props.present? && try(selected_props.first).is_a?(::Hash) css = "" selected_props.each do |prop| value = send(prop) prefix = [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 += "group_hover " if group_hover css.strip unless css.blank? end |
#hover_scale_values ⇒ Object
20 21 22 |
# File 'lib/playbook/hover.rb', line 20 def hover_scale_values %w[sm md lg] end |
#hover_shadow_values ⇒ Object
16 17 18 |
# File 'lib/playbook/hover.rb', line 16 def hover_shadow_values %w[deep deeper deepest] end |
#hover_values ⇒ Object
32 33 34 |
# File 'lib/playbook/hover.rb', line 32 def hover_values .keys.select { |sk| try(sk) } end |