Sha256: 1b0b11dfe8af3f409f6252e2d9ff5760117af916ee9a33b1c7b1f3c8d2cde47e

Contents?: true

Size: 734 Bytes

Versions: 5

Compression:

Stored size: 734 Bytes

Contents

# frozen_string_literal: true

class SolidusAdmin::UI::Dropdown::Component < SolidusAdmin::BaseComponent
  DIRECTIONS = {
    left: "right-0",
    right: "left-0",
  }

  SIZES = {
    s: "w-5 h-5",
    m: "w-[22px] h-[22px]",
  }

  def initialize(text: nil, size: :m, direction: :left, **attributes)
    @text = text
    @size = size
    @attributes = attributes
    @direction = direction

    @attributes[:"data-controller"] = "#{stimulus_id} #{attributes[:"data-controller"]}"
    @attributes[:"data-action"] = "turbo:before-cache@window->#{stimulus_id}#close #{attributes[:"data-action"]}"
    @attributes[:class] = "
      font-normal
      #{@size == :m ? 'text-base' : 'text-sm'}
      #{@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/dropdown/component.rb
solidus_admin-0.3.1 app/components/solidus_admin/ui/dropdown/component.rb
solidus_admin-0.3.0 app/components/solidus_admin/ui/dropdown/component.rb
solidus_admin-0.2.0 app/components/solidus_admin/ui/dropdown/component.rb
solidus_admin-0.1.0 app/components/solidus_admin/ui/dropdown/component.rb