<div class="document-name-bar">
  <% if defined?(f) %>
    <div class="input-field inline">
      <%=
        f.text_field :title,
          placeholder: 'Untitled document',
          value: document.try(:name) || 'Untitled document',
          class: 'teal-text',
          style: 'font-size: 150%; border-bottom: 1px solid teal;'
      %>
      <%= f.label :title, 'Editing' %>
    </div>
    <div class="right">
      by <%= link_to document.user.display_name, document.user, class: "#{User.text_color}" %>
    </div>
    <div class="clearfix"></div>
  <% else %>

    <h5 class="document-title">
      <%= document.try(:name) || 'Untitled document' %>
    </h5>
    <div class="right">
      by <%= link_to document.user.display_name, document.user, class: "#{User.text_color}" %>
    </div>
    <% if user_signed_in? && current_user == document.user %>
      <div class="left">
        <%= link_to 'Edit this document', edit_document_path(document) %>
      </div>
    <% end %>
    <div class="clearfix"></div>

  <% end %>
</div>
