Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add styles to variant image select
Krzysztof Białogłowicz7840c210a161
diff --git a/saleor/static/dashboard/js/dashboard.js b/saleor/static/dashboard/js/dashboard.jsindex 98c46acd5c..4c3611aff5 100644--- a/saleor/static/dashboard/js/dashboard.js+++ b/saleor/static/dashboard/js/dashboard.js@@ -34,6 +34,13 @@ function openModal() {$modal.html(response);initSelects();$modal.modal();+ // Image checkbox selector+ $('.image_select-item-overlay').on('click', function (e) {+ let id = $(e.target).attr('id');+ let checkbox = $('input#'+id).prop('checked');+ $('input#'+id).prop('checked', !checkbox);+ $(e.target).toggleClass('checked', !checkbox );+ });}});diff --git a/saleor/static/dashboard/scss/components/_form.scss b/saleor/static/dashboard/scss/components/_form.scssindex 571cc87cf1..bc8c295b77 100644--- a/saleor/static/dashboard/scss/components/_form.scss+++ b/saleor/static/dashboard/scss/components/_form.scss@@ -125,6 +125,51 @@}}+.image_select {+ padding: 0 10px;+ .row .col {+ padding: 5px;+ }+ &-item {+ width: 23%;+ margin-left: 1%;+ margin-top: 1%;+ float: left;+ position: relative;+ label {+ position: absolute;+ top: 10px;+ right: -5px;+ z-index: 999;+ }+ img {+ width: 100%;+ }+ &-overlay {+ position: absolute;+ cursor: pointer;+ width: 100%;+ height: 100%;+ background: $off-black;+ opacity: 0;+ top: 0;+ transition: opacity .3s;+ &:hover {+ opacity: 0.3;+ }+ &.checked {+ opacity: 0.3;+ }+ }+ }+ .filled-in + label:after {+ border-radius: 50%;+ }+ .filled-in:not(:checked) + label:after {+ border:none;+ }+}+.input-with-suffix {display: table-row;input {diff --git a/templates/dashboard/product/_variant_image_select.html b/templates/dashboard/product/_variant_image_select.htmlindex 70752789c1..193c2db6f1 100644--- a/templates/dashboard/product/_variant_image_select.html+++ b/templates/dashboard/product/_variant_image_select.html@@ -1,25 +1,18 @@{% load i18n %}-<div class="input input-field col">- {% if field.auto_id %}- <label class="control-label">- {{ field.label }}- {% if not field.field.required %}- {% trans "(optional)" context "Dashboard form labels" %}- {% endif %}- </label>- {% endif %}- {% for choice_with_image in choices_with_images %}- {% with choice=choice_with_image.0 image=choice_with_image.1 %}- <p>- <input id="{{ choice.id_for_label }}" name="{{ choice.name }}" class="filled-in" type="checkbox" value="{{ choice.choice_value }}" {% if choice.choice_value in choice.value %} checked="checked" {% endif %}>- <label for="{{ choice.id_for_label }}">- {{ choice.choice_label }}- <img class="responsive-img" src="{{ image.image.crop.120x120 }}" srcset="{{ image.image.crop.120x120 }} 1x" alt="">- </label>- </p>- {% endwith %}- {% endfor %}+<div class="image_select">+ <div class="row">+ {% for choice_with_image in choices_with_images %}+ {% with choice=choice_with_image.0 image=choice_with_image.1 %}+ <div class="image_select-item">+ <input id="{{ choice.id_for_label }}" name="{{ choice.name }}" class="filled-in" type="checkbox" value="{{ choice.choice_value }}" {% if choice.choice_value in choice.value %} checked="checked" {% endif %}>+ <label for="{{ choice.id_for_label }}"></label>+ <img id="{{ choice.id_for_label }}" class="responsive-img" src="{{ image.image.crop.200x200 }}" srcset="{{ image.image.crop.200x200 }} 1x" alt="">+ <div id="{{ choice.id_for_label }}" class="image_select-item-overlay {% if choice.choice_value in choice.value %}checked{% endif %}"></div>+ </div>+ {% endwith %}+ {% endfor %}+ </div>{% for error in field.errors %}<p class="help-block materialize-red-text">{{ error }}</p>{% endfor %}