2017-11-24 16:00:06 -05:00
|
|
|
/**
|
|
|
|
* Toggle button
|
|
|
|
*
|
|
|
|
* @usage
|
2017-11-28 08:16:44 -05:00
|
|
|
* ### Active and Inactive text should be provided as data attributes:
|
|
|
|
* <button type="button" class="project-feature-toggle" data-enabled-text="Enabled" data-disabled-text="Disabled">
|
2017-11-24 16:00:06 -05:00
|
|
|
* <i class="fa fa-spinner fa-spin loading-icon hidden"></i>
|
|
|
|
* </button>
|
|
|
|
|
2017-11-28 08:16:44 -05:00
|
|
|
* ### Checked should have `is-checked` class
|
|
|
|
* <button type="button" class="project-feature-toggle is-checked" data-enabled-text="Enabled" data-disabled-text="Disabled">
|
2017-11-24 16:00:06 -05:00
|
|
|
* <i class="fa fa-spinner fa-spin loading-icon hidden"></i>
|
|
|
|
* </button>
|
|
|
|
|
2017-11-28 08:16:44 -05:00
|
|
|
* ### Disabled should have `is-disabled` class
|
|
|
|
* <button type="button" class="project-feature-toggle is-disabled" data-enabled-text="Enabled" data-disabled-text="Disabled" disabled="true">
|
2017-11-24 16:00:06 -05:00
|
|
|
* <i class="fa fa-spinner fa-spin loading-icon hidden"></i>
|
|
|
|
* </button>
|
|
|
|
|
2017-11-28 08:16:44 -05:00
|
|
|
* ### Loading should have `is-loading` and an icon with `loading-icon` class
|
2017-11-24 16:00:06 -05:00
|
|
|
* <button type="button" class="project-feature-toggle is-loading" data-enabled-text="Enabled" data-disabled-text="Disabled">
|
|
|
|
* <i class="fa fa-spinner fa-spin loading-icon"></i>
|
|
|
|
* </button>
|
|
|
|
*/
|
|
|
|
.project-feature-toggle {
|
|
|
|
position: relative;
|
|
|
|
border: 0;
|
|
|
|
outline: 0;
|
|
|
|
display: block;
|
2017-12-15 08:24:16 -05:00
|
|
|
width: 50px;
|
2017-11-24 16:00:06 -05:00
|
|
|
height: 24px;
|
|
|
|
cursor: pointer;
|
|
|
|
user-select: none;
|
2020-08-09 23:09:44 -04:00
|
|
|
background: $gray-400;
|
2017-11-24 16:00:06 -05:00
|
|
|
border-radius: 12px;
|
|
|
|
padding: 3px;
|
2019-02-25 14:03:21 -05:00
|
|
|
transition: all 0.4s ease;
|
2017-11-24 16:00:06 -05:00
|
|
|
|
|
|
|
&::selection,
|
|
|
|
&::before::selection,
|
|
|
|
&::after::selection {
|
|
|
|
background: none;
|
|
|
|
}
|
|
|
|
|
2018-06-06 13:08:01 -04:00
|
|
|
&:focus {
|
|
|
|
outline: none;
|
|
|
|
}
|
|
|
|
|
2017-12-15 08:24:16 -05:00
|
|
|
.toggle-icon {
|
2017-11-24 16:00:06 -05:00
|
|
|
position: relative;
|
|
|
|
display: block;
|
|
|
|
left: 0;
|
|
|
|
border-radius: 9px;
|
2020-08-09 23:09:44 -04:00
|
|
|
background: $white;
|
2019-02-25 14:03:21 -05:00
|
|
|
transition: all 0.2s ease;
|
2020-08-09 23:09:44 -04:00
|
|
|
width: $default-icon-size;
|
|
|
|
height: $default-icon-size;
|
2017-11-24 16:00:06 -05:00
|
|
|
}
|
|
|
|
|
2017-11-28 08:16:44 -05:00
|
|
|
.loading-icon {
|
|
|
|
display: none;
|
|
|
|
font-size: 12px;
|
2020-03-30 20:08:09 -04:00
|
|
|
color: $white;
|
2017-11-28 08:16:44 -05:00
|
|
|
position: absolute;
|
|
|
|
top: 50%;
|
|
|
|
left: 50%;
|
|
|
|
transform: translate(-50%, -50%);
|
|
|
|
}
|
|
|
|
|
2017-11-24 16:00:06 -05:00
|
|
|
&.is-loading {
|
|
|
|
.loading-icon {
|
2017-11-28 08:16:44 -05:00
|
|
|
display: block;
|
2017-11-24 16:00:06 -05:00
|
|
|
|
|
|
|
&::before {
|
2017-11-28 08:16:44 -05:00
|
|
|
position: absolute;
|
|
|
|
top: 50%;
|
|
|
|
left: 50%;
|
|
|
|
transform: translate(-50%, -50%);
|
2017-11-24 16:00:06 -05:00
|
|
|
}
|
|
|
|
}
|
2017-11-28 08:16:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
&.is-checked {
|
2020-08-09 23:09:44 -04:00
|
|
|
background: $blue-400;
|
2017-11-24 16:00:06 -05:00
|
|
|
|
2017-12-15 08:24:16 -05:00
|
|
|
.toggle-icon {
|
|
|
|
left: calc(100% - 18px);
|
2020-08-09 23:09:44 -04:00
|
|
|
}
|
|
|
|
}
|
2017-11-24 16:00:06 -05:00
|
|
|
|
2020-08-09 23:09:44 -04:00
|
|
|
&.is-checked .toggle-icon .toggle-status-checked,
|
|
|
|
.toggle-icon .toggle-status-unchecked {
|
|
|
|
display: inline;
|
|
|
|
}
|
2017-12-15 08:24:16 -05:00
|
|
|
|
2020-08-09 23:09:44 -04:00
|
|
|
&.is-checked .toggle-icon .toggle-status-unchecked,
|
|
|
|
&.is-loading .toggle-icon,
|
|
|
|
.toggle-icon .toggle-status-checked {
|
|
|
|
display: none;
|
2017-11-24 16:00:06 -05:00
|
|
|
}
|
|
|
|
|
2017-11-28 08:16:44 -05:00
|
|
|
&.is-disabled {
|
2017-11-24 16:00:06 -05:00
|
|
|
opacity: 0.4;
|
|
|
|
cursor: not-allowed;
|
|
|
|
}
|
|
|
|
|
2018-04-09 11:26:28 -04:00
|
|
|
@include media-breakpoint-down(xs) {
|
2017-11-24 16:00:06 -05:00
|
|
|
width: 50px;
|
|
|
|
|
|
|
|
&::before,
|
2017-11-28 08:16:44 -05:00
|
|
|
&.is-checked::before {
|
2017-11-24 16:00:06 -05:00
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@keyframes animate-enabled {
|
2019-02-25 14:03:21 -05:00
|
|
|
0%,
|
|
|
|
|
|
|
|
35% { opacity: 0; }
|
|
|
|
|
2017-11-24 16:00:06 -05:00
|
|
|
100% { opacity: 1; }
|
|
|
|
}
|
|
|
|
|
|
|
|
@keyframes animate-disabled {
|
2019-02-25 14:03:21 -05:00
|
|
|
0%,
|
|
|
|
|
|
|
|
35% { opacity: 0; }
|
|
|
|
|
2017-11-24 16:00:06 -05:00
|
|
|
100% { opacity: 1; }
|
|
|
|
}
|
|
|
|
}
|