gitlab-org--gitlab-foss/app/assets/stylesheets/framework/toggle.scss

132 lines
2.8 KiB
SCSS
Raw Normal View History

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