Sha256: af9daf9ba74b18671b6a34bc6fa08b6da98cbbc9c29292d90ee49c3977ee9344

Contents?: true

Size: 1.41 KB

Versions: 546

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

module Playbook
  module Hover
    def self.included(base)
      base.prop :hover
    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 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 = 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.strip unless css.blank?
    end
  end
end

Version data entries

546 entries across 546 versions & 1 rubygems

Version Path
playbook_ui-14.7.0.pre.rc.14 lib/playbook/hover.rb
playbook_ui-14.7.0.pre.rc.13 lib/playbook/hover.rb
playbook_ui-14.6.2.pre.alpha.PBNTR666advancedtablefirstcolumn4406 lib/playbook/hover.rb
playbook_ui-14.7.0.pre.rc.12 lib/playbook/hover.rb
playbook_ui-14.6.2.pre.alpha.PLAY15814384 lib/playbook/hover.rb
playbook_ui-14.6.2.pre.alpha.PBNTR633dropdownavailablepropstable4380 lib/playbook/hover.rb
playbook_ui-14.7.0.pre.rc.11 lib/playbook/hover.rb
playbook_ui-14.7.0.pre.rc.10 lib/playbook/hover.rb
playbook_ui-14.6.2.pre.alpha.PLAY1551tiptapextbump4350 lib/playbook/hover.rb
playbook_ui-14.6.2.pre.alpha.PLAY15814348 lib/playbook/hover.rb
playbook_ui-14.7.0.pre.rc.9 lib/playbook/hover.rb
playbook_ui-14.7.0.pre.rc.8 lib/playbook/hover.rb
playbook_ui-14.6.2.pre.alpha.PBNTR633dropdownavailablepropstable4316 lib/playbook/hover.rb
playbook_ui-14.7.0.pre.rc.7 lib/playbook/hover.rb
playbook_ui-14.6.2.pre.alpha.PBNTR576tooltiptruncatedformpills4312 lib/playbook/hover.rb
playbook_ui-14.6.2.pre.alpha.PBNTR633dropdownavailablepropstable4305 lib/playbook/hover.rb
playbook_ui-14.7.0.pre.rc.6 lib/playbook/hover.rb
playbook_ui-14.6.2.pre.alpha.PBNTR576tooltiptruncatedformpills4304 lib/playbook/hover.rb
playbook_ui-14.6.2.pre.alpha.PBNTR633dropdownavailablepropstable4303 lib/playbook/hover.rb
playbook_ui-14.6.2.pre.alpha.PBNTR576tooltiptruncatedformpills4296 lib/playbook/hover.rb