Sha256: efd4e9db20bf7ad55aa27ec07f03b24668d64f9e0d2fb305fc831212107d4950

Contents?: true

Size: 1.42 KB

Versions: 80

Compression:

Stored size: 1.42 KB

Contents

<%
stimulus_controller = 'fields--button-toggle'
form ||= current_fields_form
html_options ||= {}
html_options[:id] ||= form.field_id(method)
multiple ||= false
other_options ||= {}
options ||= options_for(form, method)
%>

<% content = render 'shared/fields/field', form: form, method: method, options: html_options, other_options: other_options do %>
  <% content_for :field do %>
    <div>
      <% options.each do |value, label| %>
        <% checked = form.object.send(method).is_a?(Array) ? form.object.send(method).map(&:to_s).include?(value.to_s) : form.object.send(method).to_s == value.to_s  %>
        <label class="btn-toggle" data-controller="<%= stimulus_controller %>">
          <% if multiple %>
            <%= form.check_box method, {multiple: multiple, checked: checked, data: { "#{stimulus_controller}-target": 'shadowField' }}, value, "" %>
          <% else %>
            <%= form.radio_button method, value, { data: { "#{stimulus_controller}-target": 'shadowField' }, checked: checked} %>
          <% end %>
          <button type="button" class="button-alternative mb-1.5 mr-1" data-action="<%= stimulus_controller %>#clickShadowField">
            <%= label %>
          </button>
        </label>
      <% end %>
    </div>
  <% end %>
<% end %>

<%# The `-mb-1.5` is making up for the `mb-1.5` on each of the buttons. This allows them to wrap with appropriate vertical spacing. %>
<div class="-mb-1.5"><%= content %></div>

Version data entries

80 entries across 80 versions & 1 rubygems

Version Path
bullet_train-themes-tailwind_css-1.6.38 app/views/themes/tailwind_css/fields/_buttons.html.erb
bullet_train-themes-tailwind_css-1.6.37 app/views/themes/tailwind_css/fields/_buttons.html.erb
bullet_train-themes-tailwind_css-1.6.36 app/views/themes/tailwind_css/fields/_buttons.html.erb
bullet_train-themes-tailwind_css-1.6.35 app/views/themes/tailwind_css/fields/_buttons.html.erb
bullet_train-themes-tailwind_css-1.6.34 app/views/themes/tailwind_css/fields/_buttons.html.erb
bullet_train-themes-tailwind_css-1.6.33 app/views/themes/tailwind_css/fields/_buttons.html.erb
bullet_train-themes-tailwind_css-1.6.32 app/views/themes/tailwind_css/fields/_buttons.html.erb
bullet_train-themes-tailwind_css-1.6.31 app/views/themes/tailwind_css/fields/_buttons.html.erb
bullet_train-themes-tailwind_css-1.6.30 app/views/themes/tailwind_css/fields/_buttons.html.erb
bullet_train-themes-tailwind_css-1.6.29 app/views/themes/tailwind_css/fields/_buttons.html.erb
bullet_train-themes-tailwind_css-1.6.28 app/views/themes/tailwind_css/fields/_buttons.html.erb
bullet_train-themes-tailwind_css-1.6.27 app/views/themes/tailwind_css/fields/_buttons.html.erb
bullet_train-themes-tailwind_css-1.6.26 app/views/themes/tailwind_css/fields/_buttons.html.erb
bullet_train-themes-tailwind_css-1.6.25 app/views/themes/tailwind_css/fields/_buttons.html.erb
bullet_train-themes-tailwind_css-1.6.24 app/views/themes/tailwind_css/fields/_buttons.html.erb
bullet_train-themes-tailwind_css-1.6.23 app/views/themes/tailwind_css/fields/_buttons.html.erb
bullet_train-themes-tailwind_css-1.6.22 app/views/themes/tailwind_css/fields/_buttons.html.erb
bullet_train-themes-tailwind_css-1.6.21 app/views/themes/tailwind_css/fields/_buttons.html.erb
bullet_train-themes-tailwind_css-1.6.20 app/views/themes/tailwind_css/fields/_buttons.html.erb
bullet_train-themes-tailwind_css-1.6.19 app/views/themes/tailwind_css/fields/_buttons.html.erb