Skip to content

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

Add Select2

Paweł Kowalewski0c6bf5c7e8e0
diff --git a/Gruntfile.js b/Gruntfile.js
index cc22736ce0..56c20f795d 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -144,6 +144,7 @@ module.exports = function(grunt) {
"saleor/static/components/jquery/dist/jquery.js",
"saleor/static/components/materialize/dist/js/materialize.js",
"saleor/static/components/Sortable/Sortable.js",
+ "saleor/static/components/select2/dist/js/select2.js",
"saleor/static/js_src/dashboard.js"
]
}
diff --git a/bower.json b/bower.json
index 8e443c38e6..c8a315351e 100644
--- a/bower.json
+++ b/bower.json
@@ -13,6 +13,7 @@
"zocial-less": "~1.0.0",
"materialize": "~0.97.0",
"jquery": "~2.1.4",
- "Sortable": "[email protected]:RubaXa/Sortable.git#~1.2.0"
+ "Sortable": "[email protected]:RubaXa/Sortable.git#~1.2.0",
+ "select2": "~4.0.0"
}
}
diff --git a/saleor/static/js_src/dashboard.js b/saleor/static/js_src/dashboard.js
index ebfff39e0a..5a31b25251 100644
--- a/saleor/static/js_src/dashboard.js
+++ b/saleor/static/js_src/dashboard.js
@@ -1,6 +1,6 @@
$('.button-collapse').sideNav();
$('select:not(.browser-default):not([multiple])').material_select();
-$('select[multiple]').addClass('browser-default');
+$('select[multiple]').addClass('browser-default').select2();
$('.modal-trigger').leanModal();
$('ul.tabs').find('.tab').on('click', function(e) {
window.history.pushState(null, null, e.target.hash);
diff --git a/saleor/static/scss/_app.scss b/saleor/static/scss/_app.scss
index be3d9da041..53b8754b89 100644
--- a/saleor/static/scss/_app.scss
+++ b/saleor/static/scss/_app.scss
@@ -29,11 +29,7 @@ $font-size-action-icon: 18px;
@font-face {font-family: "HurmeGeometricSans4-Black";src: url("#{$roboto-font-path}2C8496_1_0.eot");src: url("#{$roboto-font-path}2C8496_1_0.eot?#iefix") format("embedded-opentype"),url("#{$roboto-font-path}2C8496_1_0.woff2") format("woff2"),url("#{$roboto-font-path}2C8496_1_0.woff") format("woff"),url("#{$roboto-font-path}2C8496_1_0.ttf") format("truetype");}
@import "materialize/sass/materialize";
-@each $mdi-icon-name, $mdi-icon-value in $mdi-list-icons {
- .#{$mdi-prefix}#{$mdi-icon-name}:before {
- content: "\"" + $mdi-icon-value + "\"";
- }
-}
+@import "select2/src/scss/core";
.header {
@media (min-width: $large-screen-up) {
@@ -228,4 +224,5 @@ table {
@import "widget/form";
@import "widget/product-gallery";
@import "widget/product-list";
+@import "widget/select2";
@import "widget/toast";
diff --git a/saleor/static/scss/widget/_select2.scss b/saleor/static/scss/widget/_select2.scss
new file mode 100644
index 0000000000..63fe21de14
--- /dev/null
+++ b/saleor/static/scss/widget/_select2.scss
@@ -0,0 +1,47 @@
+@mixin select2 {
+ margin-bottom: 15px;
+
+ &--default, &--default.select2-container--focus {
+ .select2-selection--multiple {
+ border: none;
+ border-bottom: 1px solid $input-border-color;
+ border-radius: 0;
+ line-height: 3rem;
+
+ .select2-selection__rendered {
+ padding: 0;
+ vertical-align: middle;
+ }
+
+ .select2-selection__choice {
+ line-height: 1.5;
+ margin-top: 10px;
+ }
+ }
+
+ .select2-search--inline {
+ .select2-search__field {
+ height: auto;
+ margin: 0;
+
+ &:focus {
+ border-bottom: none;
+ box-shadow: none;
+ }
+ }
+ }
+ }
+
+ &--default.select2-container--open {
+ @extend .z-depth-1;
+ }
+
+ .select2-dropdown {
+ @extend .z-depth-1;
+ border: none;
+ }
+}
+
+.select2-container {
+ @include select2;
+}