Sha256: 5f118d812aeac5690afccf43d8728d43e0df691411002aa6062657c6fd71a7b8

Contents?: true

Size: 1.43 KB

Versions: 31

Compression:

Stored size: 1.43 KB

Contents

<% yield %>

<%
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

31 entries across 31 versions & 1 rubygems

Version Path
bullet_train-themes-tailwind_css-1.2.7 app/views/themes/tailwind_css/fields/_buttons.html.erb
bullet_train-themes-tailwind_css-1.2.6 app/views/themes/tailwind_css/fields/_buttons.html.erb
bullet_train-themes-tailwind_css-1.2.5 app/views/themes/tailwind_css/fields/_buttons.html.erb
bullet_train-themes-tailwind_css-1.2.4 app/views/themes/tailwind_css/fields/_buttons.html.erb
bullet_train-themes-tailwind_css-1.2.3 app/views/themes/tailwind_css/fields/_buttons.html.erb
bullet_train-themes-tailwind_css-1.2.2 app/views/themes/tailwind_css/fields/_buttons.html.erb
bullet_train-themes-tailwind_css-1.2.1 app/views/themes/tailwind_css/fields/_buttons.html.erb
bullet_train-themes-tailwind_css-1.2.0 app/views/themes/tailwind_css/fields/_buttons.html.erb
bullet_train-themes-tailwind_css-1.0.17 app/views/themes/tailwind_css/fields/_buttons.html.erb
bullet_train-themes-tailwind_css-1.0.16 app/views/themes/tailwind_css/fields/_buttons.html.erb
bullet_train-themes-tailwind_css-1.0.15 app/views/themes/tailwind_css/fields/_buttons.html.erb