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
.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_attributes ⇒ Object
35 36 37 |
# File 'lib/playbook/hover.rb', line 35 def hover_attributes %w[background shadow scale color] end |
#hover_background_values ⇒ Object
23 24 25 |
# File 'lib/playbook/hover.rb', line 23 def hover_background_values [] end |
#hover_color_values ⇒ Object
27 28 29 |
# File 'lib/playbook/hover.rb', line 27 def hover_color_values [] end |
#hover_options ⇒ Object
9 10 11 12 13 |
# File 'lib/playbook/hover.rb', line 9 def { hover: "hover", } end |
#hover_props ⇒ Object
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 = .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 %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_values ⇒ Object
19 20 21 |
# File 'lib/playbook/hover.rb', line 19 def hover_scale_values %w[sm md lg] end |
#hover_shadow_values ⇒ Object
15 16 17 |
# File 'lib/playbook/hover.rb', line 15 def hover_shadow_values %w[deep deeper deepest] end |
#hover_values ⇒ Object
31 32 33 |
# File 'lib/playbook/hover.rb', line 31 def hover_values .keys.select { |sk| try(sk) } end |