Add form field update capability to toggle components
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
<button type="submit" role="switch" aria-checked="false"
|
||||
<%= @input_enabled ? "" : "disabled=disabled"%>
|
||||
class="<%= @enabled ? 'bg-indigo-600' : 'bg-gray-200' %>
|
||||
relative inline-flex h-6 w-11 flex-shrink-0
|
||||
cursor-pointer rounded-full border-2 border-transparent
|
||||
transition-colors duration-200 ease-in-out focus:outline-none
|
||||
focus:ring-2 focus:ring-indigo-600 focus:ring-offset-2">
|
||||
<%= button_tag type: "button",
|
||||
data: @data,
|
||||
role: "switch", aria: { checked: @enabled.to_s },
|
||||
disabled: !@input_enabled,
|
||||
class: "#{ @enabled ? 'bg-blue-600' : 'bg-gray-200' }
|
||||
relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer
|
||||
rounded-full border-2 border-transparent transition-colors
|
||||
duration-200 ease-in-out focus:outline-none focus:ring-2
|
||||
focus:ring-blue-600 focus:ring-offset-2" do %>
|
||||
<span class="sr-only"><%= @button_text %></span>
|
||||
<span aria-hidden="true"
|
||||
<span aria-hidden="true" data-settings--toggle-target="switch"
|
||||
class="<%= @enabled ? 'translate-x-5' : 'translate-x-0' %>
|
||||
pointer-events-none inline-block h-5 w-5 transform rounded-full
|
||||
bg-white shadow ring-0 transition duration-200 ease-in-out"></span>
|
||||
</button>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user