debian-mirror-gitlab/app/assets/stylesheets/framework/toggle.scss

132 lines
2.8 KiB
SCSS
Raw Normal View History

2018-03-17 18:26:18 +05:30
/**
* 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">
2021-02-22 17:27:13 +05:30
* <span class="gl-spinner loading-icon hidden" aria-label="Loading"></span>
2018-03-17 18:26:18 +05:30
* </button>
* ### Checked should have `is-checked` class
* <button type="button" class="project-feature-toggle is-checked" data-enabled-text="Enabled" data-disabled-text="Disabled">
2021-02-22 17:27:13 +05:30
* <span class="gl-spinner loading-icon hidden" aria-label="Loading"></span>
2018-03-17 18:26:18 +05:30
* </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">
2021-02-22 17:27:13 +05:30
* <span class="gl-spinner loading-icon hidden" aria-label="Loading"></span>
2018-03-17 18:26:18 +05:30
* </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">
2021-02-22 17:27:13 +05:30
* <span class="gl-spinner loading-icon" aria-label="Loading"></span>
2018-03-17 18:26:18 +05:30
* </button>
*/
.project-feature-toggle {
position: relative;
border: 0;
outline: 0;
display: block;
width: 50px;
height: 24px;
cursor: pointer;
user-select: none;
2020-10-24 23:57:45 +05:30
background: $gray-400;
2018-03-17 18:26:18 +05:30
border-radius: 12px;
padding: 3px;
2019-07-07 11:18:12 +05:30
transition: all 0.4s ease;
2018-03-17 18:26:18 +05:30
&::selection,
&::before::selection,
&::after::selection {
background: none;
}
2018-11-08 19:23:39 +05:30
&:focus {
outline: none;
}
2018-03-17 18:26:18 +05:30
.toggle-icon {
position: relative;
display: block;
left: 0;
border-radius: 9px;
2020-10-24 23:57:45 +05:30
background: $white;
2019-07-07 11:18:12 +05:30
transition: all 0.2s ease;
2020-10-24 23:57:45 +05:30
width: $default-icon-size;
height: $default-icon-size;
2018-03-17 18:26:18 +05:30
}
.loading-icon {
display: none;
font-size: 12px;
2020-04-22 19:07:51 +05:30
color: $white;
2018-03-17 18:26:18 +05:30
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 {
2020-10-24 23:57:45 +05:30
background: $blue-400;
2018-03-17 18:26:18 +05:30
.toggle-icon {
left: calc(100% - 18px);
2020-10-24 23:57:45 +05:30
}
}
2018-03-17 18:26:18 +05:30
2020-10-24 23:57:45 +05:30
&.is-checked .toggle-icon .toggle-status-checked,
.toggle-icon .toggle-status-unchecked {
display: inline;
}
2018-03-17 18:26:18 +05:30
2020-10-24 23:57:45 +05:30
&.is-checked .toggle-icon .toggle-status-unchecked,
&.is-loading .toggle-icon,
.toggle-icon .toggle-status-checked {
display: none;
2018-03-17 18:26:18 +05:30
}
&.is-disabled {
opacity: 0.4;
cursor: not-allowed;
}
2018-11-08 19:23:39 +05:30
@include media-breakpoint-down(xs) {
2018-03-17 18:26:18 +05:30
width: 50px;
&::before,
&.is-checked::before {
display: none;
}
}
@keyframes animate-enabled {
2019-07-07 11:18:12 +05:30
0%,
35% { opacity: 0; }
2018-03-17 18:26:18 +05:30
100% { opacity: 1; }
}
@keyframes animate-disabled {
2019-07-07 11:18:12 +05:30
0%,
35% { opacity: 0; }
2018-03-17 18:26:18 +05:30
100% { opacity: 1; }
}
}