rx/presenters

View on GitHub
views/mdc/body/dismissable-drawer.erb

Summary

Maintainability
Test Coverage
<%
  top_items = drawer.menu&.items&.select { |i| eq(i.position, :top) }
  bottom_items = drawer.menu&.items&.select { |i| eq(i.position, :bottom) }
%> 
<aside id="<%= drawer.id %>" class="v-drawer <% if bottom_items.any? %>v-drawer--full-height<% end %> v-drawer__dismissible mdc-drawer mdc-drawer--dismissible mdc-drawer--open">
  <% if drawer.title || drawer.subtitle %>
    <div class="mdc-drawer__header">
  <% end %>
    <% if drawer.title  %>
      <h3 class="mdc-drawer__title"><%= expand_text(drawer.title.text) %></h3>
    <% end %>
    <% if drawer.subtitle %>
      <h6 class="mdc-drawer__subtitle"><%= expand_text(drawer.subtitle.text) %></h6>
    <% end %>
  <% if drawer.title || drawer.subtitle %>
    </div>
  <% end %>
  <div class="mdc-drawer__content">
    <nav class="mdc-list v-list <% if bottom_items.any? %>v-list--full-height<% end %>">
      <% top_items.each do |item| %>
        <%= erb :"body/drawer/#{item.type}", :locals => {item: item} %>
      <% end %>

      <% if bottom_items.any? %>
        <div class="v-list--bottom-wrapper">
          <% bottom_items.each do |item| %>
            <%= erb :"body/drawer/#{item.type}", :locals => {item: item} %>
          <% end %>
        </div>
      <% end %>
    </nav>
    <%= erb :"components/render", :locals => {:components => drawer.components, :scope => nil} %>
  </div>
</aside>