Class: SolidusAdmin::UI::Forms::Checkbox::Component

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

Constant Summary collapse

SIZES =
{
  s: 'w-4 h-4',
  m: 'w-5 h-5',
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(size: :m, **attributes) ⇒ Component

Returns a new instance of Component.



9
10
11
12
# File 'app/components/solidus_admin/ui/forms/checkbox/component.rb', line 9

def initialize(size: :m, **attributes)
  @size = size
  @attributes = attributes
end

Instance Method Details

#callObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/components/solidus_admin/ui/forms/checkbox/component.rb', line 14

def call
  tag.input(
    type: 'checkbox',
    class: "
      #{SIZES.fetch(@size)}
      form-checkbox
      cursor-pointer
      disabled:cursor-not-allowed

      bg-white rounded border border-2 border-gray-300
      hover:border-gray-700
      focus:ring focus:ring-gray-300 focus:ring-0.5 focus:bg-white focus:ring-offset-0
      active:ring active:ring-gray-300 active:ring-0.5
      disabled:border-gray-300

      indeterminate:border-gray-700 indeterminate:bg-gray-700 indeterminate:text-white
      indeterminate:hover:border-gray-500 indeterminate:hover:bg-gray-500
      indeterminate:focus:bg-gray-700
      indeterminate:disabled:border-gray-300 indeterminate:disabled:bg-gray-300

      checked:border-gray-700 checked:bg-gray-700 checked:text-white
      checked:hover:border-gray-500 checked:hover:bg-gray-500
      checked:focus:bg-gray-700
      checked:disabled:border-gray-300 checked:disabled:bg-gray-300
    ",
    **@attributes,
  )
end