From bda1ef55138de45b00b8a97b8ec52c3e7a97a051 Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Fri, 28 Mar 2014 17:09:16 +1100 Subject: [PATCH] Adding a cart icon with count --- app/assets/stylesheets/darkswarm/header.css.sass | 14 ++++++++++++-- app/helpers/spree/orders_helper.rb | 4 ++++ app/views/shared/_menu.html.haml | 9 +++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/darkswarm/header.css.sass b/app/assets/stylesheets/darkswarm/header.css.sass index 5c4bdb13be..910c40c6bc 100644 --- a/app/assets/stylesheets/darkswarm/header.css.sass +++ b/app/assets/stylesheets/darkswarm/header.css.sass @@ -2,9 +2,19 @@ nav.top-bar margin-bottom: 0px a.icon - line-height: auto - font-size: 1.75em + &:hover + text-decoration: none + height: 45px color: white + i + font-size: 29px + line-height: 45px + span + font-size: 13px + display: inline-block + line-height: 45px + height: 45px + vertical-align: top body > section[role='main'] padding: 0px diff --git a/app/helpers/spree/orders_helper.rb b/app/helpers/spree/orders_helper.rb index f3a7b433f8..86f295ae52 100644 --- a/app/helpers/spree/orders_helper.rb +++ b/app/helpers/spree/orders_helper.rb @@ -18,5 +18,9 @@ module Spree def last_completed_order spree_current_user.orders.complete.last end + + def cart_count + current_order.andand.line_items.count || 0 + end end end diff --git a/app/views/shared/_menu.html.haml b/app/views/shared/_menu.html.haml index 2ef3b3d566..3ece58cf4d 100644 --- a/app/views/shared/_menu.html.haml +++ b/app/views/shared/_menu.html.haml @@ -10,3 +10,12 @@ = render 'shared/signed_out' - else = render 'shared/signed_in' + + %section.top-bar-section + %ul.right + %li.cart + %a.icon{href: cart_url} + %i.fi-shopping-cart + %span + = cart_count + items