Class: SolidusAdmin::UI::Tab::Component

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/solidus_admin/ui/tab/component.rb

Constant Summary collapse

SIZES =
{
  s: %w[h-7 px-1.5 font-semibold text-sm],
  m: %w[h-9 px-3 font-semibold text-sm],
  l: %w[h-12 px-4 font-semibold text-base],
}

Instance Method Summary collapse

Constructor Details

#initialize(text:, tag: :a, size: :m, current: false, disabled: false, **attributes) ⇒ Component

Returns a new instance of Component.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/components/solidus_admin/ui/tab/component.rb', line 10

def initialize(text:, tag: :a, size: :m, current: false, disabled: false, **attributes)
  @tag = tag
  @text = text
  @size = size
  @attributes = attributes

  @attributes[:'aria-current'] = current
  @attributes[:'aria-disabled'] = disabled
  @attributes[:class] = [
    %w[
      rounded justify-start items-center inline-flex py-1.5 cursor-pointer
      bg-transparent text-gray-500

      hover:bg-gray-75 hover:text-gray-700
      focus:bg-gray-25 focus:text-gray-700

      active:bg-gray-75 active:text-black
      aria-current:bg-gray-50 aria-current:text-black

      disabled:bg-gray-75 disabled:text-gray-400
      aria-disabled:bg-gray-75 aria-disabled:text-gray-400
    ],
    SIZES.fetch(@size.to_sym),
    @attributes.delete(:class),
  ].join(" ")
end

Instance Method Details

#callObject



37
38
39
40
41
42
43
# File 'app/components/solidus_admin/ui/tab/component.rb', line 37

def call
  (
    @tag,
    @text,
    **@attributes
  )
end