83 lines
2.1 KiB
SCSS

/*
* Copyright 2016 Resin.io
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* A button with a progress bar inside.
*
* From http://tympanus.net/Development/ProgressButtonStyles/
*
* The state of the progress bar is controller by the width, in percentage,
* of `.progress-button__bar`.
*
* The current percentage also needs to be reflected in the top level
* `.progress-button` element as a `percentage` attribute, without the percentage sign.
*
* If there is an action in place, the `active` attribute must be set to `true`.
* This is useful to determine if the progress bar is paused from the point of view
* of the styling.
*
* Usage:
*
* <button class="progress-button progress-button--primary" percentage="50" active="true">
* <span class="progress-button__content">Button text</span>
* <span class="progress-button__bar" style="width: 50%;"></span>
* </button>
*/
.progress-button {
@extend .btn;
}
.progress-button--primary {
@extend .btn-primary;
.progress-button__bar {
background: lighten($brand-primary, 5);
}
}
.progress-button[percentage="100"][active="false"] .progress-button__bar {
background-color: $brand-success;
}
.progress-button[percentage="100"][active="true"] .progress-button__bar {
background-color: $brand-warning;
}
// Prevent the button from being clickable
// when it has an active progress bar.
.progress-button[active="true"] {
pointer-events: none;
}
.progress-button__content {
position: relative;
z-index: 10;
}
.progress-button__bar {
position: absolute;
left: 0;
top: 0;
width: 0;
height: 100%;
// Subtle progress bar animation
transition: width 0.3s, opacity 0.3s;
}