Class: Uistiti::Alpha::TogglePreview

Inherits:
ViewComponent::Preview
  • Object
show all
Defined in:
app/components/previews/uistiti/alpha/toggle_preview.rb

Instance Method Summary collapse

Instance Method Details

#playground(checked: false, path: '/uistiti/lookbook/dummy/success', model: 'automated_ticket', field: 'active', color_on: :success, color_off: :disabled) ⇒ Object

Toggle


On each changes, this component makes PUT request to @path with body sent as follow {@field: value} where value is true/false for now. If the request retunr something else than a 2XX the toglle is reverted to its original state

Parameters:

  • checked (Boolean) (defaults to: false)
  • path (defaults to: '/uistiti/lookbook/dummy/success')

    select [/uistiti/lookbook/dummy/success, /uistiti/lookbook/dummy/error]

  • model (defaults to: 'automated_ticket')
  • field (defaults to: 'active')
  • color_on (defaults to: :success)

    select [disabled, success, danger]

  • color_off (defaults to: :disabled)

    select [disabled, success, danger]



16
17
18
# File 'app/components/previews/uistiti/alpha/toggle_preview.rb', line 16

def playground(checked: false, path: '/uistiti/lookbook/dummy/success', model: 'automated_ticket', field: 'active', color_on: :success, color_off: :disabled)
  render(Uistiti::Alpha::Toggle.new(checked:, path:, model:, field:, color_on:, color_off:))
end