Skip to content

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

Add new styles to user profile, save tab links to URL

weronka055c3ac6cb08
diff --git a/saleor/static/js/storefront.js b/saleor/static/js/storefront.js
index 8604bbd094..4a60d6cf06 100644
--- a/saleor/static/js/storefront.js
+++ b/saleor/static/js/storefront.js
@@ -131,17 +131,17 @@ $countrySelect.on('change', (e) => {
})
})
+// Save tab links to URL
-const variantPicker = document.getElementById('variant-picker')
-if (variantPicker) {
- const variantPickerData = JSON.parse(variantPicker.dataset.variantPickerData)
- ReactDOM.render(
- <VariantPicker
- attributes={variantPickerData.attributes}
- url={variantPicker.dataset.action}
- variants={variantPickerData.variants}
- />,
- variantPicker
- )
+$('.nav-tabs a').click((e) => {
+ e.preventDefault();
+ $(this).tab('show');
+});
-}
+$("ul.nav-tabs li a").on("shown.bs.tab", (e) => {
+ var id = $(e.target).attr("href").substr(1);
+ window.location.hash = id;
+});
+
+var hash = window.location.hash;
+$('.nav-tabs a[href="' + hash + '"]').tab('show');
diff --git a/saleor/static/scss/storefront/components/_userprofile.scss b/saleor/static/scss/storefront/components/_userprofile.scss
index 1994d1124e..38a0cd5ffd 100644
--- a/saleor/static/scss/storefront/components/_userprofile.scss
+++ b/saleor/static/scss/storefront/components/_userprofile.scss
@@ -10,34 +10,41 @@
}
&__nav {
- background-color: $light-gray;
- padding: $global-padding 0;
- margin-bottom: $global-margin;
- .nav-link {
- color: $gray;
- border: 0;
- &:first-of-type {
- margin-right: $global-margin * 3;
+ margin: $global-margin * 2 0 $global-margin * 2;
+ .nav {
+ border-bottom: 0;
+ background-color: $light-gray;
+ }
+ .nav-item {
+ & + .nav-item {
+ margin-left: 0;
}
- &.active, &.active:hover, &.active:focus {
- background-color: transparent;
+ .nav-link {
+ padding: $global-padding $global-padding * 2;
border: 0;
- color: $body-color;
+ border-radius: 0;
+ transition: 0.3s;
+ &:hover, &.active {
+ background-color: $white;
+ }
+ h3 {
+ color: $body-color;
+ }
}
}
- ul {
- border-bottom: 0;
- }
}
&__address-empty {
margin: $global-margin 0 $global-margin * 2;
}
&__address-row {
- padding: $global-padding 0;
- border-bottom: 1px solid $light-gray;
- img {
- margin-left: $global-margin;
- float: right;
+ &__item {
+ border: 1px solid $light-gray;
+ padding: $global-padding;
+ img {
+ position: absolute;
+ top: 1rem;
+ right: 2rem;
+ }
}
}
.primary {
diff --git a/saleor/userprofile/views.py b/saleor/userprofile/views.py
index 10f2e77e9c..c3cde997c9 100755
--- a/saleor/userprofile/views.py
+++ b/saleor/userprofile/views.py
@@ -22,6 +22,6 @@ def address_delete(request, pk):
if request.method == 'POST':
address.delete()
messages.success(request, _('Address successfully deleted.'))
- return HttpResponseRedirect(reverse('profile:details'))
+ return HttpResponseRedirect(reverse('profile:details') + '#addresses')
return TemplateResponse(
request, 'userprofile/address-delete.html', {'address': address})
diff --git a/templates/userprofile/address-delete.html b/templates/userprofile/address-delete.html
index 5c3a9575c6..288c6a70ac 100644
--- a/templates/userprofile/address-delete.html
+++ b/templates/userprofile/address-delete.html
@@ -12,7 +12,7 @@
<div class="modal-footer">
<form method="post" novalidate action="{% url 'profile:address-delete' pk=address.pk %}">
{% csrf_token %}
- <a href="{% url 'profile:details' %}" class="btn btn-link">{% trans "Cancel" %}</a>
+ <a class="btn btn-link" data-dismiss="modal">{% trans "Cancel" %}</a>
<button type="submit" class="btn danger">{% trans "Delete" %}</button>
</form>
</div>
diff --git a/templates/userprofile/details.html b/templates/userprofile/details.html
index 9bf1deaf4d..02a9762ed2 100644
--- a/templates/userprofile/details.html
+++ b/templates/userprofile/details.html
@@ -11,17 +11,12 @@
{% block breadcrumb %}
<ul class="breadcrumbs list-unstyled">
<li><a href="/">{% trans "Home" %}</a></li>
- <li><a href="{% url 'profile:details' %}">{% trans "Your account" %}</a></li>
+ <li>{% trans "Your account" %} (<b>{{ user }}</b>)</li>
</ul>
{% endblock breadcrumb %}
{% block content %}
<div class="userprofile">
- <div class="row">
- <div class="col-lg-10 offset-lg-1 userprofile__user">
- <h2 class="float-xs-left">{{ user }}</h2>
- </div>
- </div>
<div class="userprofile__nav container">
<ul class="nav nav-tabs col-lg-10 offset-lg-1" role="tablist">
<li class="nav-item">
@@ -35,7 +30,6 @@
</li>
</ul>
</div>
- <div class="row">
<div class="tab-content col-lg-10 offset-lg-1">
<div class="tab-pane active" id="orders" role="tabpanel">
<div id="accordion" role="tablist" aria-multiselectable="true">
@@ -70,11 +64,11 @@
<div class="tab-pane" id="addresses" role="tabpanel">
{% for address in addresses %}
<div class="row userprofile__address-row">
- <div class="col-xs-6">
- {% include "userprofile/snippets/address-short.html" %}
- </div>
- <div class="col-md-2 col-xs-4">
- <a data-toggle="modal" data-target=".modal-address-delete"><img src="{% static 'img/icon_delete.svg' %}"></a>
+ <div class="col-md-4">
+ <div class="userprofile__address-row__item">
+ {% include "userprofile/snippets/address-short.html" %}
+ <a data-toggle="modal" data-target=".modal-address-delete"><img src="{% static 'img/icon_delete.svg' %}"></a>
+ </div>
</div>
</div>
{% include "userprofile/address-delete.html" with pk=address.pk %}
@@ -87,6 +81,5 @@
</div>
</div>
</div>
- </div>
{% endblock content %}