mirror of
https://github.com/Choices-js/Choices.git
synced 2024-04-30 13:02:48 +02:00
More descriptive state classes
This commit is contained in:
parent
877a688275
commit
db5d35790c
4
assets/scripts/dist/bundle.js
vendored
4
assets/scripts/dist/bundle.js
vendored
File diff suppressed because one or more lines are too long
|
@ -64,6 +64,8 @@ export class Choices {
|
|||
group: 'choices__group',
|
||||
groupHeading : 'choices__heading',
|
||||
activeState: 'is-active',
|
||||
focusState: 'is-focused',
|
||||
openState: 'is-open',
|
||||
disabledState: 'is-disabled',
|
||||
highlightedState: 'is-highlighted',
|
||||
hiddenState: 'is-hidden',
|
||||
|
@ -408,7 +410,7 @@ export class Choices {
|
|||
this.deselectAll();
|
||||
}
|
||||
|
||||
this.containerOuter.classList.remove(this.options.classNames.activeState);
|
||||
this.containerOuter.classList.remove(this.options.classNames.focusState);
|
||||
|
||||
// Close all other dropodowns
|
||||
if(this.passedElement.type === 'select-multiple' && this.dropdown.classList.contains(this.options.classNames.activeState)) {
|
||||
|
@ -451,7 +453,7 @@ export class Choices {
|
|||
*/
|
||||
onFocus(e) {
|
||||
if(!this.containerOuter.classList.contains(this.options.classNames.activeState)) {
|
||||
this.containerOuter.classList.add(this.options.classNames.activeState);
|
||||
this.containerOuter.classList.add(this.options.classNames.focusState);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -463,7 +465,7 @@ export class Choices {
|
|||
onBlur(e) {
|
||||
const hasActiveDropdown = this.dropdown && this.dropdown.classList.contains(this.options.classNames.activeState);
|
||||
if(!hasActiveDropdown) {
|
||||
this.containerOuter.classList.remove(this.options.classNames.activeState);
|
||||
this.containerOuter.classList.remove(this.options.classNames.focusState);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -510,7 +512,6 @@ export class Choices {
|
|||
|
||||
const animateScroll = (time, endPoint, direction) => {
|
||||
let continueAnimation = false;
|
||||
|
||||
let easing, distance;
|
||||
const strength = 4;
|
||||
|
||||
|
@ -742,8 +743,10 @@ export class Choices {
|
|||
* Show dropdown to user by adding active state class
|
||||
* @return
|
||||
*/
|
||||
showDropdown() {
|
||||
showDropdown() {
|
||||
this.containerOuter.classList.add(this.options.classNames.openState);
|
||||
this.dropdown.classList.add(this.options.classNames.activeState);
|
||||
|
||||
const dimensions = this.dropdown.getBoundingClientRect();
|
||||
const shouldFlip = dimensions.top + dimensions.height >= document.body.offsetHeight;
|
||||
|
||||
|
@ -763,6 +766,7 @@ export class Choices {
|
|||
// A dropdown flips if it does not have space below the input
|
||||
const isFlipped = this.dropdown.classList.contains(this.options.classNames.flippedState);
|
||||
|
||||
this.containerOuter.classList.remove(this.options.classNames.openState);
|
||||
this.dropdown.classList.remove(this.options.classNames.activeState);
|
||||
|
||||
if(isFlipped) {
|
||||
|
|
|
@ -48,7 +48,7 @@ h1, h2, h3, h4, h5, h6 {
|
|||
border-radius: .25rem;
|
||||
font-size: 1.4rem;
|
||||
cursor: text; }
|
||||
.is-active .choices__inner {
|
||||
.is-focused .choices__inner {
|
||||
border-color: #b7b7b7; }
|
||||
.choices__inner:focus {
|
||||
outline: 1px solid #00BCD4;
|
||||
|
@ -89,7 +89,7 @@ h1, h2, h3, h4, h5, h6 {
|
|||
max-height: 300px;
|
||||
overflow: auto;
|
||||
will-change: scroll-position; }
|
||||
.is-active .choices__list--dropdown {
|
||||
.is-open .choices__list--dropdown {
|
||||
border-color: #b7b7b7; }
|
||||
.choices__list--dropdown .choices__item {
|
||||
padding: 1rem;
|
||||
|
|
2
assets/styles/css/choices.min.css
vendored
2
assets/styles/css/choices.min.css
vendored
|
@ -1 +1 @@
|
|||
*,:after,:before{box-sizing:border-box}body,html{margin:0;height:100%;widows:100%}html{font-size:62.5%}body{background-color:#333;font-family:"Helvetica Neue",Helvetica,Arial,"Lucida Grande",sans-serif;font-size:1.6rem;color:#fff}label{display:block;margin-bottom:.8rem;font-size:1.4rem;font-weight:500}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:1.2rem;font-weight:500}.container{display:block;margin:auto;max-width:35em;padding:2.4rem}.section{background-color:#fff;padding:2.4rem;color:#333}.choices{margin-bottom:2.4rem;position:relative}.choices__inner{background-color:#f9f9f9;padding:.75rem .75rem .375rem;border:1px solid #ddd;border-radius:.25rem;font-size:1.4rem;cursor:text}.is-active .choices__inner{border-color:#b7b7b7}.choices__inner:focus{outline:1px solid #00bcd4;outline-offset:-1px}.choices__list{margin:0;padding-left:0;list-style-type:none}.choices__list--items{display:inline}.choices__list--items .choices__item{display:inline-block;border-radius:2rem;padding:.4rem 1rem;font-size:1.2rem;margin-right:.375rem;margin-bottom:.375rem;background-color:#00bcd4;border:1px solid #00b1c7;color:#fff;word-break:break-all}.choices__list--items .choices__item.is-selected{background-color:#00a5bb}.choices__list--dropdown{display:none;z-index:1;position:absolute;width:100%;background-color:#fff;border:1px solid #ddd;top:100%;margin-top:-1px;border-bottom-left-radius:.25rem;border-bottom-right-radius:.25rem;max-height:300px;overflow:auto;will-change:scroll-position}.is-active .choices__list--dropdown{border-color:#b7b7b7}.choices__list--dropdown .choices__item{padding:1rem;font-size:1.4rem}.choices__list--dropdown .choices__item--selectable.is-highlighted:after,.choices__list--dropdown .choices__item.is-selected{opacity:.5}.choices__list--dropdown .choices__item.is-selected:hover{background-color:#fff}.choices__list--dropdown .choices__item--selectable:after{content:"Press to select";font-size:12px;opacity:0;float:right}.choices__list--dropdown .choices__item--selectable.is-highlighted{background-color:#f2f2f2}.choices__list--dropdown.is-active{display:block}.choices__list--dropdown.is-flipped{top:auto;bottom:100%;margin-top:0;margin-bottom:-1px;border-bottom-left-radius:0;border-bottom-right-radius:0;border-top-left-radius:.25rem;border-top-right-radius:.25rem}.choices__item{cursor:default}.choices__item--selectable{cursor:pointer}.choices__item--disabled{cursor:not-allowed;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:.5}.choices__group .choices__heading{font-weight:600;font-size:1.2rem;padding:1rem;border-bottom:1px solid #eaeaea;color:gray}.choices__input{background-color:#f9f9f9;font-size:1.4rem;padding:0;margin-bottom:.5rem;display:inline-block;vertical-align:baseline;border:0;border-radius:0;max-width:100%;padding:.4rem 0 .4rem .2rem}.choices__input:focus{outline:0}
|
||||
*,:after,:before{box-sizing:border-box}body,html{margin:0;height:100%;widows:100%}html{font-size:62.5%}body{background-color:#333;font-family:"Helvetica Neue",Helvetica,Arial,"Lucida Grande",sans-serif;font-size:1.6rem;color:#fff}label{display:block;margin-bottom:.8rem;font-size:1.4rem;font-weight:500}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:1.2rem;font-weight:500}.container{display:block;margin:auto;max-width:35em;padding:2.4rem}.section{background-color:#fff;padding:2.4rem;color:#333}.choices{margin-bottom:2.4rem;position:relative}.choices__inner{background-color:#f9f9f9;padding:.75rem .75rem .375rem;border:1px solid #ddd;border-radius:.25rem;font-size:1.4rem;cursor:text}.is-focused .choices__inner{border-color:#b7b7b7}.choices__inner:focus{outline:1px solid #00bcd4;outline-offset:-1px}.choices__list{margin:0;padding-left:0;list-style-type:none}.choices__list--items{display:inline}.choices__list--items .choices__item{display:inline-block;border-radius:2rem;padding:.4rem 1rem;font-size:1.2rem;margin-right:.375rem;margin-bottom:.375rem;background-color:#00bcd4;border:1px solid #00b1c7;color:#fff;word-break:break-all}.choices__list--items .choices__item.is-selected{background-color:#00a5bb}.choices__list--dropdown{display:none;z-index:1;position:absolute;width:100%;background-color:#fff;border:1px solid #ddd;top:100%;margin-top:-1px;border-bottom-left-radius:.25rem;border-bottom-right-radius:.25rem;max-height:300px;overflow:auto;will-change:scroll-position}.is-open .choices__list--dropdown{border-color:#b7b7b7}.choices__list--dropdown .choices__item{padding:1rem;font-size:1.4rem}.choices__list--dropdown .choices__item--selectable.is-highlighted:after,.choices__list--dropdown .choices__item.is-selected{opacity:.5}.choices__list--dropdown .choices__item.is-selected:hover{background-color:#fff}.choices__list--dropdown .choices__item--selectable:after{content:"Press to select";font-size:12px;opacity:0;float:right}.choices__list--dropdown .choices__item--selectable.is-highlighted{background-color:#f2f2f2}.choices__list--dropdown.is-active{display:block}.choices__list--dropdown.is-flipped{top:auto;bottom:100%;margin-top:0;margin-bottom:-1px;border-bottom-left-radius:0;border-bottom-right-radius:0;border-top-left-radius:.25rem;border-top-right-radius:.25rem}.choices__item{cursor:default}.choices__item--selectable{cursor:pointer}.choices__item--disabled{cursor:not-allowed;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:.5}.choices__group .choices__heading{font-weight:600;font-size:1.2rem;padding:1rem;border-bottom:1px solid #eaeaea;color:gray}.choices__input{background-color:#f9f9f9;font-size:1.4rem;padding:0;margin-bottom:.5rem;display:inline-block;vertical-align:baseline;border:0;border-radius:0;max-width:100%;padding:.4rem 0 .4rem .2rem}.choices__input:focus{outline:0}
|
|
@ -59,7 +59,7 @@ h1, h2, h3, h4, h5, h6 {
|
|||
border-radius: .25rem;
|
||||
font-size: 1.4rem;
|
||||
cursor: text;
|
||||
.is-active & { border-color: darken(#DDDDDD, 15%); }
|
||||
.is-focused & { border-color: darken(#DDDDDD, 15%); }
|
||||
&:focus {
|
||||
outline: 1px solid #00BCD4;
|
||||
outline-offset: -1px;
|
||||
|
@ -105,7 +105,7 @@ h1, h2, h3, h4, h5, h6 {
|
|||
max-height: 300px;
|
||||
overflow: auto;
|
||||
will-change: scroll-position;
|
||||
.is-active & { border-color: darken(#DDDDDD, 15%); }
|
||||
.is-open & { border-color: darken(#DDDDDD, 15%); }
|
||||
.choices__item {
|
||||
padding: 1rem;
|
||||
font-size: 1.4rem;
|
||||
|
|
Loading…
Reference in a new issue