Sha256: d5c79f2e93ca7da7382e9f6dcacb931221c5353c9aef934dfabe52ef99e8c41e

Contents?: true

Size: 1021 Bytes

Versions: 12

Compression:

Stored size: 1021 Bytes

Contents

module Coco
  class Popover < Coco::Component
    include Concerns::AcceptsOptions

    accepts_option :theme, from: ["netural", "info"], default: "neutral"
    accepts_option :trigger, from: ["click", "manual", "hover"], default: "click"
    accepts_option :placement,
      from: %w[top top-start top-end right right-start right-end bottom bottom-start bottom-end left left-start left-end auto auto-start auto-end],
      default: "auto",
      private: true

    before_initialize do |kwargs|
      [:placement, :trigger, :theme].each do |key|
        kwargs[key] = kwargs[key].to_s.tr("_", "-") if kwargs.key?(key)
      end
      kwargs
    end

    attr_reader :target

    def initialize(target: nil, options: {}, **)
      @target = target
      @options = options
    end

    def trigger
      (get_option_value(:trigger) == "hover") ? "mouseenter focus" : get_option_value(:trigger)
    end

    def options
      {
        placement: get_option_value(:placement),
        **@options
      }
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
coveragebook_components-0.19.8 app/components/coco/messaging/popover/popover.rb
coveragebook_components-0.19.7 app/components/coco/messaging/popover/popover.rb
coveragebook_components-0.19.6 app/components/coco/messaging/popover/popover.rb
coveragebook_components-0.19.5 app/components/coco/messaging/popover/popover.rb
coveragebook_components-0.19.4 app/components/coco/messaging/popover/popover.rb
coveragebook_components-0.19.3 app/components/coco/messaging/popover/popover.rb
coveragebook_components-0.19.2 app/components/coco/messaging/popover/popover.rb
coveragebook_components-0.19.1 app/components/coco/messaging/popover/popover.rb
coveragebook_components-0.19.0 app/components/coco/messaging/popover/popover.rb
coveragebook_components-0.18.8 app/components/coco/messaging/popover/popover.rb
coveragebook_components-0.18.7 app/components/coco/messaging/popover/popover.rb
coveragebook_components-0.18.0 app/components/coco/messaging/popover/popover.rb