Skip to content

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

Add changing password visibility

Krzysztof Białogłowicz53aedb2aa580
diff --git a/saleor/static/images/pass-invisible.svg b/saleor/static/images/pass-invisible.svg
new file mode 100644
index 0000000000..454002a2d8
--- /dev/null
+++ b/saleor/static/images/pass-invisible.svg
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 20.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+ viewBox="0 0 16.8 12.6" style="enable-background:new 0 0 16.8 12.6;" xml:space="preserve">
+<style type="text/css">
+ .st0{fill:#333333;}
+</style>
+<path class="st0" d="M12.3,0.9C12.3,1,12.3,1,12.3,0.9c-0.7,1.3-1.7,3-3,5.4C8,8.7,7,10.5,6.3,11.6l-0.5,0.8
+ c-0.1,0.1-0.2,0.2-0.3,0.2c-0.1,0-0.5-0.2-1.3-0.7c-0.1-0.1-0.2-0.2-0.2-0.3c0-0.1,0.1-0.3,0.4-0.8c-0.9-0.4-1.7-0.9-2.5-1.6
+ C1.4,8.6,0.7,7.8,0.2,7C0.1,6.8,0,6.5,0,6.3s0.1-0.5,0.2-0.6c1-1.5,2.1-2.6,3.6-3.5c1.4-0.9,3-1.3,4.7-1.3C9,0.9,9.5,1,10.1,1.1
+ l0.5-0.9C10.7,0.1,10.8,0,10.9,0c0,0,0.1,0,0.2,0.1s0.2,0.1,0.3,0.1s0.2,0.1,0.3,0.2c0.1,0.1,0.2,0.1,0.3,0.2
+ c0.1,0.1,0.2,0.1,0.2,0.1C12.2,0.7,12.3,0.8,12.3,0.9z M5.2,9.8l0.7-1.3C5.4,8.1,5,7.6,4.7,7C4.4,6.4,4.2,5.8,4.2,5.1
+ c0-0.8,0.2-1.5,0.6-2.1C3.3,3.7,2.2,4.8,1.2,6.3C2.2,7.9,3.6,9.1,5.2,9.8z M8.7,3c0.1-0.1,0.1-0.2,0.1-0.3c0-0.1,0-0.2-0.1-0.3
+ C8.6,2.3,8.5,2.3,8.4,2.3c-0.8,0-1.5,0.3-2,0.8c-0.6,0.6-0.8,1.2-0.8,2c0,0.1,0,0.2,0.1,0.3C5.8,5.5,5.9,5.6,6,5.6
+ c0.1,0,0.2,0,0.3-0.1c0.1-0.1,0.1-0.2,0.1-0.3c0-0.5,0.2-1,0.6-1.4s0.8-0.6,1.4-0.6C8.5,3.2,8.6,3.1,8.7,3z M16.8,6.3
+ c0,0.2-0.1,0.4-0.2,0.6c-0.2,0.4-0.6,0.9-1,1.4c-0.9,1.1-2,1.9-3.3,2.5c-1.2,0.6-2.5,0.9-3.9,0.9l0.7-1.2c1.3-0.1,2.6-0.5,3.7-1.3
+ c1.1-0.7,2.1-1.7,2.8-2.9c-0.7-1.1-1.6-2-2.6-2.8l0.6-1.1c0.6,0.4,1.2,0.9,1.7,1.4c0.5,0.6,1,1.1,1.4,1.7
+ C16.8,5.9,16.8,6.1,16.8,6.3z M12.6,5.1c0,0.9-0.2,1.7-0.7,2.4c-0.5,0.7-1.1,1.2-2,1.5l2.6-4.7C12.6,4.6,12.6,4.9,12.6,5.1z"/>
+</svg>
diff --git a/saleor/static/images/pass-visible.svg b/saleor/static/images/pass-visible.svg
new file mode 100644
index 0000000000..7c71d26a51
--- /dev/null
+++ b/saleor/static/images/pass-visible.svg
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 20.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+ viewBox="0 0 16.8 10.8" style="enable-background:new 0 0 16.8 10.8;" xml:space="preserve">
+<style type="text/css">
+ .st0{fill:#333333;}
+</style>
+<path class="st0" d="M16.8,5.4c0,0.2-0.1,0.4-0.2,0.6c-0.9,1.4-2.1,2.6-3.5,3.5s-3,1.3-4.7,1.3c-1.6,0-3.2-0.4-4.7-1.3
+ c-1.5-0.9-2.7-2-3.5-3.5C0.1,5.8,0,5.6,0,5.4S0.1,5,0.2,4.8c0.9-1.4,2.1-2.6,3.5-3.5C5.2,0.4,6.8,0,8.4,0c1.6,0,3.2,0.4,4.7,1.3
+ c1.5,0.9,2.7,2,3.5,3.5C16.8,5,16.8,5.2,16.8,5.4z M15.6,5.4c-1-1.5-2.1-2.6-3.6-3.3c0.4,0.7,0.6,1.4,0.6,2.1c0,1.2-0.4,2.1-1.2,3
+ s-1.8,1.2-3,1.2c-1.2,0-2.1-0.4-3-1.2c-0.8-0.8-1.2-1.8-1.2-3c0-0.8,0.2-1.5,0.6-2.1C3.3,2.8,2.2,3.9,1.2,5.4C2,6.7,3.1,7.7,4.3,8.5
+ C5.6,9.2,7,9.6,8.4,9.6s2.8-0.4,4.1-1.1C13.8,7.7,14.8,6.7,15.6,5.4z M8.7,2.1C8.8,2,8.9,1.9,8.9,1.8c0-0.1,0-0.2-0.1-0.3
+ C8.6,1.4,8.5,1.4,8.4,1.4c-0.8,0-1.5,0.3-2,0.8c-0.6,0.6-0.8,1.2-0.8,2c0,0.1,0,0.2,0.1,0.3C5.8,4.6,5.9,4.7,6,4.7
+ c0.1,0,0.2,0,0.3-0.1c0.1-0.1,0.1-0.2,0.1-0.3c0-0.5,0.2-1,0.6-1.4s0.8-0.6,1.4-0.6C8.5,2.3,8.6,2.2,8.7,2.1z"/>
+</svg>
diff --git a/saleor/static/js/storefront.js b/saleor/static/js/storefront.js
index 707afdec8e..6b50e0b8c3 100644
--- a/saleor/static/js/storefront.js
+++ b/saleor/static/js/storefront.js
@@ -6,6 +6,9 @@ import Relay from 'react-relay';
import variantPickerStore from './stores/variantPicker';
+import passwordIvisible from '../images/pass-invisible.svg';
+import passwordVisible from '../images/pass-visible.svg';
+
import VariantPicker from './components/variantPicker/VariantPicker';
import VariantPrice from './components/variantPicker/VariantPrice';
@@ -112,6 +115,22 @@ $(function() {
});
});
+// Input Passwords
+
+let $inputPassword = $('input[type=password]');
+$("<img class='passIcon' src="+passwordIvisible+" />").insertAfter($inputPassword);
+$inputPassword.parent().addClass('relative');
+$('.passIcon').on('click', (e) => {
+ let $input = $(e.target).parent().find('input');
+ if ($input.attr('type') == 'password') {
+ $input.attr('type','text');
+ $(e.target).attr('src', passwordVisible);
+ } else {
+ $input.attr('type','password');
+ $(e.target).attr('src', passwordIvisible);
+ }
+});
+
// Cart dropdown
let summaryLink = '/cart/summary';
diff --git a/saleor/static/scss/storefront/components/_forms.scss b/saleor/static/scss/storefront/components/_forms.scss
index 140c4df430..25a8d0ceb9 100644
--- a/saleor/static/scss/storefront/components/_forms.scss
+++ b/saleor/static/scss/storefront/components/_forms.scss
@@ -24,3 +24,15 @@
margin-right: $global-margin;
}
}
+
+.relative {
+ position: relative;
+}
+
+.passIcon {
+ max-width: 15px;
+ position: absolute;
+ top: 2.8rem;
+ right: 0.5rem;
+ cursor: pointer;
+}