Merge pull request #3252 from mllocs/fix/navbar-right-items-styles

Top navbar redesign and cleanup
This commit is contained in:
Luis Ramos
2019-06-13 12:04:20 +01:00
committed by GitHub
17 changed files with 268 additions and 198 deletions

View File

@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="18" viewBox="0 0 20 18">
<path fill="#FFF" fill-opacity=".5" fill-rule="nonzero" d="M18.338 10.593l1.64-7.312a.841.841 0 0 0-.812-1.031H5.528L5.21.675A.836.836 0 0 0 4.393 0H.833A.839.839 0 0 0 0 .844v.562c0 .466.373.844.833.844H3.26l2.439 12.074c-.584.34-.977.977-.977 1.707 0 1.088.87 1.969 1.945 1.969 1.074 0 1.944-.881 1.944-1.969 0-.55-.224-1.049-.584-1.406h7.28c-.36.357-.585.855-.585 1.406 0 1.088.87 1.969 1.945 1.969 1.074 0 1.944-.881 1.944-1.969 0-.78-.447-1.453-1.096-1.772l.191-.853a.841.841 0 0 0-.812-1.031h-9.32l-.228-1.125h10.179c.389 0 .726-.273.813-.657z"/>
</svg>

After

Width:  |  Height:  |  Size: 648 B

View File

@@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<g fill="none" fill-rule="evenodd">
<path d="M0 0h16v16H0z"/>
<path fill="#F4704C" d="M13.85 5.928h-1.234v-1.54c0-2.338-2.026-4.234-4.525-4.234-2.5 0-4.526 1.896-4.526 4.235v1.54H2.33c-.682 0-1.235.516-1.235 1.154v7.7c0 .637.553 1.154 1.235 1.154h11.52c.681 0 1.234-.517 1.234-1.154v-7.7c0-.638-.553-1.155-1.234-1.155zM4.8 4.388c0-1.7 1.473-3.08 3.29-3.08 1.818 0 3.292 1.38 3.292 3.08v1.54H4.799v-1.54z"/>
<path fill="#FFF" d="M8.296 13.23c1.243 0 2.25-.942 2.25-2.105 0-1.162-1.007-2.105-2.25-2.105-1.242 0-2.25.943-2.25 2.105.003 1.162 1.009 2.103 2.25 2.106zm0-3.211c.654 0 1.183.495 1.183 1.106 0 .612-.53 1.107-1.183 1.107s-1.183-.495-1.183-1.107c0-.61.53-1.106 1.183-1.106z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 812 B

View File

@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16">
<defs>
<path id="a" d="M15 15.2a.79.79 0 0 1-.778.8H1.778A.79.79 0 0 1 1 15.2v-2.4c0-2.21 1.741-4 3.889-4h6.222c2.148 0 3.889 1.79 3.889 4v2.4zM8 8C5.852 8 4.111 6.21 4.111 4S5.852 0 8 0c2.148 0 3.889 1.79 3.889 4S10.148 8 8 8z"/>
</defs>
<use fill="#F4704C" fill-rule="nonzero" xlink:href="#a"/>
</svg>

After

Width:  |  Height:  |  Size: 451 B

View File

@@ -60,7 +60,6 @@ body.embedded {
vertical-align: top;
&.cart {
div.joyride-tip-guide { // Cart Dropdown
top: 75px;
overflow: visible;

View File

@@ -1,31 +0,0 @@
@import "variables";
nav.top-bar {
margin-bottom: 0px;
a.icon {
&:hover {
text-decoration: none;
}
height: $topbar-height;
color: white;
i {
font-size: 29px;
line-height: $topbar-height;
}
span {
font-size: 13px;
display: inline-block;
line-height: $topbar-height;
height: $topbar-height;
vertical-align: top;
}
}
}
body > section[role='main'] {
padding: 0px;
}

View File

@@ -4,102 +4,176 @@
@import "typography";
@import "variables";
nav {
nav.top-bar {
@include textpress;
text-shadow: none;
// Create center style for nav ul (foundation provides left and right)
text-align: center;
font-size: 16px;
margin-bottom: 0;
height: $topbar-height;
}
.top-bar-section {
// Avoid menu items blocking logo
li:not(.has-form), li:not(.has-form) a:not(.button), li:not(.has-form) a:not(.button):hover {
background-color: transparent;
.top-bar-section {
a.icon {
&:hover {
text-decoration: none;
}
ul.center {
> span {
display: inline-block;
// By default, we center between the left and right uls, but we want to be centered
// relative to the whole page. The difference in width between the other uls is 74px,
// so we offset by that amount here.
margin-left: -74px;
}
}
.joyride-tip-guide .button {
text-shadow: none;
}
// Default overrides - big menu
.top-bar-section .has-dropdown > a {
padding-right: ($topbar-height / 3) !important;
i.ofn-i_022-cog, .ofn-i_071-globe {
font-size: 24px;
font-weight: 300;
height: $topbar-height;
line-height: $topbar-height;
}
i.ofn-i_071-globe {
color: #666;
font-size: 27px
vertical-align: top;
}
}
.top-bar-section .has-dropdown > a:after {
display: none;
// Avoid menu items blocking logo
li:not(.has-form), li:not(.has-form) a:not(.button), li:not(.has-form) a:not(.button):hover {
background-color: transparent;
}
.top-bar-section ul li > a {
font-size: 0.75rem;
height: $topbar-height;
opacity: 0.8;
li.cart {
background-color: #f4704c;
&:hover, &:focus, &:active {
opacity: 1;
a span {
color: white;
}
@include transition(all 0.3s ease-in-out);
}
i {
color: white;
}
.top-bar-section ul li.ofn-logo > a {
display: table-cell;
vertical-align: middle;
opacity: 1;
}
.count {
position: relative;
.nav-branded {
color: $brand-colour;
img {
width: 32px;
height: 26px;
margin-top: 16px;
margin-right: 5px;
}
span {
font-size: 13px;
span {
background-color: white;
border-radius: 20px;
color: #f4704c;
font-size: 12px;
line-height: 18px;
position: absolute;
right: -8px;
top: 8px;
width: 18px;
}
}
}
.nav-primary {
@include headingFont;
ul.center {
display: inline-block;
font-size: 0.875rem;
font-weight: 300;
}
ul .nav-primary {
text-transform: uppercase;
// By default, we center between the left and right uls, but we want to be centered
// relative to the whole page. The difference in width between the other uls is 74px,
// so we offset by that amount here.
margin-left: -74px;
}
ul.dropdown {
border: 1px solid $smoke;
border-top: none;
}
ul.right {
> li {
border-left: 1px solid #ddd;
padding: 0 14px;
@media screen and (max-width: 1450px) {
padding: 0 6px;
}
}
li > a {
opacity: 0.8;
&:hover, &:focus, &:active {
opacity: 1;
}
i {
color: #f4704c;
display: inline-block;
margin-right: 2px;
margin-top: -3px;
vertical-align: middle;
}
img {
margin-right: 2px;
margin-top: -5px;
}
}
}
ul li > a {
font-size: 16px;
height: $topbar-height;
}
ul li.ofn-logo > a {
display: table-cell;
vertical-align: middle;
}
ul .nav-primary {
@include headingFont;
text-transform: uppercase;
font-weight: 300;
font-size: 16px;
}
.joyride-tip-guide .button {
text-shadow: none;
}
}
// Mobile Menu
.tab-bar {
background-color: white;
.cart-span {
background-color: #f4704c;
padding: 13px;
a, span {
color: white;
}
.count {
position: relative;
img {
margin-left: 2px;
width: 26px;
}
span {
background-color: white;
border-radius: 20px;
color: #f4704c;
font-size: 12px;
line-height: 16px;
position: absolute;
right: -10px;
text-align: center;
top: -9px;
width: 16px;
}
}
}
}
.off-canvas-list li.language-switcher ul li {
list-style-type: none;
padding-left: 0.5em;
@@ -114,8 +188,6 @@ nav {
}
.off-canvas-wrap.move-right .tab-bar .menu-icon span {
-moz-box-shadow: 0 0px 0 1px #666, 0 7px 0 1px #666, 0 14px 0 1px #666;
-webkit-box-shadow: 0 0px 0 1px #666, 0 7px 0 1px #666, 0 14px 0 1px #666;
box-shadow: 0 0px 0 1px #666, 0 7px 0 1px #666, 0 14px 0 1px #666;
}
@@ -194,10 +266,4 @@ nav {
// padding required to placehold for fixed menu bar
padding-top: 0;
}
section.right {
.nav-branded {
padding: 0 1em;
}
}
}

View File

@@ -13,7 +13,7 @@
$brand-colour: #f27052;
// Topbar
$topbar-height: rem-calc(75);
$topbar-height: rem-calc(64);
$topbar-link-padding: $topbar-height / 3;
$topbar-bg: $white;

View File

@@ -1,71 +1,10 @@
%span.cart-span{"ng-controller" => "CartCtrl", "ng-class" => "{ dirty: Cart.dirty || Cart.empty(), 'pure-dirty': Cart.dirty }"}
%a#cart.icon{cart: true}
%span.nav-branded
%i.ofn-i_027-shopping-cart
%span
= t '.cart'
%span.count
%img{ src: "/assets/menu/icn-cart.svg" }
%span
{{ Cart.total_item_count() }}
= t 'cart_items'
.joyride-tip-guide{"ng-class" => "{ in: open }", "ng-show" => "open"}
%span.joyride-nub.top
.joyride-content-wrapper
%h5
= t 'cart_headline'
.buttons.text-right
%a.button.secondary.tiny.add_to_cart{ href: cart_path, type: :submit, "ng-disabled" => "Cart.dirty || Cart.empty()", "ng-class" => "{ dirty: Cart.dirty }" }
= "{{ Cart.dirty ? '#{t(:cart_updating)}' : (Cart.empty() ? '#{t(:cart_empty)}' : '#{t(:cart_edit)}' ) }}"
%a.button.primary.tiny{href: checkout_path, "ng-disabled" => "Cart.dirty || Cart.empty()"}
= t '.checkout'
%table
%tr.product-cart{"ng-repeat" => "line_item in Cart.line_items", "id" => "cart-variant-{{ line_item.variant.id }}"}
%td
%small
%strong
{{ line_item.variant.extended_name }}
%td.text-right
%small
%span.quantity {{ line_item.quantity }}
%i.ofn-i_009-close
%span.price {{ line_item.variant.price_with_fees | localizeCurrency }}
%td
%small
\=
%strong
.total-price.right {{ line_item.total_price | localizeCurrency }}
%table{"ng-show" => "Cart.line_items.length > 0"}
%tr.total-cart
%td
%em
= t 'total'
\:
%td.text-right
%strong {{ Cart.total() | localizeCurrency }}
.buttons.text-right
%a.button.secondary.tiny.add_to_cart{ href: cart_path, type: :submit, "ng-disabled" => "Cart.dirty || Cart.empty()", "ng-class" => "{ dirty: Cart.dirty }" }
= "{{ Cart.dirty ? '#{t(:cart_updating)}' : (Cart.empty() ? '#{t(:cart_empty)}' : '#{t(:cart_edit)}' ) }}"
%a.button.primary.tiny{href: checkout_path, "ng-disabled" => "Cart.dirty || Cart.empty()"}
= t '.checkout'
- if order_changes_allowed?
%h5{"ng-if" => "Cart.line_items_finalised.length", style: 'margin-top: 1em'}
= t '.already_ordered_products'
%table
%tr.product-cart{"ng-repeat" => "line_item in Cart.line_items_finalised",
"id" => "cart-variant-{{ line_item.variant.id }}"}
%td
%small
%strong
{{ line_item.variant.extended_name }}
%td.text-right
%small
%span.quantity {{ line_item.quantity }}
%i.ofn-i_009-close
%span.price {{ line_item.variant.price_with_fees | localizeCurrency }}
%td
%small
\=
%strong
.total-price.right {{ line_item.total_price | localizeCurrency }}
= render 'shared/menu/joyride'

View File

@@ -0,0 +1,63 @@
.joyride-tip-guide{"ng-class" => "{ in: open }", "ng-show" => "open"}
%span.joyride-nub.top
.joyride-content-wrapper
%h5
= t 'cart_headline'
.buttons.text-right
%a.button.secondary.tiny.add_to_cart{ href: cart_path, type: :submit, "ng-disabled" => "Cart.dirty || Cart.empty()", "ng-class" => "{ dirty: Cart.dirty }" }
= "{{ Cart.dirty ? '#{t(:cart_updating)}' : (Cart.empty() ? '#{t(:cart_empty)}' : '#{t(:cart_edit)}' ) }}"
%a.button.primary.tiny{href: checkout_path, "ng-disabled" => "Cart.dirty || Cart.empty()"}
= t '.checkout'
%table
%tr.product-cart{"ng-repeat" => "line_item in Cart.line_items", "id" => "cart-variant-{{ line_item.variant.id }}"}
%td
%small
%strong
{{ line_item.variant.extended_name }}
%td.text-right
%small
%span.quantity {{ line_item.quantity }}
%i.ofn-i_009-close
%span.price {{ line_item.variant.price_with_fees | localizeCurrency }}
%td
%small
\=
%strong
.total-price.right {{ line_item.total_price | localizeCurrency }}
%table{"ng-show" => "Cart.line_items.length > 0"}
%tr.total-cart
%td
%em
= t 'total'
\:
%td.text-right
%strong {{ Cart.total() | localizeCurrency }}
.buttons.text-right
%a.button.secondary.tiny.add_to_cart{ href: cart_path, type: :submit, "ng-disabled" => "Cart.dirty || Cart.empty()", "ng-class" => "{ dirty: Cart.dirty }" }
= "{{ Cart.dirty ? '#{t(:cart_updating)}' : (Cart.empty() ? '#{t(:cart_empty)}' : '#{t(:cart_edit)}' ) }}"
%a.button.primary.tiny{href: checkout_path, "ng-disabled" => "Cart.dirty || Cart.empty()"}
= t '.checkout'
- if order_changes_allowed?
%h5{"ng-if" => "Cart.line_items_finalised.length", style: 'margin-top: 1em'}
= t '.already_ordered_products'
%table
%tr.product-cart{"ng-repeat" => "line_item in Cart.line_items_finalised",
"id" => "cart-variant-{{ line_item.variant.id }}"}
%td
%small
%strong
{{ line_item.variant.extended_name }}
%td.text-right
%small
%span.quantity {{ line_item.quantity }}
%i.ofn-i_009-close
%span.price {{ line_item.variant.price_with_fees | localizeCurrency }}
%td
%small
\=
%strong
.total-price.right {{ line_item.total_price | localizeCurrency }}

View File

@@ -0,0 +1,8 @@
%li.language-switcher.has-dropdown
%a{href: '#'}
%i.ofn-i_071-globe
%span= t 'language_name'
%ul.dropdown
- OpenFoodNetwork::I18nConfig.selectable_locales.each do |l|
%li
%a{href: "?locale=#{l.to_s}" }= t('language_name', locale: l)

View File

@@ -18,24 +18,19 @@
%a{href: t("#{menu_name}_url") }
%span.nav-primary
= t "#{menu_name}_title"
%ul.right
%ul.menu.icons.right
- if OpenFoodNetwork::I18nConfig.selectable_locales.count > 1
%li.language-switcher.has-dropdown
%a{href: '#'}
%i.ofn-i_071-globe
%ul.dropdown
- OpenFoodNetwork::I18nConfig.selectable_locales.each do |l|
%li
%a{href: "?locale=#{l.to_s}" }= t('language_name', locale: l)
= render 'shared/menu/language_selector'
- if spree_current_user.nil?
= render 'shared/signed_out'
= render 'shared/menu/signed_out'
- else
= render 'shared/signed_in'
= render 'shared/menu/signed_in'
%li.current_hub{"ng-controller" => "CurrentHubCtrl", "ng-show" => "CurrentHub.hub.id", "ng-cloak" => true}
%a{href: main_app.shop_path}
%em
= t 'label_shopping'
&#64;
%span.nav-primary.nav-branded {{ CurrentHub.hub.name | truncate:25 }}
= t 'label_shopping'
= '@'
%span {{ CurrentHub.hub.name | truncate:25 }}
%li.cart{"ng-cloak" => true}
= render partial: "shared/menu/cart"

View File

@@ -9,8 +9,15 @@
%img{src: ContentConfig.logo_mobile.url, srcset: ContentConfig.logo_mobile_svg.url, width: "75", height: "26"}
%section.right{"ng-cloak" => true}
.cart
= render partial: "shared/menu/cart"
%span.cart-span{"ng-controller" => "CartCtrl", "ng-class" => "{ dirty: Cart.dirty || Cart.empty(), 'pure-dirty': Cart.dirty }"}
%a.icon{href: main_app.checkout_path}
%span
= t '.cart'
%span.count
%img{ src: "/assets/menu/icn-cart.svg" }
%span
{{ Cart.total_item_count() }}
%a{href: main_app.shop_path}
{{ CurrentHub.hub.name }}
@@ -39,6 +46,6 @@
%a{href: "?locale=#{l.to_s}" }= t('language_name', locale: l)
%li
- if spree_current_user.nil?
= render 'shared/signed_out'
= render 'shared/menu/signed_out'
- else
= render 'shared/signed_in_offcanvas'
= render 'shared/menu/signed_in_offcanvas'

View File

@@ -5,15 +5,17 @@
= t 'label_notices'
%li.user-menu.has-dropdown.not-click
%a{href: "#"}
%i.ofn-i_022-cog
%a{href: "#"}
%img{ src: "/assets/menu/icn-profile.svg" }
%span
= t '.profile'
%ul.dropdown
- if admin_user? or enterprise_user?
%li
%a{href: spree.admin_path, target:'_blank'}
%a{href: spree.admin_path, target:'_blank'}
%i.ofn-i_021-tools
= t 'label_administration'
@@ -22,8 +24,8 @@
%i.ofn-i_015-user
= t 'label_account'
= "(" + spree_current_user.email + ")"
%li
%a{title: t('label_logout'), href:'/logout' }
%a{title: t('label_logout'), href:'/logout' }
%i.ofn-i_018-unlocked
= t 'label_logout'

View File

@@ -7,7 +7,7 @@
- if admin_user? or enterprise_user?
%li
%a{href: spree.admin_path, target:'_blank'}
%a{href: spree.admin_path, target:'_blank'}
%i.ofn-i_021-tools
= t 'label_admin'
@@ -17,6 +17,6 @@
= t 'label_account'
%li
%a{title: t('label_logout'), href:'/logout' }
%a{title: t('label_logout'), href:'/logout' }
%i.ofn-i_018-unlocked
= t 'label_logout'

View File

@@ -1,5 +1,5 @@
%li#login-link
%a{"auth" => "login"}
%i.ofn-i_017-locked
%img{ src: "/assets/menu/icn-login.svg" }
%span
= t 'label_login'

View File

@@ -1111,6 +1111,12 @@ en:
shared:
menu:
cart:
cart: "Cart"
signed_in:
profile: "Profile"
mobile_menu:
cart: "Cart"
joyride:
checkout: "Checkout now"
already_ordered_products: "Already ordered in this order cycle"
register_call:

View File

@@ -130,7 +130,7 @@ feature "As a consumer I want to shop with a distributor", js: true do
select "frogs", from: "order_cycle_id"
show_cart
page.should have_selector "tr.product-cart"
page.should have_selector 'li.cart', text: '1 item'
page.should have_selector 'li.cart', text: '1'
# The order cycle choice should not have changed
page.should have_select 'order_cycle_id', selected: 'turtles'
@@ -154,14 +154,14 @@ feature "As a consumer I want to shop with a distributor", js: true do
expect(page).to have_content "Next order closing in 2 days"
visit shop_path
find("#cart").click
expect(page).to have_text(I18n.t("shared.menu.cart.already_ordered_products"))
expect(page).to have_text(I18n.t("shared.menu.joyride.already_ordered_products"))
end
it "shows previous orders after selecting an order cycle" do
select "frogs", from: "order_cycle_id"
expect(page).to have_content "Next order closing in 2 days"
find("#cart").click
expect(page).to have_text(I18n.t("shared.menu.cart.already_ordered_products"))
expect(page).to have_text(I18n.t("shared.menu.joyride.already_ordered_products"))
end
end
end