Sha256: 9261a4879659cd8bfeb839595f7cf3f3848045d872332772baae4d12454bd746

Contents?: true

Size: 755 Bytes

Versions: 5

Compression:

Stored size: 755 Bytes

Contents

# frozen_string_literal: true

class SolidusAdmin::UI::Toggletip::Component < SolidusAdmin::BaseComponent
  POSITIONS = {
    below: {
      arrow: "before:top-0 before:left-1/2 before:translate-y-[-50%] before:translate-x-[-50%]",
      bubble: "translate-x-[calc(-50%+(1rem/2))] translate-y-[calc(0.375rem/2)]"
    },
    above: {
      arrow: "before:bottom-0 before:left-1/2 before:translate-y-[50%] before:translate-x-[-50%]",
      bubble: "translate-x-[calc(-50%+(1rem/2))] translate-y-[calc(-100%-1rem-(0.375rem/2))]"
    },
  }.freeze

  def initialize(text:, position: :above, **attributes)
    @text = text
    @position = position
    @attributes = attributes
    @attributes[:class] = "relative inline-block #{@attributes[:class]}"
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
solidus_admin-0.3.2 app/components/solidus_admin/ui/toggletip/component.rb
solidus_admin-0.3.1 app/components/solidus_admin/ui/toggletip/component.rb
solidus_admin-0.3.0 app/components/solidus_admin/ui/toggletip/component.rb
solidus_admin-0.2.0 app/components/solidus_admin/ui/toggletip/component.rb
solidus_admin-0.1.0 app/components/solidus_admin/ui/toggletip/component.rb