appirits/comable

View on GitHub
frontend/app/views/comable/shared/_header.slim

Summary

Maintainability
Test Coverage
header
  nav.navbar.navbar-default role="navigation"
    .comable-navbar-top
      .container
        /! Collect the nav links, forms, and other content for toggling
        #bs-example-navbar-collapse-1.collapse.navbar-collapse
          ul.nav.navbar-nav
            li
              p.navbar-text
                | descriptions
          ul.nav.navbar-nav.navbar-right
            li
              = link_to Comable.t('my_account'), comable.user_path
            li
              - if current_comable_user.signed_in?
                = link_to comable.destroy_user_session_path, method: :delete do
                  i.glyphicon.glyphicon-log-out>
                  = Comable.t('sign_out')
              - else
                = link_to comable.new_user_session_path do
                  i.glyphicon.glyphicon-log-in>
                  = Comable.t('sign_in')
    .container
      /! Brand and toggle get grouped for better mobile display
      .navbar-header
        button.navbar-toggle.collapsed data-target="#bs-example-navbar-collapse-1" data-toggle="collapse" type="button"
          span.sr-only Toggle navigation
          span.icon-bar
          span.icon-bar
          span.icon-bar
        = link_to current_store.name, comable.root_path, class: 'navbar-brand'
      /! Collect the nav links, forms, and other content for toggling
      #bs-example-navbar-collapse-1.collapse.navbar-collapse
        ul.nav.navbar-nav
          li.dropdown.menu-large
            = link_to comable.products_path, class: 'dropdown-toggle', role: 'button', 'aria-expanded' => 'false' do
              = Comable.t('category')
              span.caret<
            ul.dropdown-menu.megamenu.row
              - Comable::Category.roots.each do |category|
                li.col-sm-3
                  ul
                    li.dropdown-header
                      = category.name
                    - category.children.each do |child|
                      li = link_to_category child, force_link: true
        ul.nav.navbar-nav.navbar-right
          li.dropdown
            = link_to comable.cart_path, class: 'dropdown-toggle', role: 'button', 'aria-expanded' => 'false' do
              i.glyphicon.glyphicon-shopping-cart>
              span
                = Comable.t('cart')
              span<
                | (#{current_comable_user.cart.size})
              span.caret<
            ul.dropdown-menu.comable-mini-cart role="menu"
              - current_comable_user.cart.take(5).each do |cart_item|
                li
                  = link_to comable.product_path(cart_item.product) do
                    .comable-image
                      = image_tag cart_item.product.image_url, width: '100%'
                    .comable-name
                      = cart_item.name_with_sku
                    .comable-quantity
                      = "#{cart_item.class.human_attribute_name(:quantity)}: "
                      = cart_item.quantity
              li.comable-show-cart
                = link_to Comable.t('show_cart'), comable.cart_path
        = form_tag comable.products_path, method: :get, class: 'navbar-form' do
          .form-group
            .input-group
              = text_field_tag :q, params[:q], class: 'form-control'
              span.input-group-btn
                = button_tag Comable.t('search'), class: 'btn btn-default', type: 'button'