Class: DaisyUI::Swap
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- DaisyUI::Swap
- Defined in:
- app/components/daisy_ui/actions/swap.rb
Overview
Swap component implementing DaisyUI’s swap styles
Constant Summary collapse
- VARIANTS =
Available variants from DaisyUI
{ primary: 'text-primary', secondary: 'text-secondary', accent: 'text-accent', info: 'text-info', success: 'text-success', warning: 'text-warning', error: 'text-error', ghost: 'text-base-content', neutral: 'text-neutral' }.freeze
- SIZES =
Available sizes
{ xs: 'text-xs', sm: 'text-sm', md: 'text-base', lg: 'text-lg' }.freeze
- EFFECTS =
Available effects
{ rotate: 'swap-rotate', flip: 'swap-flip', flip_active: 'swap-flip-active' }.freeze
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(states:, value: false, variant: nil, size: nil, effect: nil, active: false, button: false, **system_arguments) ⇒ Swap
constructor
A new instance of Swap.
Constructor Details
#initialize(states:, value: false, variant: nil, size: nil, effect: nil, active: false, button: false, **system_arguments) ⇒ Swap
57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/components/daisy_ui/actions/swap.rb', line 57 def initialize(states:, value: false, variant: nil, size: nil, effect: nil, active: false, button: false, **system_arguments) @states = validate_states!(states) @value = ActiveModel::Type::Boolean.new.cast(value) @variant = build_argument(variant, VARIANTS, 'variant') @size = build_argument(size, SIZES, 'size') @effect = build_argument(effect, EFFECTS, 'effect') @active = active = super(**system_arguments) end |
Instance Method Details
#call ⇒ Object
69 70 71 72 73 74 75 76 77 |
# File 'app/components/daisy_ui/actions/swap.rb', line 69 def call tag.label(**label_html_attributes) do safe_join([ tag.input(**input_html_attributes), render_state(:on), render_state(:off) ].compact) end end |