Class: SolidusAdmin::UI::Forms::Switch::Component
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- SolidusAdmin::UI::Forms::Switch::Component
- Defined in:
- app/components/solidus_admin/ui/forms/switch/component.rb
Constant Summary collapse
- SIZES =
{ s: ' w-8 h-5 after:w-4 after:h-4 after:top-0.5 after:left-0.5 active:after:w-4 after:checked:left-[1.875rem] ', m: ' w-10 h-6 after:w-5 after:h-5 after:top-0.5 after:left-0.5 active:after:w-5 after:checked:left-[2.375rem] ', }.freeze
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(size: :m, **attributes) ⇒ Component
constructor
A new instance of Component.
Constructor Details
#initialize(size: :m, **attributes) ⇒ Component
Returns a new instance of Component.
25 26 27 28 |
# File 'app/components/solidus_admin/ui/forms/switch/component.rb', line 25 def initialize(size: :m, **attributes) @size = size @attributes = attributes end |
Instance Method Details
#call ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/components/solidus_admin/ui/forms/switch/component.rb', line 30 def call tag.input( type: 'checkbox', class: " #{SIZES.fetch(@size)} appearance-none outline-0 cursor-pointer bg-gray-200 inline-block rounded-full relative after:content-[''] after:absolute after:bg-white after:duration-300 after:rounded-full after:checked:-translate-x-full hover:bg-gray-300 disabled:opacity-40 disabled:cursor-not-allowed checked:bg-gray-500 checked:hover:bg-gray-700 ", **@attributes, ) end |