ArturT/Railstom

View on GitHub
app/views/layouts/_top_navbar.html.erb

Summary

Maintainability
Test Coverage
<div class="contain-to-grid">
  <nav class="top-bar top-bar-menu" data-topbar>
    <ul class="title-area">
      <!-- Title Area -->
      <li class="name">
        <h1><a href="<%= root_path %>"><i class="fa fa-terminal"></i> Railstom</a></h1>
      </li>
      <!-- Remove the class "menu-icon" to get rid of menu icon. Take out "Menu" to just have icon alone -->
      <li class="toggle-topbar menu-icon"><a href="#"><span><%= t('layouts.application.words.menu') %></span></a></li>
    </ul>

    <section class="top-bar-section">
      <!-- Left Nav Section -->
      <ul class="left">
        <li class="divider"></li>
        <li class="has-dropdown"><a href="#"><i class="fa fa-globe fa-lg"></i> <%= I18n.locale %></a>
          <ul class="dropdown">
            <% Locale.supported_languages.each do |locale| %>
              <li><%= link_to I18n.name_for_locale(locale), (request.get? ? url_for(locale: locale) : root_path(locale: locale)) %></li>
            <% end %>
          </ul>
        </li>
        <li class="divider"></li>
      </ul>

      <!-- Right Nav Section -->
      <ul class="right">
        <li class="divider"></li>
        <% if user_signed_in? %>
          <!-- user is signed in -->
          <%= menu_items(
            # My account
            { name: t('layouts.application.words.my_account'),
              icon: 'fa-wrench',
              path: edit_user_settings_path,
              divider: true },

            # Link to active admin
            { name: 'Admin',
              icon: 'fa-cog',
              path: admin_root_path,
              condition: current_user.admin?,
              divider: true },

            # Sign out
            { name: t('layouts.application.words.sign_out'),
              path: destroy_user_session_path,
              method: :delete }
          ) %>
        <% else %>
          <!-- user is signed out -->
          <li class="has-dropdown"><a href="#"><span id="sign-in-icon-container"></span><%= t('layouts.application.words.sign_in') %></a>
            <ul class="dropdown">
              <li><%= link_to raw(%{<i class="fa fa-facebook-square"></i> #{t('layouts.application.sign_up_modal.sign_in_via_facebook')}}), user_omniauth_authorize_path(:facebook), data: { 'load-icon' => '#sign-in-icon-container', 'load-icon-margin' => 'right:10px' } %></li>
              <li><%= link_to raw(%{<i class="fa fa-envelope"></i> #{t('layouts.application.words.sign_in_via_email')}}), new_user_session_path %></li>
              <li class="divider"></li>
              <li><%= link_to raw(%{<i class="fa fa-key"></i> #{t("devise.passwords.new.forgot_your_password")}}), new_user_password_path %></li>
            </ul>
          </li>
          <li class="divider"></li>
          <li class="has-form">
            <%= link_to raw(%{#{t('layouts.application.words.sign_up')} <i class="fa fa-sign-in"></i>}), '#', class: 'button', data: { 'reveal-id' => 'signUpModal' } %>
          </li>
        <% end %>
      </ul>
    </section>
  </nav>
</div>