diff --git a/README.md b/README.md index 16154ec..34933f8 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ A vanilla, lightweight (~15kb gzipped 🎉), configurable select box/text input delimiter: ',', paste: true, search: true, + searchFloor: 1, flip: true, regexFilter: null, shouldSort: true, @@ -86,13 +87,13 @@ A vanilla, lightweight (~15kb gzipped 🎉), configurable select box/text input flippedState: 'is-flipped', loadingState: 'is-loading', }, - callbackOnInit: () => {}, - callbackOnAddItem: (id, value, passedInput) => {}, - callbackOnRemoveItem: (id, value, passedInput) => {}, - callbackOnHighlightItem: (id, value, passedInput) => {}, - callbackOnUnhighlightItem: (id, value, passedInput) => {}, - callbackOnChange: (value, passedInput) => {}, - callbackOnItemSearch: (value, fn, passedInput) => {}, + callbackOnInit: null, + callbackOnAddItem: null, + callbackOnRemoveItem: null, + callbackOnHighlightItem: null, + callbackOnUnhighlightItem: null, + callbackOnChange: null, + callbackOnSearch: null, }); ``` @@ -223,6 +224,13 @@ Pass an array of objects: **Usage:** Whether a user should be allowed to search avaiable choices. Note that multiple select boxes will always show search inputs. +### searchFloor +**Type:** `Number` **Default:** `1` + +**Input types affected:** `select-one`, `select-multiple` + +**Usage:** The minimum length a search value should be before choices are searched. + ### flip **Type:** `Boolean` **Default:** `true` @@ -361,42 +369,52 @@ classNames: { **Usage:** Classes added to HTML generated by Choices. By default classnames follow the [BEM](http://csswizardry.com/2013/01/mindbemding-getting-your-head-round-bem-syntax/) notation. ### callbackOnInit -**Type:** `Function` **Default:** `() => {}` +**Type:** `Function` **Default:** `null` **Input types affected:** `text`, `select-one`, `select-multiple` **Usage:** Function to run once Choices initialises. ### callbackOnAddItem -**Type:** `Function` **Default:** `(id, value, passedInput) => {}` +**Type:** `Function` **Default:** `null` **Arguments:** `id, value, passedInput` **Input types affected:** `text`, `select-one`, `select-multiple` **Usage:** Function to run each time an item is added (programmatically or by the user). +**Example:** + +```js +const example = new Choices(element, { + callbackOnAddItem: (id, value, passedInput) => { + // do something creative here... + }, +}; +``` + ### callbackOnRemoveItem -**Type:** `Function` **Default:** `(id, value, passedInput) => {}` +**Type:** `Function` **Default:** `null` **Arguments:** `id, value, passedInput` **Input types affected:** `text`, `select-one`, `select-multiple` **Usage:** Function to run each time an item is removed (programmatically or by the user). ### callbackOnHighlightItem -**Type:** `Function` **Default:** `(id, value, passedInput) => {}` +**Type:** `Function` **Default:** `null` **Arguments:** `id, value, passedInput` **Input types affected:** `text`, `select-multiple` **Usage:** Function to run each time an item is highlighted. ### callbackOnUnhighlightItem -**Type:** `Function` **Default:** `(id, value, passedInput) => {}` +**Type:** `Function` **Default:** `null` **Arguments:** `id, value, passedInput` **Input types affected:** `text`, `select-multiple` **Usage:** Function to run each time an item is unhighlighted. ### callbackOnChange -**Type:** `Function` **Default:** `(value, passedInput) => {}` +**Type:** `Function` **Default:** `null` **Arguments:** `value, passedInput` **Input types affected:** `text`, `select-one`, `select-multiple` diff --git a/assets/scripts/src/choices.js b/assets/scripts/src/choices.js index da43ff9..c765f07 100644 --- a/assets/scripts/src/choices.js +++ b/assets/scripts/src/choices.js @@ -57,6 +57,7 @@ export default class Choices { delimiter: ',', paste: true, search: true, + searchFloor: 1, flip: true, regexFilter: null, shouldSort: true, @@ -96,13 +97,13 @@ export default class Choices { flippedState: 'is-flipped', loadingState: 'is-loading', }, - callbackOnInit: () => {}, - callbackOnAddItem: (id, value, passedInput) => {}, - callbackOnRemoveItem: (id, value, passedInput) => {}, - callbackOnHighlightItem: (id, value, passedInput) => {}, - callbackOnUnhighlightItem: (id, value, passedInput) => {}, - callbackOnChange: (value, passedInput) => {}, - callbackOnItemSearch: null, + callbackOnInit: null, + callbackOnAddItem: null, + callbackOnRemoveItem: null, + callbackOnHighlightItem: null, + callbackOnUnhighlightItem: null, + callbackOnChange: null, + callbackOnSearch: null, }; // Merge options with user options @@ -162,8 +163,8 @@ export default class Choices { this.wasTap = true; // Cutting the mustard - const cuttingTheMustard = 'querySelector' in document && 'addEventListener' in document && 'classList' in document.createElement( - 'div'); + const cuttingTheMustard = 'querySelector' in document && 'addEventListener' in document + && 'classList' in document.createElement('div'); if (!cuttingTheMustard) console.error('Choices: Your browser doesn\'t support Choices'); // Input type check @@ -268,7 +269,6 @@ export default class Choices { if (this.passedElement.type === 'select-one') { return choice.groupId === group.id; } - return choice.groupId === group.id && !choice.selected; }); @@ -834,7 +834,8 @@ export default class Choices { if (this.passedElement.type === 'select-one' || this.passedElement.type === 'select-multiple') { // Show loading text this._handleLoadingState(); - fn(this._getAjaxCallback()); + // Run callback + fn(this._ajaxCallback()); } } return this; @@ -1068,17 +1069,19 @@ export default class Choices { /** * Retrieve the callback used to populate component's choices in an async way. - * @returns {function(*=, *=, *)} the callback as a function. + * @returns {Function} The callback as a function. * @private */ - _getAjaxCallback() { + _ajaxCallback() { return (results, value, label) => { - if (!isType('Array', results) || !value) return; - if (results && results.length) { + if (!results || !value) return; + const parsedResults = isType('Object', results) ? [results] : results; + + if (parsedResults && isType('Array', parsedResults) && parsedResults.length) { // Remove loading states/text this._handleLoadingState(false); // Add each result as a choice - results.forEach((result) => { + parsedResults.forEach((result) => { this._addChoice(false, false, result[value], result[label]); }); } @@ -1092,7 +1095,7 @@ export default class Choices { * @return * @private */ - _filterChoices(value) { + _searchChoices(value) { const newValue = isType('String', value) ? value.trim() : value; const currentValue = isType('String', this.currentValue) ? this.currentValue.trim() : this.currentValue; @@ -1122,35 +1125,28 @@ export default class Choices { */ _handleSearch(value) { if (!value) return; + const choices = this.store.getChoices(); + const hasUnactiveChoices = choices.some((option) => option.active !== true); + // Run callback if it is a function if (this.input === document.activeElement) { - // If a custom callback has been provided, use it - if (this.config.callbackOnItemSearch) { - const callback = this.config.callbackOnItemSearch; - if (isType('Function', callback)) { - if(this.passedElement.type !== 'text') { - // Reset choices - this._clearChoices(); - // Reset loading state/text - this._handleLoadingState(); + // Check that we have a value to search and the input was an alphanumeric character + if (value && value.length > this.config.searchFloor) { + // Filter available choices + this._searchChoices(value); + // Run callback if it is a function + if (this.config.callbackOnSearch) { + const callback = this.config.callbackOnSearch; + if (isType('Function', callback)) { + callback(value, this.passedElement); + } else { + console.error('callbackOnSearch: Callback is not a function'); } - // Run callback - callback(value, this._getAjaxCallback(), this.passedElement); - } else { - console.error('callbackOnOnItemSearch: Callback is not a function'); - } - } else { - const choices = this.store.getChoices(); - const hasUnactiveChoices = choices.some((option) => option.active !== true); - // Check that we have a value to search and the input was an alphanumeric character - if (value && value.length > 1) { - // Filter available choices - this._filterChoices(value); - } else if (hasUnactiveChoices) { - // Otherwise reset choices to active - this.isSearching = false; - this.store.dispatch(activateChoices(true)); } + } else if (hasUnactiveChoices) { + // Otherwise reset choices to active + this.isSearching = false; + this.store.dispatch(activateChoices(true)); } } } @@ -1331,6 +1327,7 @@ export default class Choices { // If backspace or delete key is pressed and the input has no value if (hasFocusedInput && !e.target.value && this.passedElement.type !== 'select-one') { this._handleBackspace(activeItems); + this._handleLoadingState(); e.preventDefault(); } }; diff --git a/assets/styles/css/base.css b/assets/styles/css/base.css index 8bb4d08..792e305 100644 --- a/assets/styles/css/base.css +++ b/assets/styles/css/base.css @@ -29,6 +29,9 @@ label { font-weight: 500; cursor: pointer; } +p { + margin-top: 0; } + hr { display: block; margin: 36px 0; diff --git a/assets/styles/css/base.min.css b/assets/styles/css/base.min.css index f8a143b..141be57 100644 --- a/assets/styles/css/base.min.css +++ b/assets/styles/css/base.min.css @@ -1 +1 @@ -*{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}*,:after,:before{box-sizing:border-box}body,html{position:relative;margin:0;width:100%;height:100%}body{font-family:"Helvetica Neue",Helvetica,Arial,"Lucida Grande",sans-serif;font-size:16px;line-height:1.4;color:#fff;background-color:#333;overflow-x:hidden}hr,label{display:block}label{margin-bottom:8px;font-size:14px;font-weight:500;cursor:pointer}hr{margin:36px 0;border:0;border-bottom:1px solid #eaeaea;height:1px}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:12px;font-weight:400;line-height:1.2}a,a:focus,a:visited{color:#fff;text-decoration:none;font-weight:600}.form-control{display:block;width:100%;background-color:#f9f9f9;padding:12px;border:1px solid #ddd;border-radius:2.5px;font-size:14px;-webkit-appearance:none;-moz-appearance:none;appearance:none;margin-bottom:24px}.h1,h1{font-size:32px}.h2,h2{font-size:24px}.h3,h3{font-size:20px}.h4,h4{font-size:18px}.h5,h5{font-size:16px}.h6,h6{font-size:14px}.container{display:block;margin:auto;max-width:40em;padding:48px}@media (max-width:620px){.container{padding:0}}.section{background-color:#fff;padding:24px;color:#333}.section a,.section a:focus,.section a:visited{color:#00bcd4}.logo{width:100%;height:auto;display:inline-block;max-width:100%;vertical-align:top;padding:6px 0}.visible-ie{display:none} \ No newline at end of file +*{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}*,:after,:before{box-sizing:border-box}body,html{position:relative;margin:0;width:100%;height:100%}body{font-family:"Helvetica Neue",Helvetica,Arial,"Lucida Grande",sans-serif;font-size:16px;line-height:1.4;color:#fff;background-color:#333;overflow-x:hidden}hr,label{display:block}label{margin-bottom:8px;font-size:14px;font-weight:500;cursor:pointer}p{margin-top:0}hr{margin:36px 0;border:0;border-bottom:1px solid #eaeaea;height:1px}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:12px;font-weight:400;line-height:1.2}a,a:focus,a:visited{color:#fff;text-decoration:none;font-weight:600}.form-control{display:block;width:100%;background-color:#f9f9f9;padding:12px;border:1px solid #ddd;border-radius:2.5px;font-size:14px;-webkit-appearance:none;-moz-appearance:none;appearance:none;margin-bottom:24px}.h1,h1{font-size:32px}.h2,h2{font-size:24px}.h3,h3{font-size:20px}.h4,h4{font-size:18px}.h5,h5{font-size:16px}.h6,h6{font-size:14px}.container{display:block;margin:auto;max-width:40em;padding:48px}@media (max-width:620px){.container{padding:0}}.section{background-color:#fff;padding:24px;color:#333}.section a,.section a:focus,.section a:visited{color:#00bcd4}.logo{width:100%;height:auto;display:inline-block;max-width:100%;vertical-align:top;padding:6px 0}.visible-ie{display:none} \ No newline at end of file diff --git a/assets/styles/scss/base.scss b/assets/styles/scss/base.scss index 5e3be52..f55392a 100644 --- a/assets/styles/scss/base.scss +++ b/assets/styles/scss/base.scss @@ -11,72 +11,74 @@ $global-font-size-h6: 14px; =============================================*/ * { - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale } *, *:before, *:after { - box-sizing: border-box + box-sizing: border-box } html, body { - position: relative; - margin: 0; - width: 100%; - height: 100%; + position: relative; + margin: 0; + width: 100%; + height: 100%; } body { - font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; - font-size: 16px; - line-height: 1.4; - color: #FFFFFF; - background-color: #333; - overflow-x: hidden; + font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; + font-size: 16px; + line-height: 1.4; + color: #FFFFFF; + background-color: #333; + overflow-x: hidden; } label { - display: block; - margin-bottom: 8px; - font-size: 14px; - font-weight: 500; - cursor: pointer; + display: block; + margin-bottom: 8px; + font-size: 14px; + font-weight: 500; + cursor: pointer; } +p { margin-top: 0; } + hr { - display: block; - margin: $global-guttering*1.5 0; - border: 0; - border-bottom: 1px solid #eaeaea; - height: 1px; + display: block; + margin: $global-guttering*1.5 0; + border: 0; + border-bottom: 1px solid #eaeaea; + height: 1px; } h1, h2, h3, h4, h5, h6 { - margin-top: 0; - margin-bottom: $global-guttering/2; - font-weight: 400; - line-height: 1.2; + margin-top: 0; + margin-bottom: $global-guttering/2; + font-weight: 400; + line-height: 1.2; } -a, a:visited, a:focus { - color: #FFFFFF; - text-decoration: none; - font-weight: 600; +a, a:visited, a:focus { + color: #FFFFFF; + text-decoration: none; + font-weight: 600; } .form-control { - display: block; - width: 100%; - background-color: #f9f9f9; - padding: 12px; - border: 1px solid #ddd; - border-radius: 2.5px; - font-size: 14px; - -webkit-appearance: none; - appearance: none; - margin-bottom: $global-guttering; + display: block; + width: 100%; + background-color: #f9f9f9; + padding: 12px; + border: 1px solid #ddd; + border-radius: 2.5px; + font-size: 14px; + -webkit-appearance: none; + appearance: none; + margin-bottom: $global-guttering; } h1, .h1 { font-size: $global-font-size-h1; } @@ -87,29 +89,29 @@ h5, .h5 { font-size: $global-font-size-h5; } h6, .h6 { font-size: $global-font-size-h6; } .container { - display: block; - margin: auto; - max-width: 40em; - padding: $global-guttering*2; - @media (max-width: 620px) { padding: 0; } + display: block; + margin: auto; + max-width: 40em; + padding: $global-guttering*2; + @media (max-width: 620px) { padding: 0; } } .section { - background-color: #FFFFFF; - padding: $global-guttering; - color: #333; - a, a:visited, a:focus { color: #00bcd4; } + background-color: #FFFFFF; + padding: $global-guttering; + color: #333; + a, a:visited, a:focus { color: #00bcd4; } } .logo { - width: 100%; - height: auto; - display: inline-block; - max-width: 100%; - vertical-align: top; - padding: $global-guttering/4 0; + width: 100%; + height: auto; + display: inline-block; + max-width: 100%; + vertical-align: top; + padding: $global-guttering/4 0; } .visible-ie { display: none; } -/*===== End of Section comment block ======*/ \ No newline at end of file +/*===== End of Section comment block ======*/ diff --git a/assets/styles/scss/choices.scss b/assets/styles/scss/choices.scss index b824601..9d55e05 100644 --- a/assets/styles/scss/choices.scss +++ b/assets/styles/scss/choices.scss @@ -22,274 +22,274 @@ $choices-button-dimension: 8px !default; $choices-button-offset: 8px !default; .#{$choices-selector} { - position: relative; - margin-bottom: $choices-guttering; - font-size: $choices-font-size-lg; - &:focus { outline: none; } - &:last-child { margin-bottom: 0; } - &.is-disabled { - .#{$choices-selector}__inner, .#{$choices-selector}__input { - background-color: $choices-bg-color-disabled; - cursor: not-allowed; - user-select: none; - } - .#{$choices-selector}__item { cursor: not-allowed; } + position: relative; + margin-bottom: $choices-guttering; + font-size: $choices-font-size-lg; + &:focus { outline: none; } + &:last-child { margin-bottom: 0; } + &.is-disabled { + .#{$choices-selector}__inner, .#{$choices-selector}__input { + background-color: $choices-bg-color-disabled; + cursor: not-allowed; + user-select: none; } + .#{$choices-selector}__item { cursor: not-allowed; } + } } .#{$choices-selector}[data-type*="select-one"] { - cursor: pointer; - .#{$choices-selector}__inner { padding-bottom: 7.5px; } - .#{$choices-selector}__input { - display: block; - width: 100%; - padding: 10px; - border-bottom: 1px solid $choices-keyline-color; - background-color: #FFFFFF; - margin: 0; + cursor: pointer; + .#{$choices-selector}__inner { padding-bottom: 7.5px; } + .#{$choices-selector}__input { + display: block; + width: 100%; + padding: 10px; + border-bottom: 1px solid $choices-keyline-color; + background-color: #FFFFFF; + margin: 0; + } + .#{$choices-selector}__button { + background-image: url($choices-button-icon-path + '/cross-inverse.svg'); + padding: 0; + background-size: 8px; + height: 100%; + position: absolute; + top: 50%; + right: 0; + margin-top: -10px; + margin-right: 25px; + height: 20px; + width: 20px; + border-radius: 10em; + opacity: .5; + &:hover, &:focus { opacity: 1; } + &:focus { box-shadow: 0px 0px 0px 2px $choices-highlight-color; } + } + &:after { + content: ""; + height: 0; + width: 0; + border-style: solid; + border-color: $choices-text-color transparent transparent transparent; + border-width: 5px; + position: absolute; + right: 11.5px; + top: 50%; + margin-top: -2.5px; + pointer-events: none; + } + &.is-open:after { + border-color: transparent transparent $choices-text-color transparent; + margin-top: -7.5px; + } + &[dir="rtl"] { + &:after { + left: 11.5px; + right: auto; } .#{$choices-selector}__button { - background-image: url($choices-button-icon-path + '/cross-inverse.svg'); - padding: 0; - background-size: 8px; - height: 100%; - position: absolute; - top: 50%; - right: 0; - margin-top: -10px; - margin-right: 25px; - height: 20px; - width: 20px; - border-radius: 10em; - opacity: .5; - &:hover, &:focus { opacity: 1; } - &:focus { box-shadow: 0px 0px 0px 2px $choices-highlight-color; } - } - &:after { - content: ""; - height: 0; - width: 0; - border-style: solid; - border-color: $choices-text-color transparent transparent transparent; - border-width: 5px; - position: absolute; - right: 11.5px; - top: 50%; - margin-top: -2.5px; - pointer-events: none; - } - &.is-open:after { - border-color: transparent transparent $choices-text-color transparent; - margin-top: -7.5px; - } - &[dir="rtl"] { - &:after { - left: 11.5px; - right: auto; - } - .#{$choices-selector}__button { - right: auto; - left: 0; - margin-left: 25px; - margin-right: 0; - } + right: auto; + left: 0; + margin-left: 25px; + margin-right: 0; } + } } .#{$choices-selector}[data-type*="select-multiple"], .#{$choices-selector}[data-type*="text"] { - .#{$choices-selector}__inner { cursor: text; } - .#{$choices-selector}__button { - position: relative; - display: inline-block; - margin-top: 0; - margin-right: -$choices-button-offset/2; - margin-bottom: 0; - margin-left: $choices-button-offset; - padding-left: $choices-button-offset*2; - border-left: 1px solid darken($choices-primary-color, 10%); - background-image: url($choices-button-icon-path + '/cross.svg'); - background-size: $choices-button-dimension; - width: $choices-button-dimension; - line-height: 1; - opacity: .75; - &:hover, &:focus { opacity: 1; } - } + .#{$choices-selector}__inner { cursor: text; } + .#{$choices-selector}__button { + position: relative; + display: inline-block; + margin-top: 0; + margin-right: -$choices-button-offset/2; + margin-bottom: 0; + margin-left: $choices-button-offset; + padding-left: $choices-button-offset*2; + border-left: 1px solid darken($choices-primary-color, 10%); + background-image: url($choices-button-icon-path + '/cross.svg'); + background-size: $choices-button-dimension; + width: $choices-button-dimension; + line-height: 1; + opacity: .75; + &:hover, &:focus { opacity: 1; } + } } .#{$choices-selector}__inner { - display: inline-block; - vertical-align: top; - width: 100%; - background-color: $choices-bg-color; - padding: 7.5px 7.5px 3.75px; - border: 1px solid $choices-keyline-color; - border-radius: $choices-border-radius; - font-size: $choices-font-size-md; - min-height: 44px; - overflow: hidden; - .is-focused &, .is-open & { border-color: darken($choices-keyline-color, 15%); } - .is-open & { border-radius: $choices-border-radius $choices-border-radius 0 0; } - .is-flipped.is-open & { border-radius: 0 0 $choices-border-radius $choices-border-radius; } + display: inline-block; + vertical-align: top; + width: 100%; + background-color: $choices-bg-color; + padding: 7.5px 7.5px 3.75px; + border: 1px solid $choices-keyline-color; + border-radius: $choices-border-radius; + font-size: $choices-font-size-md; + min-height: 44px; + overflow: hidden; + .is-focused &, .is-open & { border-color: darken($choices-keyline-color, 15%); } + .is-open & { border-radius: $choices-border-radius $choices-border-radius 0 0; } + .is-flipped.is-open & { border-radius: 0 0 $choices-border-radius $choices-border-radius; } } .#{$choices-selector}__list { - margin: 0; - padding-left: 0; - list-style-type: none; + margin: 0; + padding-left: 0; + list-style-type: none; } .#{$choices-selector}__list--single { - display: inline-block; - padding: 4px 16px 4px 4px; - width: 100%; - [dir="rtl"] & { - padding-right: 4px; - padding-left: 16px; - } - .#{$choices-selector}__item { width: 100%; } + display: inline-block; + padding: 4px 16px 4px 4px; + width: 100%; + [dir="rtl"] & { + padding-right: 4px; + padding-left: 16px; + } + .#{$choices-selector}__item { width: 100%; } } .#{$choices-selector}__list--multiple { - display: inline; - .#{$choices-selector}__item { - display: inline-block; - vertical-align: middle; - border-radius: $choices-border-radius-item; - padding: 4px 10px; - font-size: $choices-font-size-sm; - font-weight: 500; - margin-right: 3.75px; - margin-bottom: 3.75px; - background-color: $choices-primary-color; - border: 1px solid darken($choices-primary-color, 5%); - color: #FFFFFF; - word-break: break-all; - &[data-deletable] { padding-right: 5px; } - [dir="rtl"] & { - margin-right: 0; - margin-left: 3.75px; - } - &.is-highlighted { - background-color: darken($choices-primary-color, 5%); - border: 1px solid darken($choices-primary-color, 10%); - } - .is-disabled & { - background-color: darken($choices-disabled-color, 25%); - border: 1px solid darken($choices-disabled-color, 35%); - } + display: inline; + .#{$choices-selector}__item { + display: inline-block; + vertical-align: middle; + border-radius: $choices-border-radius-item; + padding: 4px 10px; + font-size: $choices-font-size-sm; + font-weight: 500; + margin-right: 3.75px; + margin-bottom: 3.75px; + background-color: $choices-primary-color; + border: 1px solid darken($choices-primary-color, 5%); + color: #FFFFFF; + word-break: break-all; + &[data-deletable] { padding-right: 5px; } + [dir="rtl"] & { + margin-right: 0; + margin-left: 3.75px; } + &.is-highlighted { + background-color: darken($choices-primary-color, 5%); + border: 1px solid darken($choices-primary-color, 10%); + } + .is-disabled & { + background-color: darken($choices-disabled-color, 25%); + border: 1px solid darken($choices-disabled-color, 35%); + } + } } .#{$choices-selector}__list--dropdown { - display: none; - z-index: 1; - position: absolute; - width: 100%; - background-color: $choices-bg-color-dropdown; - border: 1px solid $choices-keyline-color; - top: 100%; - margin-top: -1px; - border-bottom-left-radius: $choices-border-radius; - border-bottom-right-radius: $choices-border-radius; - overflow: hidden; - &.is-active { display: block; } - .is-open & { border-color: darken($choices-keyline-color, 15%); } - .is-flipped & { - top: auto; - bottom: 100%; - margin-top: 0; - margin-bottom: -1px; - border-radius: .25rem .25rem 0 0; - } - .#{$choices-selector}__list { - position: relative; - max-height: 300px; - overflow: auto; - -webkit-overflow-scrolling: touch; - will-change: scroll-position; - } - .#{$choices-selector}__item { - position: relative; - padding: 10px; - font-size: $choices-font-size-md; - [dir="rtl"] & { text-align: right; } - } - .#{$choices-selector}__item--selectable { - @media (min-width: 640px) { - padding-right: 100px; - &:after { - content: attr(data-select-text); - font-size: $choices-font-size-sm; - opacity: 0; - position: absolute; - right: 10px; - top: 50%; - transform: translateY(-50%); - } - [dir="rtl"] & { - text-align: right; - padding-left: 100px; - padding-right: 10px; - &:after { - right: auto; - left: 10px; - } - } - } - &.is-highlighted { - background-color: mix(#000000, #FFFFFF, 5%); - &:after { opacity: .5; } + display: none; + z-index: 1; + position: absolute; + width: 100%; + background-color: $choices-bg-color-dropdown; + border: 1px solid $choices-keyline-color; + top: 100%; + margin-top: -1px; + border-bottom-left-radius: $choices-border-radius; + border-bottom-right-radius: $choices-border-radius; + overflow: hidden; + &.is-active { display: block; } + .is-open & { border-color: darken($choices-keyline-color, 15%); } + .is-flipped & { + top: auto; + bottom: 100%; + margin-top: 0; + margin-bottom: -1px; + border-radius: .25rem .25rem 0 0; + } + .#{$choices-selector}__list { + position: relative; + max-height: 300px; + overflow: auto; + -webkit-overflow-scrolling: touch; + will-change: scroll-position; + } + .#{$choices-selector}__item { + position: relative; + padding: 10px; + font-size: $choices-font-size-md; + [dir="rtl"] & { text-align: right; } + } + .#{$choices-selector}__item--selectable { + @media (min-width: 640px) { + padding-right: 100px; + &:after { + content: attr(data-select-text); + font-size: $choices-font-size-sm; + opacity: 0; + position: absolute; + right: 10px; + top: 50%; + transform: translateY(-50%); + } + [dir="rtl"] & { + text-align: right; + padding-left: 100px; + padding-right: 10px; + &:after { + right: auto; + left: 10px; } + } } + &.is-highlighted { + background-color: mix(#000000, #FFFFFF, 5%); + &:after { opacity: .5; } + } + } } .#{$choices-selector}__item { cursor: default; } .#{$choices-selector}__item--selectable { cursor: pointer; } .#{$choices-selector}__item--disabled { - cursor: not-allowed; - user-select: none; - opacity: .5; + cursor: not-allowed; + user-select: none; + opacity: .5; } .#{$choices-selector}__group { - .#{$choices-selector}__heading { - font-weight: 600; - font-size: $choices-font-size-sm; - padding: 10px; - border-bottom: 1px solid lighten($choices-keyline-color, 10%); - color: lighten(#333, 30%); - } + .#{$choices-selector}__heading { + font-weight: 600; + font-size: $choices-font-size-sm; + padding: 10px; + border-bottom: 1px solid lighten($choices-keyline-color, 10%); + color: lighten(#333, 30%); + } } .#{$choices-selector}__button { - text-indent: -9999px; - -webkit-appearance: none; - appearance: none; - border: 0; - background-color: transparent; - background-repeat: no-repeat; - background-position: center; - cursor: pointer; - &:focus { outline: none; } + text-indent: -9999px; + -webkit-appearance: none; + appearance: none; + border: 0; + background-color: transparent; + background-repeat: no-repeat; + background-position: center; + cursor: pointer; + &:focus { outline: none; } } .#{$choices-selector}__input { - display: inline-block; - vertical-align: baseline; - background-color: mix(#000000, #FFFFFF, 2.5%); - font-size: $choices-font-size-md; - margin-bottom: 5px; - border: 0; - border-radius: 0; - max-width: 100%; - padding: 4px 0 4px 2px; - &:focus { outline: 0; } - [dir="rtl"] & { - padding-right: 2px; - padding-left: 0; - } + display: inline-block; + vertical-align: baseline; + background-color: mix(#000000, #FFFFFF, 2.5%); + font-size: $choices-font-size-md; + margin-bottom: 5px; + border: 0; + border-radius: 0; + max-width: 100%; + padding: 4px 0 4px 2px; + &:focus { outline: 0; } + [dir="rtl"] & { + padding-right: 2px; + padding-left: 0; + } } .#{$choices-selector}__placeholder { opacity: .5; } -/*===== End of Choices ======*/ \ No newline at end of file +/*===== End of Choices ======*/ diff --git a/index.html b/index.html index 978c196..d4beeb7 100644 --- a/index.html +++ b/index.html @@ -122,9 +122,6 @@ - - -

Single select input

@@ -137,6 +134,7 @@ +

If this doesn't work, the Discogs rate limit has probably been reached. Try again later!

@@ -239,7 +237,7 @@