rx/presenters

View on GitHub
views/mdc/components/switch.erb

Summary

Maintainability
Test Coverage
<% class_name = '' unless local_variables.include? :class_name
%>

<div class="v-form-field mdc-form-field">
  <div id="<%= comp.id %>"
       <% if comp.tag %>data-input-tag="<%= comp.tag %>"<% end %>
       <% if comp.dirtyable %>data-dirtyable<% end %>
       class="v-switch v-input mdc-switch
      <%= 'mdc-switch--disabled' if comp.disabled %>
      <%= class_name %>">
    <div class="mdc-switch__track"></div>
    <div class="mdc-switch__thumb-underlay">
      <div class="mdc-switch__thumb">
        <input id="<%= comp.id %>-input"
               name="<%= comp.name %>"
               type="checkbox"
               class="mdc-switch__native-control"
               role="switch"
               <% if comp.value %>value="<%= comp.value %>"<% end %>
               data-off="<%= comp.off_value %>"
               <%= ' checked ' if comp.checked %>
               <%= ' disabled ' if comp.disabled %>
               <%= erb :"components/event", :locals => {comp: comp, events: comp.events, parent_id: comp.event_parent_id} %>/>
      </div>
    </div>
  </div>
  <label class="v-switch__label" for="<%= comp.id %>-input"><%= comp.text %></label>
</div>
<%= erb :"components/tooltip", :locals => {comp: comp.tooltip, parent_id: comp.id} %>