rx/presenters

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

Summary

Maintainability
Test Coverage
<%
  require_relative "drag_and_drop/drag_and_drop"
%>

<div id="<%= comp.id %>" class="<%= 'v-hidden' if comp.hidden %>">
  <div
  <% if comp.tag %>
  data-input-tag="<%= comp.tag %>"
  <% end %>
  <%= draggable_attributes(comp) %>
  <%= drop_zone_attributes(comp) %>
  class="v-card card-<%= comp.id %> mdc-card
           <%= 'v-actionable' if comp.events && !comp.draggable %>
           <%= 'v-dnd-draggable' if comp.draggable %>
           <%= 'v-card-selected' if comp.selected %>
           <%= comp.css_class.join(' ') %>
           <%= color_classname(comp, 'background-', :background_color)%>"
  style="<%= "width: #{comp.width};" if comp.width%>
    <%= "height: #{comp.height};" if comp.height %>
    <%= color_style(comp, 'background-', :background_color) %>"
  <%= erb :"components/event", :locals => {comp: comp, events: comp.events, parent_id: comp.event_parent_id} %>
  data-is-container>
    <%= erb(:"components/progress", :locals => {:comp => comp.progress}) if comp.progress && includes_one?(Array(comp.progress.position), %i(top both)) %>
    <% if comp.media %>
      <div class="v-errors">
        <div id="<%= comp.media.id %>"
             class="mdc-card__media v-card-media
                <%= 'v-hidden' if comp.media.hidden %>
                <%= 'mdc-card__media--square' if false && comp.media.width == comp.media.height %>"
             style="<%= "width: #{comp.media.width};" if comp.media.width%>
                 <%= "height: #{comp.media.height};" if comp.media.height  %>
               <%= "background-color: #{comp.media.color};" if comp.media.color %>">
          <%= erb :"components/render", :locals => {:components => comp.media.components, :scope => nil} %>
          <%= erb :"components/button", :locals => {:comp => comp.media.button, class_name: "v-card__media-menu"} %>
          <%= erb :"components/image", :locals => {:comp => comp.media.image, class_name: 'v-card-media-image'} %>
          <%= erb :"components/avatar", :locals => {:comp => comp.media.avatar, class_name: 'v-card-media-avatar'} %>
          <%= erb :"components/headline", :locals => {:comp => comp.media.title, class_name: "v-card-title"} %>
          <%= erb :"components/headline", :locals => {:comp => comp.media.subtitle, class_name: "v-card-title"} %>
        </div>
      </div>
    <% end %>
    <div class="v-errors" style="<%= "height: #{comp.height};" if comp.height %>">
      <% if comp.components.any? %>
        <div class="v-card-content
                  <%= _padding_classes_(comp.padding, subclass: :col) %>"
             style="<%= "height: #{comp.height};" if comp.height %>">
          <%= erb :"components/render", :locals => {:components => comp.components, :scope => nil} %>
        </div>
      <% end %>

      <% if comp.actions&.buttons
           action_buttons = comp.actions.buttons.select { |b| !eq(b.button_type, :icon) }
           action_icons = comp.actions.buttons.select { |b| eq(b.button_type, :icon) }
      %>
        <div class="mdc-card__actions v-card--actions">
          <div class="mdc-card__action-buttons">
            <% action_buttons.each do |button| %>
              <%= erb :"components/button", :locals => {:comp => button, class_name: 'mdc-card__action mdc-card__action--button'} %>
            <% end %>
          </div>
          <div class="mdc-card__action-icons">
            <% action_icons.each do |button| %>
              <%= erb :"components/button", :locals => {:comp => button, class_name: 'mdc-card__action mdc-card__action--icon'} %>
            <% end %>
            <% comp.actions.switches.each do |switch| %>
              <%= erb :"components/switch", :locals => {:comp => switch, class_name: 'mdc-card__action'} %>
            <% end %>
          </div>
        </div>
      <% end %>
    </div>
    <%= erb(:"components/progress", :locals => {:comp => comp.progress}) if comp.progress && includes_one?(Array(comp.progress.position), %i(bottom both)) %>
  </div>
</div>