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_options ⇒ Object
- #hover_props ⇒ Object
- #hover_scale_values ⇒ Object
- #hover_shadow_values ⇒ Object
- #hover_values ⇒ Object
Class Method Details
.included(base) ⇒ Object
7 8 9 |
# File 'lib/playbook/hover.rb', line 7 def self.included(base) base.prop :hover end |
Instance Method Details
#hover_attributes ⇒ Object
33 34 35 |
# File 'lib/playbook/hover.rb', line 33 def hover_attributes %w[background shadow scale] end |
#hover_background_values ⇒ Object
25 26 27 |
# File 'lib/playbook/hover.rb', line 25 def hover_background_values [] end |
#hover_options ⇒ Object
11 12 13 14 15 |
# File 'lib/playbook/hover.rb', line 11 def { hover: "hover", } end |
#hover_props ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/playbook/hover.rb', line 37 def hover_props selected_props = .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 = [prop] if responsive value.each do |key, val| if key == :background 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_values ⇒ Object
21 22 23 |
# File 'lib/playbook/hover.rb', line 21 def hover_scale_values %w[sm md lg] end |
#hover_shadow_values ⇒ Object
17 18 19 |
# File 'lib/playbook/hover.rb', line 17 def hover_shadow_values %w[deep deeper deepest] end |
#hover_values ⇒ Object
29 30 31 |
# File 'lib/playbook/hover.rb', line 29 def hover_values .keys.select { |sk| try(sk) } end |