Skip to content

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

Improve product page styles

weronkad4944cc72366
diff --git a/saleor/static/js/components/variantPicker/AttributeSelectionWidget.js b/saleor/static/js/components/variantPicker/AttributeSelectionWidget.js
index e3aac3e0e3..0484d4d9e5 100644
--- a/saleor/static/js/components/variantPicker/AttributeSelectionWidget.js
+++ b/saleor/static/js/components/variantPicker/AttributeSelectionWidget.js
@@ -17,7 +17,7 @@ export default class AttributeSelectionWidget extends Component {
const { attribute, selected } = this.props;
return (
<div className="product__variant-picker">
- <div>{attribute.display}: </div>
+ <div className="product__variant-picker__label">{attribute.display}</div>
<div className="btn-group" data-toggle="buttons">
{attribute.values.map((value, i) => {
const active = selected === value.pk.toString();
diff --git a/saleor/static/js/components/variantPicker/QuantityInput.js b/saleor/static/js/components/variantPicker/QuantityInput.js
index 6f5dcb70ec..70ddcb9383 100644
--- a/saleor/static/js/components/variantPicker/QuantityInput.js
+++ b/saleor/static/js/components/variantPicker/QuantityInput.js
@@ -13,11 +13,12 @@ export default class QuantityInput extends Component {
const { errors, quantity } = this.props;
const formGroupClasses = classNames({
'form-group': true,
- 'has-error': errors && !!errors.length
+ 'has-error': errors && !!errors.length,
+ 'product__info__quantity': true
});
return (
<div className={formGroupClasses}>
- <label className="control-label" htmlFor="id_quantity">Quantity</label>
+ <label className="control-label product__variant-picker__label" htmlFor="id_quantity">Quantity</label>
<input
className="form-control"
defaultValue={quantity}
diff --git a/saleor/static/js/components/variantPicker/VariantPicker.js b/saleor/static/js/components/variantPicker/VariantPicker.js
index 2cbd81fcdd..fe6dcdcf23 100644
--- a/saleor/static/js/components/variantPicker/VariantPicker.js
+++ b/saleor/static/js/components/variantPicker/VariantPicker.js
@@ -98,18 +98,20 @@ export default class VariantPicker extends Component {
selected={selection[attribute.pk]}
/>
)}
- <QuantityInput
- errors={errors.quantity}
- handleChange={this.handleQuantityChange}
- quantity={quantity}
- />
- <div className="form-group">
- <button
- className={addToCartBtnClasses}
- onClick={this.handleAddToCart}
- disabled={disableAddToCart}>
- Add to cart
- </button>
+ <div className="clearfix">
+ <QuantityInput
+ errors={errors.quantity}
+ handleChange={this.handleQuantityChange}
+ quantity={quantity}
+ />
+ <div className="form-group product__info__button">
+ <button
+ className={addToCartBtnClasses}
+ onClick={this.handleAddToCart}
+ disabled={disableAddToCart}>
+ Add to cart
+ </button>
+ </div>
</div>
</div>
);
diff --git a/saleor/static/js/storefront.js b/saleor/static/js/storefront.js
index f3f4f1e32e..5538020fb9 100644
--- a/saleor/static/js/storefront.js
+++ b/saleor/static/js/storefront.js
@@ -117,7 +117,7 @@ $(function() {
let summaryLink = '/cart/summary';
let $cartDropdown = $('.cart-dropdown');
let $cartIcon = $('.cart__icon');
-let $addToCartError = $('.product__info__form-error');
+let $addToCartError = $('.product__info__form-error small');
const onAddToCartSuccess = () => {
$.get(summaryLink, (data) => {
diff --git a/saleor/static/scss/storefront/components/_forms.scss b/saleor/static/scss/storefront/components/_forms.scss
index 140c4df430..da01bf85d7 100644
--- a/saleor/static/scss/storefront/components/_forms.scss
+++ b/saleor/static/scss/storefront/components/_forms.scss
@@ -1,7 +1,9 @@
.form-control {
color: $body-color;
+ border-radius: 2px;
&:focus {
color: $body-color;
+ border-color: $gray;
}
}
diff --git a/saleor/static/scss/storefront/components/_product-page.scss b/saleor/static/scss/storefront/components/_product-page.scss
index 69a5e35401..fad3ac7b09 100644
--- a/saleor/static/scss/storefront/components/_product-page.scss
+++ b/saleor/static/scss/storefront/components/_product-page.scss
@@ -4,18 +4,58 @@
text-decoration: underline;
}
&__info {
+ h3 {
+ text-transform: uppercase;
+ }
&__name {
- font-weight: 900;
- @include media-breakpoint-up(md) {
- margin-bottom: $global-margin;
- }
+ font-weight: 300;
}
&__price {
+ color: $skull-gray;
&__undiscounted {
- color: $gray;
text-decoration: line-through;
}
- margin-bottom: $global-margin * 2;
+ margin-bottom: $global-margin;
+ }
+ label {
+ margin-bottom: $global-margin;
+ }
+ &__quantity {
+ width: 17%;
+ float: left;
+ input {
+ height: 58px;
+ }
+ }
+ &__button {
+ width: 80%;
+ float: right;
+ margin-top: $global-margin * 2.5;
+ button {
+ min-width: 100%;
+ }
+ }
+ td {
+ padding-right: $global-padding;
+ }
+ &__form-error {
+ margin-top: -$global-padding / 2;
+ margin-bottom: $global-margin;
+ }
+ }
+ &__variant-picker {
+ margin-bottom: $global-margin;
+ &__label {
+ margin-bottom: $global-margin;
+ }
+ label {
+ margin-bottom: 0;
+ }
+ .btn-group {
+ display: block;
+ .btn {
+ margin-bottom: $global-margin / 4;
+ }
}
}
&__gallery {
diff --git a/templates/product/details.html b/templates/product/details.html
index 1c7ea8ee99..79b79e5ccf 100644
--- a/templates/product/details.html
+++ b/templates/product/details.html
@@ -30,35 +30,7 @@
{% endif %}
<div itemscope itemtype="http://schema.org/Product">
<div class="row product">
- <div class="col-12 col-md-7"></div>
- <div class="col-12 col-md-5">
- <h1 itemprop="name" class="product__info__name">
- {{ product }}
- </h1>
- {% if user.is_staff %}
- <p><a href="{% url "dashboard:product-update" pk=product.pk %}">{% trans "Edit in dashboard" %}</a></p>
- {% endif %}
- {% if availability.available %}
- {% if show_variant_picker %}
- <div id="variant-price-component"></div>
- {% else %}
- <h2 itemprop="offers" class="product__info__price" itemscope itemtype="http://schema.org/Offer">
- <span>{% price_range availability.price_range %}</span>
- {% if availability.discount %}
- <small class="product__info__price__undiscounted">{% gross availability.price_range_undiscounted.min_price html=True %}</small>
- {% endif %}
- {% if availability.price_range_local_currency %}
- <br>
- <small>
- &asymp;
- {% gross availability.price_range_local_currency.min_price html=True %}
- </small>
- {% endif %}
- </h2>
- {% endif %}
- {% endif %}
- </div>
- <div class="col-md-7 col-12 product__gallery">
+ <div class="col-md-6 col-12 product__gallery">
{% with images=product_images %}
{% if images %}
<div id="carousel-example-generic" class="carousel slide">
@@ -92,7 +64,32 @@
{% endif %}
{% endwith %}
</div>
- <div class="col-md-5 col-12 product__info">
+ <div class="col-md-6 col-12 product__info">
+ <h1 itemprop="name" class="product__info__name">
+ {{ product }}
+ </h1>
+ {% if user.is_staff %}
+ <p><a href="{% url "dashboard:product-update" pk=product.pk %}">{% trans "Edit in dashboard" %}</a></p>
+ {% endif %}
+ {% if availability.available %}
+ {% if show_variant_picker %}
+ <div id="variant-price-component"></div>
+ {% else %}
+ <h2 itemprop="offers" class="product__info__price" itemscope itemtype="http://schema.org/Offer">
+ <span>{% price_range availability.price_range %}</span>
+ {% if availability.discount %}
+ <small class="product__info__price__undiscounted">{% gross availability.price_range_undiscounted.min_price html=True %}</small>
+ {% endif %}
+ {% if availability.price_range_local_currency %}
+ <br>
+ <small>
+ &asymp;
+ {% gross availability.price_range_local_currency.min_price html=True %}
+ </small>
+ {% endif %}
+ </h2>
+ {% endif %}
+ {% endif %}
{% if is_visible and product.is_in_stock %}
{% block orderform %}
{% if show_variant_picker %}
@@ -103,8 +100,11 @@
action="{% url 'product:add-to-cart' product_id=product.pk slug=product.get_slug %}" novalidate>
{% csrf_token %}
{% bootstrap_field form.variant %}
- {% bootstrap_field form.quantity %}
- <div class="form-group">
+ <div class="product__info__quantity">
+ {% bootstrap_field form.quantity %}
+ </div>
+
+ <div class="form-group product__info__button">
<button class="btn primary">
{% trans "Add to cart" %}
</button>
@@ -112,21 +112,27 @@
</form>
{% endif %}
{% endblock %}
- <small class="product__info__form-error text-danger"></small>
+ <div class="product__info__form-error">
+ <small class="text-danger"></small>
+ </div>
+
{% else %}
<p class="alert alert-warning">{% trans "This product is currently <strong>unavailable</strong>." %}</p>
{% endif %}
- <hr>
- <div itemprop="product__info__description">
- <p><strong>{% trans "Description" %}</strong></p>
+ <div class="product__info__description" itemprop="description">
+ <h3>{% trans "Description" %}</h3>
+ <hr>
{{ product.description|markdown }}
</div>
<hr>
- <div>
- {% for attribute, value in product_attributes.items %}
- <div>{{ attribute }}: <strong>{{ value }}</strong></div>
- {% endfor %}
- </div>
+ <table>
+ {% for attribute, value in product_attributes.items %}
+ <tr>
+ <td>{{ attribute }}:</td>
+ <td><strong>{{ value }}</strong></td>
+ </tr>
+ {% endfor %}
+ </table>
</div>
</div>
</div>