Skip to content

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

Add styles for shopping cart page

weronka96a5b43372ca
diff --git a/saleor/static/img/icon_delete.svg b/saleor/static/img/icon_delete.svg
new file mode 100644
index 0000000000..424cce7660
--- /dev/null
+++ b/saleor/static/img/icon_delete.svg
@@ -0,0 +1,24 @@
+<svg width="15" height="22" viewBox="0 0 15 22" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:figma="http://www.figma.com/figma/ns">
+<title>icon_trash_01</title>
+<desc>Created using Figma</desc>
+<g id="Canvas" transform="translate(-3786 1358)" figma:type="canvas">
+<g id="icon_trash_01" style="mix-blend-mode:normal;" figma:type="frame">
+<g id="Vector" style="mix-blend-mode:normal;" figma:type="vector">
+<use xlink:href="#path0_fill" transform="translate(3786.5 -1354.98)" fill="#828282" style="mix-blend-mode:normal;"/>
+</g>
+<g id="Group" style="mix-blend-mode:normal;" figma:type="frame">
+<g id="Vector" style="mix-blend-mode:normal;" figma:type="vector">
+<use xlink:href="#path1_fill" transform="translate(3790.15 -1357.28)" fill="#828282" style="mix-blend-mode:normal;"/>
+</g>
+</g>
+<g id="Vector" style="mix-blend-mode:normal;" figma:type="vector">
+<use xlink:href="#path2_fill" transform="translate(3787.04 -1352.31)" fill="#828282" style="mix-blend-mode:normal;"/>
+</g>
+</g>
+</g>
+<defs>
+<path id="path0_fill" d="M 14 0L 0 0L 0 2.03664L 14 2.03664L 14 0Z"/>
+<path id="path1_fill" d="M 6.70048 3.56383L 5.7447 3.56383L 5.7447 2.03664C 5.7447 1.10638 5.00897 1.02246 4.78336 1.01891L 1.91379 1.01891C 1.03914 1.01891 0.96134 1.80142 0.956894 2.04019L 0.956894 3.56383L -5.51143e-08 3.56383L -5.51143e-08 2.03664C -5.51143e-08 1.21868 0.50901 -1.91637e-08 1.91379 -1.91637e-08L 4.7867 -1.91637e-08C 5.55577 -1.91637e-08 6.70048 0.541371 6.70048 2.03664L 6.70048 3.56383Z"/>
+<path id="path2_fill" d="M 2.62853e-07 -1.80364e-08L 2.62853e-07 14.8913C 2.62853e-07 14.8913 1.32486e-07 16.0366 1.07692 16.0366L 11.8462 16.0366C 11.8462 16.0366 12.9231 16.0366 12.9231 14.8913L 12.9231 -1.80364e-08L 2.62853e-07 -1.80364e-08ZM 3.51417 13.9362C 3.51417 14.253 3.24966 14.5083 2.92403 14.5083C 2.5984 14.5083 2.33389 14.2518 2.33389 13.9362L 2.33389 2.10047C 2.33389 1.78369 2.5984 1.52719 2.92403 1.52719C 3.24966 1.52719 3.51417 1.78369 3.51417 2.10047L 3.51417 13.9362ZM 7.05057 13.9362C 7.05057 14.253 6.78717 14.5083 6.46154 14.5083C 6.13591 14.5083 5.87251 14.2518 5.87251 13.9362L 5.87251 2.10047C 5.87251 1.78369 6.13591 1.52719 6.46154 1.52719C 6.78717 1.52719 7.05057 1.78369 7.05057 2.10047L 7.05057 13.9362ZM 10.5903 13.9362C 10.5903 14.253 10.3258 14.5083 10.0024 14.5083C 9.67564 14.5083 9.41224 14.2518 9.41224 13.9362L 9.41224 2.10047C 9.41224 1.78369 9.67564 1.52719 10.0024 1.52719C 10.3258 1.52719 10.5903 1.78369 10.5903 2.10047L 10.5903 13.9362Z"/>
+</defs>
+</svg>
diff --git a/saleor/static/scss/demo/components/_cart.scss b/saleor/static/scss/demo/components/_cart.scss
new file mode 100644
index 0000000000..05263a9993
--- /dev/null
+++ b/saleor/static/scss/demo/components/_cart.scss
@@ -0,0 +1,43 @@
+.cart {
+ .col-md-2 {
+ text-align: right;
+ }
+ &__table-header {
+ color: $gray;
+ border-bottom: 1px solid $light-gray;
+ padding-bottom: $global-padding / 2;
+ }
+ &__line {
+ padding: $global-padding / 2 0;
+ &:not(:nth-last-of-type(2)) {
+ border-bottom: 1px solid $light-gray;
+ }
+ .col-md-2 {
+ margin-top: $global-margin;
+ }
+ &__product {
+ a {
+ transition: 0.3s;
+ color: $body-color;
+ &:hover {
+ text-decoration: none;
+ color: rgba($body-color, 0.6);
+ }
+ h3 {
+ display: inline;
+ }
+ }
+ }
+ }
+ &__total {
+ border-top: 1px solid $gray;
+ padding-top: $global-padding;
+ margin-bottom: $global-margin;
+ p {
+ color: $gray;
+ }
+ h3 {
+ margin-bottom: 0;
+ }
+ }
+}
\ No newline at end of file
diff --git a/saleor/static/scss/demo/components/_header.scss b/saleor/static/scss/demo/components/_header.scss
index 1b9ddc2be7..fe4f8c63b2 100644
--- a/saleor/static/scss/demo/components/_header.scss
+++ b/saleor/static/scss/demo/components/_header.scss
@@ -64,7 +64,7 @@
ul {
border-bottom: 1px solid $gray;
margin-bottom: $global-margin;
- @include media-breakpoint-down(sm), &.no-border {
+ &.no-border {
border-bottom: 0;
margin-bottom: 0;
}
diff --git a/saleor/static/scss/demo/storefront.scss b/saleor/static/scss/demo/storefront.scss
index 3e9632c35c..375115f14f 100644
--- a/saleor/static/scss/demo/storefront.scss
+++ b/saleor/static/scss/demo/storefront.scss
@@ -7,4 +7,5 @@
@import "components/breadcrumbs";
@import "components/footer";
@import "components/home";
-@import "components/product-page";
\ No newline at end of file
+@import "components/product-page";
+@import "components/cart";
\ No newline at end of file
diff --git a/saleor/static/scss/demo/variables.scss b/saleor/static/scss/demo/variables.scss
index cb81832f35..fa50578d3a 100644
--- a/saleor/static/scss/demo/variables.scss
+++ b/saleor/static/scss/demo/variables.scss
@@ -12,6 +12,7 @@ $global-margin: 1rem;
// COLORS
$gray: #C4C4C4;
+ $light-gray: #efefef;
$white: #fff;
$body-color: #333333;
$red: #EB5757;
diff --git a/templates/demo/cart/index.html b/templates/demo/cart/index.html
index a06b1b0b0e..baf4bdc1d3 100644
--- a/templates/demo/cart/index.html
+++ b/templates/demo/cart/index.html
@@ -7,105 +7,107 @@
{% block title %}{% trans "Your cart" %} — {{ block.super }}{% endblock %}
{% block breadcrumb %}
- {{ block.super }}
-<li><a href="{% url 'cart:index' %}">{% trans "Cart" %}</a></li>
+<ul class="breadcrumbs list-unstyled">
+ <li><a href="/">{% trans "Home" %}</a></li>
+ <li><a href="{% url 'cart:index' %}">{% trans "Cart" %}</a></li>
+</ul>
{% endblock breadcrumb %}
-{% block stylesheet %}
- {{ block.super }}
- {% render_bundle 'cart' 'css' %}
-{% endblock stylesheet %}
-
{% block footer_scripts %}
{{ block.super }}
{% render_bundle 'cart' 'js' %}
{% endblock footer_scripts %}
{% block content %}
-{% if cart_lines %}
- <table class="table table-striped cart" id="cart-items">
- <thead>
- <tr>
- <th class="col-xs-5 col-sm-2 col-md-1">{% trans "Product" %}</th>
- <th class="col-sm-5 hidden-xs"></th>
- <th class="col-xs-6 col-sm-3 col-md-2">{% trans "Quantity" %}</th>
- <th class="col-sm-1 hidden-xs text-right">{% trans "Price" %}</th>
- <th class="col-xs-1 text-right">{% trans "Subtotal" %}</th>
- </tr>
- </thead>
- <tfoot>
- <tr>
- <td class="hidden-xs" colspan="2"></td>
- <td class="col-xs-9 col-md-9 text-right lead" colspan="2">{% trans "Total" %}:
- <td class="col-xs-3 col-md-2 text-right lead">
- <span class="cart-total" 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">
- &asymp;
- {% gross local_cart_total html=True %}
- </small>
- {% endif %}
- {% endspaceless %}
- </span>
- </td>
- </tr>
- </tfoot>
- <tbody>
- {% for line in cart_lines %}
- <tr class="cart-item">
- <td class="hidden-xs">
- <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.100x100 }}" alt="">
- {% else %}
- <img class="cart-item-image" src="{% static 'images/product-image-placeholder-small.png' %}" alt="">
- {% endif %}
- </a>
- </td>
- <td>
- <a href="{{ line.variant.get_absolute_url }}">
- {{ line.variant.product }} - {{ line.variant.display_variant }}
- </a>
- </td>
- <td>
- <div class="cart-item-amount">
- <form role="form" action="{% url "cart:update-line" variant_id=line.variant.pk %}" method="post" class="form-cart">
- <div class="input-group cart-item-quantity js-hidden{% if form.quantity.errors %} has-error{% endif %}">
- {{ line.form.quantity }}
- <span class="input-group-btn">
- <button class="btn btn-info" type="submit">{% trans "Update" %}</button>
- </span>
- </div>
- {% if line.form.quantity.errors %}
- {% for error in form.quantity.errors %}
- <span class="text-danger">{{ error }}</span>
- {% endfor %}
- {% endif %}
- {% csrf_token %}
- </form>
-
- <button type="submit" class="btn btn-link btn-sm cart-item-remove">
- <span class="text-muted">{% trans "Remove from cart" %}</span>
- </button>
- </div>
- </td>
- <td class="text-right hidden-xs">{% gross line.get_price_per_item html=True %}</td>
- <td class="text-right cart-item-subtotal" data-product-id="{{ line.variant.pk }}">{% gross line.get_total html=True %}</td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- <div class="form-group">
- <div>
- <a href="{% url "checkout:index" %}" class="btn btn-primary btn-lg pull-right">{% trans "Proceed to checkout" %}</a>
+<div class="cart">
+ {% if cart_lines %}
+ <div class="cart__table-header">
+ <div class="row">
+ <div class="col-md-6">
+ <small>{% trans "Product" %}</small>
+ </div>
+ <div class="col-md-2">
+ <small>{% trans "Quantity" %}</small>
+ </div>
+ <div class="col-md-2">
+ <small>{% trans "Price" %}</small>
+ </div>
+ <div class="col-md-2">
+ <small>{% trans "Delete" %}</small>
</div>
+ </div>
+ </div>
+ {% for line in cart_lines %}
+ <div class="cart__line">
+ <div class="row">
+ <div class="col-md-6 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="">
+ {% else %}
+ <img class="cart-item-image" src="{% static 'images/product-image-placeholder-small.png' %}" alt="">
+ {% endif %}
+ <h3>{{ line.variant.product }} - {{ line.variant.display_variant }}</h3>
+ </a>
+ </div>
+ <div class="col-md-2 cart-item-amount">
+ <form role="form" action="{% url "cart:update-line" variant_id=line.variant.pk %}" method="post" class="form-cart">
+ <div class="input-group cart-item-quantity js-hidden{% if form.quantity.errors %} has-error{% endif %}">
+ {{ line.form.quantity }}
+ <span class="input-group-btn">
+ <button class="btn btn-info" type="submit">{% trans "Update" %}</button>
+ </span>
+ </div>
+ {% if line.form.quantity.errors %}
+ {% for error in form.quantity.errors %}
+ <span class="text-danger">{{ error }}</span>
+ {% endfor %}
+ {% endif %}
+ {% csrf_token %}
+ </form>
+ </div>
+ <div class="col-md-2">
+ <h3>{% gross line.get_total html=True %}</h3>
+ </div>
+ <div class="col-md-2">
+ <button type="submit" class="btn btn-link btn-sm cart-item-remove">
+ <img src="{% static "img/icon_delete.svg" %}">
+ </button>
+ </div>
+ </div>
+ </div>
+ {% endfor %}
+ <div class="cart__total">
+ <div class="row">
+ <div class="col-md-6">
+ <h3>{% trans "Subtotal" %}</h3>
+ <p>({% trans "Delivery claculated on checkout" %})</p>
+ </div>
+ <div class="col-md-2 offset-md-2">
+ <h3 class="cart-total" 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">
+ &asymp;
+ {% gross local_cart_total html=True %}
+ </small>
+ {% endif %}
+ {% endspaceless %}
+ </h3>
+ </div>
+ </div>
+ </div>
+ <div class="cart__checkout row">
+ <div class="col-md-12">
+ <a href="{% url "checkout:index" %}" class="btn primary float-md-right">{% trans "Checkout" %}</a>
+ </div>
</div>
-{% else %}
-<p>
- {% trans 'Your cart is empty' %}
-</p>
-{% endif %}
+ {% else %}
+ <p>
+ {% trans 'Your cart is empty' %}
+ </p>
+ {% endif %}
+ </div>
{% endblock content %}