rx/presenters

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

Summary

Maintainability
Test Coverage
<%
  dialog_action_buttons = Array(comp&.actions&.buttons)
%>
<div id="<%= comp.id %>"
     <% if comp.tag %>
     data-input-tag="<%= comp.tag %>"
     <% end %>
     class="v-dialog mdc-dialog"
     role="alertdialog"
     aria-modal="true"
     aria-labelledby="<%= comp.id %>-title"
     aria-describedby="<%= comp.id %>-content"
     data-is-container
     <%= erb :"components/event", :locals => {comp: comp, events: comp.events, parent_id: comp.event_parent_id} %>>
  <div class="mdc-dialog__container"
    <% if comp.percent_width || comp.percent_height %>
      style="<%= "max-width: none; width: #{comp.percent_width}; " if comp.percent_width %>
        <%= "height: #{comp.percent_height}; " if comp.percent_height %>"
    <% end %>>
    <div class="mdc-dialog__surface"
         <% if comp.px_width || comp.px_height  || comp.percent_width%>
              style="max-width: none;<%= " width: #{comp.px_width.to_i.to_s == comp.px_width ? comp.px_width + 'px' : comp.px_width}; " if comp.px_width %>
                <%= "height: #{comp.px_height.to_i.to_s == comp.px_height ? comp.px_height + 'px' : comp.px_height}; " if comp.px_height %>"
        <% end %>>
      <%= erb(:"components/progress", :locals => {:comp => comp.progress}) if comp.progress && includes_one?(Array(comp.progress.position), %i(top both))%>
      <!-- Title cannot contain leading whitespace due to mdc-typography-baseline-top() -->
      <% if comp.title %>
        <h2 class="mdc-dialog__title" id="<%= comp.id %>-title"><%= expand_text(comp.title.text) %></h2>
      <% end %>

      <div class="mdc-dialog__content" id="<%= comp.id %>-content">
        <div class="v-errors">
          <%= erb :"components/render", :locals => {:components => comp.components, :scope => nil} %>
          <% if dialog_action_buttons.any? %>
            <footer class="mdc-dialog__actions">
              <% dialog_action_buttons.each do |button| %>
                <%= erb :"components/button",
                        :locals => {:comp => button,
                                    :class_name => "mdc-dialog__button",
                                    :data_attributes => "data-mdc-dialog-action='#{button.id}' data-auto-close"} %>
              <% end %>
            </footer>
          <% end %>
        </div>
      </div>
      <%= erb(:"components/progress", :locals => {:comp => comp.progress}) if comp.progress && includes_one?(Array(comp.progress.position), %i(bottom both))%>
    </div>
  </div>
  <div class="mdc-dialog__scrim"></div>
</div>