Sha256: 53ddcf1eb819c93c74a2e66f71f3dd1a496d6c78e05c4f538059fe6324402b19

Contents?: true

Size: 1.54 KB

Versions: 55

Compression:

Stored size: 1.54 KB

Contents

# frozen_string_literal: true

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

    def hover_options
      {
        hover: "hover",
      }
    end

    def hover_shadow_values
      %w[deep deeper deepest]
    end

    def hover_scale_values
      %w[sm md lg]
    end

    def hover_background_values
      []
    end

    def hover_color_values
      []
    end

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

    def hover_attributes
      %w[background shadow scale color]
    end

    def hover_props
      selected_props = hover_options.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 = 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 += "group_hover " if group_hover
      css.strip unless css.blank?
    end
  end
end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
playbook_ui-14.10.0.pre.rc.9 lib/playbook/hover.rb
playbook_ui-14.10.0.pre.rc.8 lib/playbook/hover.rb
playbook_ui-14.10.0.pre.rc.7 lib/playbook/hover.rb
playbook_ui-14.10.0.pre.rc.6 lib/playbook/hover.rb
playbook_ui-14.10.0.pre.rc.5 lib/playbook/hover.rb
playbook_ui-14.10.0.pre.rc.4 lib/playbook/hover.rb
playbook_ui-14.9.0.pre.alpha.PLAY16264818 lib/playbook/hover.rb
playbook_ui-14.9.0.pre.alpha.PBNTR702stickyleftcolrails4806 lib/playbook/hover.rb
playbook_ui-14.10.0.pre.rc.3 lib/playbook/hover.rb
playbook_ui-14.10.0.pre.rc.2 lib/playbook/hover.rb
playbook_ui-14.9.0.pre.alpha.play1742globalheightfixes4766 lib/playbook/hover.rb
playbook_ui-14.10.0.pre.rc.1 lib/playbook/hover.rb
playbook_ui-14.9.0.pre.alpha.PBNTR686advancedtablepaginationpoc4747 lib/playbook/hover.rb
playbook_ui-14.9.0.pre.alpha.pbntr700newresettodefaultprop4736 lib/playbook/hover.rb
playbook_ui-14.10.0.pre.rc.0 lib/playbook/hover.rb
playbook_ui-14.9.0 lib/playbook/hover.rb
playbook_ui-14.9.0.pre.rc.18 lib/playbook/hover.rb
playbook_ui-14.9.0.pre.rc.17 lib/playbook/hover.rb
playbook_ui-14.9.0.pre.rc.16 lib/playbook/hover.rb
playbook_ui-14.9.0.pre.rc.15 lib/playbook/hover.rb