Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Fix shopping cart styles

weronkafc85d5c71287
diff --git a/saleor/static/images/placeholder60x60.png b/saleor/static/images/placeholder60x60.png
new file mode 100644
index 0000000000..a2efcc0bf8
Binary files /dev/null and b/saleor/static/images/placeholder60x60.png differ
diff --git a/saleor/static/js/storefront.js b/saleor/static/js/storefront.js
index 241f978c7c..dcb63dac94 100644
--- a/saleor/static/js/storefront.js
+++ b/saleor/static/js/storefront.js
@@ -250,7 +250,7 @@ $cartLine.each(function() {
let $quantityInput = $(this).find('#id_quantity');
let cartFormUrl = $(this).find('.form-cart').attr('action');
let $qunatityError = $(this).find('.cart__line__quantity-error');
- let $subtotal = $(this).find('.cart-item-subtotal h3');
+ let $subtotal = $(this).find('.cart-item-subtotal p');
let $deleteIcon = $(this).find('.cart-item-delete');
$(this).on('change', $quantityInput, (e) => {
let newQuantity = $quantityInput.val();
diff --git a/saleor/static/scss/storefront/components/_cart.scss b/saleor/static/scss/storefront/components/_cart.scss
index 2c968c2a63..f277bffcb4 100644
--- a/saleor/static/scss/storefront/components/_cart.scss
+++ b/saleor/static/scss/storefront/components/_cart.scss
@@ -1,19 +1,26 @@
.cart {
- .col-md-2 {
- text-align: right;
+ h3 {
+ text-transform: uppercase;
+ color: $skull-gray;
}
&__table-header {
- color: $gray;
- border-bottom: 1px solid $light-gray;
+ border-bottom: 1px solid $gray;
padding-bottom: $global-padding / 2;
}
&__line {
padding: $global-padding / 2 0;
- &:not(:nth-last-of-type(2)) {
- border-bottom: 1px solid $light-gray;
+ border-bottom: 1px solid $gray;
+ &.last {
+ border-bottom-color: $skull-gray;
}
- .col-md-2 {
- margin-top: $global-margin;
+ .col-5 {
+ margin-top: $global-margin / 2;
+ @include media-breakpoint-down(sm) {
+ text-align: right;
+ p {
+ margin-top: $global-margin * 2;
+ }
+ }
}
&__product {
a {
@@ -21,70 +28,80 @@
color: $body-color;
&:hover {
text-decoration: none;
- color: rgba($body-color, 0.6);
+ color: $skull-gray;
}
- h3 {
+ p {
display: inline-block;
- margin-top: $global-margin;
+ margin-top: $global-margin / 2;
+ margin-bottom: 0;
+ line-height: 1rem;
small {
- color: $gray;
+ color: $skull-gray;
}
}
img {
vertical-align: top;
+ margin-right: $global-margin;
}
}
}
&__quantity {
- input {
- width: 4rem;
- padding: $global-padding / 2;
- &:focus {
- outline: none;
+ form {
+ display: inline-block;
+ input {
+ width: 4rem;
+ padding: $global-padding / 2;
+ &:focus {
+ outline: none;
+ }
}
}
+ &-error {
+ display: block;
+ }
+
}
.cart-item-delete {
cursor: pointer;
+ display: inline-block;
+ margin-left: $global-margin / 2;
}
}
&__total {
- border-top: 1px solid $gray;
padding-top: $global-padding;
margin-bottom: $global-margin;
p {
- color: $gray;
- }
- h3 {
margin-bottom: 0;
}
+ &__subtotal {
+ color: $skull-gray;
+ @include media-breakpoint-up(sm) {
+ padding-left: 5.75rem;
+ }
+ }
}
&__delivery-info {
margin-top: $global-margin * 2;
- h3 {
- display: inline-block;
- border-bottom: 1px solid $gray;
- padding-bottom: $global-padding
- }
- select {
- border-color: $gray;
- color: $body-color;
- margin-left: $global-margin / 2;
- background-color: $white;
- &:focus {
- outline: none;
- }
- @include media-breakpoint-down(sm) {
- margin-left: 0;
- margin-top: $global-margin / 2;
- display:block;
- width:100%;
- }
- }
- &__price {
- text-align: right;
- }
&__list {
+ border-top: 1px solid $gray;
+ .deliveryform {
+ padding: $global-padding 0;
+ width: 100%;
+ select {
+ background-color: $white;
+ height: calc(2.25rem + 2px);
+ @include media-breakpoint-up(sm) {
+ float: right;
+ }
+ &:focus {
+ outline: none;
+ }
+ }
+ label {
+ margin-right: $global-margin;
+ margin-top: $global-margin / 2;
+ }
+ }
.col-6 {
padding: 0;
}
diff --git a/saleor/static/scss/storefront/components/_forms.scss b/saleor/static/scss/storefront/components/_forms.scss
index da01bf85d7..ff1fd246bc 100644
--- a/saleor/static/scss/storefront/components/_forms.scss
+++ b/saleor/static/scss/storefront/components/_forms.scss
@@ -1,6 +1,7 @@
-.form-control {
+.form-control, select, input {
color: $body-color;
border-radius: 2px;
+ border: 1px solid $gray;
&:focus {
color: $body-color;
border-color: $gray;
diff --git a/templates/cart/index.html b/templates/cart/index.html
index 5b989a99ce..3cead05094 100644
--- a/templates/cart/index.html
+++ b/templates/cart/index.html
@@ -22,71 +22,70 @@
{% if cart_lines %}
<div class="cart__table-header hidden-sm-down">
<div class="row">
- <div class="col-md-6">
- <small>{% trans "Product" %}</small>
+ <div class="col-md-7">
+ <h3>{% trans "Product" %}</h3>
</div>
- <div class="col-md-2">
- <small>{% trans "Quantity" %}</small>
- </div>
- <div class="col-md-2">
- <small>{% trans "Price" %}</small>
+ <div class="col-md-3">
+ <h3>{% trans "Quantity" %}</h3>
</div>
<div class="col-md-2">
- <small>{% trans "Delete" %}</small>
+ <h3 class="text-right">{% trans "Price" %}</h3>
</div>
</div>
</div>
{% for line in cart_lines %}
- <div class="cart__line">
+ <div class="cart__line{% if forloop.last %} last{% endif %}">
<div class="row">
- <div class="col-md-6 col-9 cart__line__product">
+ <div class="col-7 cart__line__product">
<a href="{{ line.variant.get_absolute_url }}">
{% if line.variant.product.images.first %}
- <img class="cart-item-image" itemprop="image" src="{{ line.variant.product.images.first.image.crop.60x60 }}" alt="">
+ <img itemprop="image" src="{{ line.variant.product.images.first.image.crop.60x60 }}" alt="">
{% else %}
- <img class="cart-item-image" src="{% static 'images/product-image-placeholder-small.png' %}" alt="">
+ <img src="{% static 'images/placeholder60x60.png' %}" alt="">
{% endif %}
- <h3>{{ line.variant.product }}
- <br><small>{{ line.variant }}</small></h3>
+ <p>{{ line.variant.product }}
+ <br><small>{{ line.variant }}</small></p>
</a>
</div>
- <div class="cart__line__quantity col-md-2 col-3">
- <form role="form" action="{% url "cart:update-line" variant_id=line.variant.pk %}" method="post" class="form-cart" >
- <div class="{% if form.quantity.errors %} has-error{% endif %}" tabindex="-1">
- {{ line.form.quantity }}
- </div>
- {% csrf_token %}
- </form>
- <small class="cart__line__quantity-error text-danger"></small>
- </div>
- <div class="cart-item-subtotal col-md-2 col-8" data-product-id="{{ line.variant.pk }}">
- <h3 class="float-left float-sm-right">{% gross line.get_total html=True %}</h3>
- </div>
- <div class="col-md-2 col-4">
- <img class="cart-item-delete" src="{% static 'images/icon_delete.svg' %}">
+ <div class="col-5">
+ <div class="row">
+ <div class="cart__line__quantity col-md-7 col-12">
+ <form role="form" action="{% url "cart:update-line" variant_id=line.variant.pk %}" method="post" class="form-cart">
+ <div class="{% if form.quantity.errors %} has-error{% endif %}" tabindex="-1">
+ {{ line.form.quantity }}
+ </div>
+ {% csrf_token %}
+ </form>
+ <img class="cart-item-delete" src="{% static 'images/icon_delete.svg' %}">
+ <small class="cart__line__quantity-error text-danger"></small>
+ </div>
+ <div class="cart-item-subtotal col-md-5 col-12" data-product-id="{{ line.variant.pk }}">
+ <p class="text-right">{% gross line.get_total html=True %}</h3>
+ </div>
+ </div>
</div>
</div>
</div>
{% endfor %}
<div class="cart__total">
<div class="row">
- <div class="col-6">
+ <div class="col-9 cart__total__subtotal">
<h3>{% trans "Subtotal" %}</h3>
<p>({% trans "Delivery claculated on checkout" %})</p>
</div>
- <div class="col-md-2 offset-md-2 col-6">
- <h3 class="cart-total" data-value="{% gross cart_total %}"{% if local_cart_total %} data-value-local="{% gross local_cart_total %}"{% endif %}>
+ <div class="col-3">
+ <p class="cart-total text-right" data-value="{% gross cart_total %}"{% if local_cart_total %} data-value-local="{% gross local_cart_total %}"{% endif %}>
{% spaceless %}
{% gross cart_total html=True %}
{% if local_cart_total %}
<br>
- <small class="text-info">
+ <small>
&asymp;
{% gross local_cart_total html=True %}
</small>
{% endif %}
{% endspaceless %}
- </h3>
+ </p>
</div>
</div>
</div>
@@ -96,19 +95,20 @@
</div>
</div>
<div class="cart__delivery-info">
- <div class="deliveryform" data-csrf="{{ csrf_token }}">
- <h3>{% trans "Delivery options to" %} {{ country_form }}</h3>
- </div>
- <div class="col-md-5 ">
+ <h3><small>{% trans "Calculate shipping cost" %}</small></h3>
+ <div class="col-md-8 col-lg-6 col-xl-5">
<div class="cart__delivery-info__list row">
+ <div class="deliveryform" data-csrf="{{ csrf_token }}">
+ {{ country_form }}
+ </div>
<div class="col-6 cart__delivery-info__method">
{% for option in default_country_options %}
<p>{{ option.shipping_method__name }}</p>
{% endfor %}
</div>
- <div class="col-6 cart__delivery-info__price">
+ <div class="col-6">
{% for option in default_country_options %}
- <p>{% gross option.price %}</p>
+ <p class="text-right">{% gross option.price %}</p>
{% endfor %}
</div>
</div>