BathHacked/energy-sparks

View on GitHub
app/components/panel_switcher_component/panel_switcher_component.html.erb

Summary

Maintainability
Test Coverage
<div<%= " id=#{id}" if id %> class="panel-switcher-component<%= " #{classes}" if classes %>">
  <% if title %>
    <h4><strong><%= title %></strong></h4>
  <% end %>
  <% if description %>
    <p><%= description %></p>
  <% end %>

  <div class="pb-1">
    <% panels.each do |panel| %>
      <div class="form-check form-check-inline">
        <%= radio_button_tag name, panel.name, panel.name == selected, class: 'form-check-input' %>
        <%= label_tag  "#{name}_#{panel.name}", panel.label, title: t('components.panel_switcher.change_to', name: panel.label), 'data-toggle': 'tooltip', class: "form-check-label" %>
      </div>
    <% end %>
  </div>

  <% panels.each do |panel| %>
    <div class="panel <%= panel.name %>" <%= 'hidden' unless panel.name == selected %>>
      <%= panel %>
    </div>
  <% end %>
</div>