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;
|
|
|
|
background: $feature-toggle-color-disabled;
|
|
|
|
border-radius: 12px;
|
|
|
|
padding: 3px;
|
|
|
|
transition: all .4s ease;
|
|
|
|
|
|
|
|
&::selection,
|
|
|
|
&::before::selection,
|
|
|
|
&::after::selection {
|
|
|
|
background: 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;
|
|
|
|
background: $feature-toggle-color;
|
|
|
|
transition: all .2s ease;
|
2017-12-15 08:24:16 -05:00
|
|
|
|
|
|
|
&,
|
|
|
|
.toggle-icon-svg {
|
|
|
|
width: 18px;
|
|
|
|
height: 18px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.toggle-icon-svg {
|
|
|
|
fill: $feature-toggle-color-disabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
.toggle-status-checked {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.toggle-status-unchecked {
|
|
|
|
display: inline;
|
|
|
|
}
|
2017-11-24 16:00:06 -05:00
|
|
|
}
|
|
|
|
|
2017-11-28 08:16:44 -05:00
|
|
|
.loading-icon {
|
|
|
|
display: none;
|
|
|
|
font-size: 12px;
|
|
|
|
color: $white-light;
|
|
|
|
position: absolute;
|
|
|
|
top: 50%;
|
|
|
|
left: 50%;
|
|
|
|
transform: translate(-50%, -50%);
|
|
|
|
}
|
|
|
|
|
2017-11-24 16:00:06 -05:00
|
|
|
&.is-loading {
|
2017-12-15 08:24:16 -05:00
|
|
|
.toggle-icon {
|
2017-11-28 08:16:44 -05:00
|
|
|
display: none;
|
2017-11-24 16:00:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
.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 {
|
|
|
|
background: $feature-toggle-color-enabled;
|
2017-11-24 16:00:06 -05:00
|
|
|
|
2017-12-15 08:24:16 -05:00
|
|
|
.toggle-icon {
|
|
|
|
left: calc(100% - 18px);
|
2017-11-24 16:00:06 -05:00
|
|
|
|
2017-12-15 08:24:16 -05:00
|
|
|
.toggle-icon-svg {
|
|
|
|
fill: $feature-toggle-color-enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
.toggle-status-checked {
|
|
|
|
display: inline;
|
|
|
|
}
|
|
|
|
|
|
|
|
.toggle-status-unchecked {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
@media (max-width: $screen-xs-min) {
|
|
|
|
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 {
|
|
|
|
0%, 35% { opacity: 0; }
|
|
|
|
100% { opacity: 1; }
|
|
|
|
}
|
|
|
|
|
|
|
|
@keyframes animate-disabled {
|
|
|
|
0%, 35% { opacity: 0; }
|
|
|
|
100% { opacity: 1; }
|
|
|
|
}
|
|
|
|
}
|