| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428 |
- //
- // Copyright 2022 Google Inc.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a copy
- // of this software and associated documentation files (the "Software"), to deal
- // in the Software without restriction, including without limitation the rights
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- // copies of the Software, and to permit persons to whom the Software is
- // furnished to do so, subject to the following conditions:
- //
- // The above copyright notice and this permission notice shall be included in
- // all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- // THE SOFTWARE.
- //
- // stylelint-disable selector-class-pattern --
- // Selector '.mdc-*' should only be used in this project.
- @use 'sass:math';
- @use '@material/animation/functions' as animation-functions;
- @use '@material/feature-targeting/feature-targeting';
- @use '@material/rtl/rtl';
- @use '@material/theme/gss';
- @use '@material/theme/theme';
- @use './circular-progress-theme';
- ///
- /// Circular progress core styles.
- ///
- @mixin core-styles($query: feature-targeting.all()) {
- @include circular-progress-theme.color(
- circular-progress-theme.$color,
- $query
- );
- @include circular-progress-theme.track-color(
- circular-progress-theme.$track-color,
- $query: $query
- );
- @include static-styles($query);
- }
- @mixin static-styles($query: feature-targeting.all()) {
- $feat-structure: feature-targeting.create-target($query, structure);
- $feat-animation: feature-targeting.create-target($query, animation);
- @include feature-targeting.targets($feat-animation) {
- @include container-rotate-keyframes_;
- @include spinner-layer-rotate-keyframes_;
- @include color-1-fade-in-out-keyframes_;
- @include color-2-fade-in-out-keyframes_;
- @include color-3-fade-in-out-keyframes_;
- @include color-4-fade-in-out-keyframes_;
- @include left-spin-keyframes_;
- @include right-spin-keyframes_;
- }
- .mdc-circular-progress {
- @include feature-targeting.targets($feat-structure) {
- display: inline-flex;
- position: relative;
- @include rtl.ignore-next-line();
- direction: ltr;
- line-height: 0;
- }
- @include feature-targeting.targets($feat-animation) {
- transition: animation-functions.exit-temporary(opacity, 250ms);
- }
- }
- .mdc-circular-progress__determinate-container,
- .mdc-circular-progress__indeterminate-circle-graphic,
- .mdc-circular-progress__indeterminate-container,
- .mdc-circular-progress__spinner-layer {
- @include feature-targeting.targets($feat-structure) {
- position: absolute;
- width: 100%;
- height: 100%;
- }
- }
- .mdc-circular-progress__determinate-container {
- @include feature-targeting.targets($feat-structure) {
- @include rtl.ignore-next-line();
- transform: rotate(-90deg);
- }
- }
- .mdc-circular-progress__indeterminate-container {
- @include feature-targeting.targets($feat-structure) {
- // Font size, letter spacing and nowrap are required in order to ignore
- // whitespaces between HTML elements.
- font-size: 0;
- letter-spacing: 0;
- white-space: nowrap;
- opacity: 0;
- }
- }
- .mdc-circular-progress__determinate-circle-graphic,
- .mdc-circular-progress__indeterminate-circle-graphic {
- @include feature-targeting.targets($feat-structure) {
- fill: transparent;
- }
- }
- .mdc-circular-progress__determinate-circle {
- @include feature-targeting.targets($feat-animation) {
- transition: animation-functions.enter(stroke-dashoffset, 500ms);
- }
- }
- .mdc-circular-progress__gap-patch {
- @include feature-targeting.targets($feat-structure) {
- position: absolute;
- top: 0;
- @include rtl.ignore-next-line();
- left: 47.5%;
- box-sizing: border-box;
- width: 5%;
- height: 100%;
- overflow: hidden;
- }
- .mdc-circular-progress__indeterminate-circle-graphic {
- @include feature-targeting.targets($feat-structure) {
- @include rtl.ignore-next-line();
- left: -900%;
- width: 2000%;
- @include rtl.ignore-next-line();
- transform: rotate(180deg);
- }
- }
- }
- .mdc-circular-progress__circle-clipper {
- @include feature-targeting.targets($feat-structure) {
- display: inline-flex;
- position: relative;
- width: 50%;
- height: 100%;
- overflow: hidden;
- }
- .mdc-circular-progress__indeterminate-circle-graphic {
- @include feature-targeting.targets($feat-structure) {
- width: 200%;
- }
- }
- }
- .mdc-circular-progress__circle-right {
- .mdc-circular-progress__indeterminate-circle-graphic {
- @include feature-targeting.targets($feat-structure) {
- @include rtl.ignore-next-line();
- left: -100%;
- }
- }
- }
- .mdc-circular-progress--indeterminate {
- .mdc-circular-progress__determinate-container {
- @include feature-targeting.targets($feat-structure) {
- opacity: 0;
- }
- }
- .mdc-circular-progress__indeterminate-container {
- @include feature-targeting.targets($feat-structure) {
- opacity: 1;
- }
- }
- @include indeterminate-active-animations_($query);
- }
- .mdc-circular-progress--closed {
- @include feature-targeting.targets($feat-structure) {
- opacity: 0;
- }
- }
- }
- // Private mixins
- /// Sets the animations for the indicator in indeterminate mode.
- /// @access private
- @mixin indeterminate-active-animations_($query: feature-targeting.all()) {
- $feat-animation: feature-targeting.create-target($query, animation);
- .mdc-circular-progress__indeterminate-container {
- @include feature-targeting.targets($feat-animation) {
- $duration: math.div(
- 360deg * circular-progress-theme.$arc-time,
- circular-progress-theme.$arc-start-rotation-interval +
- (360 - circular-progress-theme.$arc-size)
- );
- animation: mdc-circular-progress-container-rotate $duration linear
- infinite;
- }
- }
- $spinner-rotate-animation: mdc-circular-progress-spinner-layer-rotate 4 *
- circular-progress-theme.$arc-time circular-progress-theme.$timing-function
- infinite both;
- .mdc-circular-progress__spinner-layer {
- @include feature-targeting.targets($feat-animation) {
- animation: $spinner-rotate-animation;
- }
- }
- @for $i from 1 through 4 {
- $color-fade-in-out-animation: mdc-circular-progress-color-#{$i}-fade-in-out
- 4 *
- circular-progress-theme.$arc-time
- circular-progress-theme.$timing-function
- infinite
- both;
- .mdc-circular-progress__color-#{$i} {
- @include feature-targeting.targets($feat-animation) {
- animation: $spinner-rotate-animation, $color-fade-in-out-animation;
- }
- }
- }
- .mdc-circular-progress__circle-left
- .mdc-circular-progress__indeterminate-circle-graphic {
- @include feature-targeting.targets($feat-animation) {
- @include gss.annotate(
- (
- noflip: true,
- )
- );
- animation: mdc-circular-progress-left-spin
- circular-progress-theme.$arc-time
- circular-progress-theme.$timing-function infinite both;
- }
- }
- .mdc-circular-progress__circle-right
- .mdc-circular-progress__indeterminate-circle-graphic {
- @include feature-targeting.targets($feat-animation) {
- @include gss.annotate(
- (
- noflip: true,
- )
- );
- animation: mdc-circular-progress-right-spin
- circular-progress-theme.$arc-time
- circular-progress-theme.$timing-function infinite both;
- }
- }
- }
- /// Keyframes for the persistent rotation of the outermost container
- /// @access private
- @mixin container-rotate-keyframes_ {
- @keyframes mdc-circular-progress-container-rotate {
- to {
- @include rtl.ignore-next-line();
- transform: rotate(360deg);
- }
- }
- }
- /// Keyframes for the rotation of the spinner layer
- /// @access private
- @mixin spinner-layer-rotate-keyframes_ {
- @keyframes mdc-circular-progress-spinner-layer-rotate {
- @for $i from 1 through 8 {
- #{$i * 12.5}% {
- @include rtl.ignore-next-line();
- transform: rotate($i * 0.5 * circular-progress-theme.$arc-size);
- }
- }
- }
- }
- /// Keyframes for the fade-in and fade-out of the first color.
- /// .99 opacity is used to force subpixel rendering.
- /// @access private
- @mixin color-1-fade-in-out-keyframes_ {
- @keyframes mdc-circular-progress-color-1-fade-in-out {
- from {
- opacity: 0.99;
- }
- 25% {
- opacity: 0.99;
- }
- 26% {
- opacity: 0;
- }
- 89% {
- opacity: 0;
- }
- 90% {
- opacity: 0.99;
- }
- to {
- opacity: 0.99;
- }
- }
- }
- /// Keyframes for the fade-in and fade-out of the second color.
- /// .99 opacity is used to force subpixel rendering.
- /// @access private
- @mixin color-2-fade-in-out-keyframes_ {
- @keyframes mdc-circular-progress-color-2-fade-in-out {
- from {
- opacity: 0;
- }
- 15% {
- opacity: 0;
- }
- 25% {
- opacity: 0.99;
- }
- 50% {
- opacity: 0.99;
- }
- 51% {
- opacity: 0;
- }
- to {
- opacity: 0;
- }
- }
- }
- /// Keyframes for the fade-in and fade-out of the third color.
- /// .99 opacity is used to force subpixel rendering.
- /// @access private
- @mixin color-3-fade-in-out-keyframes_ {
- @keyframes mdc-circular-progress-color-3-fade-in-out {
- from {
- opacity: 0;
- }
- 40% {
- opacity: 0;
- }
- 50% {
- opacity: 0.99;
- }
- 75% {
- opacity: 0.99;
- }
- 76% {
- opacity: 0;
- }
- to {
- opacity: 0;
- }
- }
- }
- /// Keyframes for the fade-in and fade-out of the fourth color.
- /// .99 opacity is used to force subpixel rendering.
- /// @access private
- @mixin color-4-fade-in-out-keyframes_ {
- @keyframes mdc-circular-progress-color-4-fade-in-out {
- from {
- opacity: 0;
- }
- 65% {
- opacity: 0;
- }
- 75% {
- opacity: 0.99;
- }
- 90% {
- opacity: 0.99;
- }
- to {
- opacity: 0;
- }
- }
- }
- /// Keyframes for the expansion and contraction of the arc for the
- /// left semi-circle.
- /// @access private
- @mixin left-spin-keyframes_ {
- @keyframes mdc-circular-progress-left-spin {
- from {
- @include rtl.ignore-next-line();
- transform: rotate(265deg);
- }
- 50% {
- @include rtl.ignore-next-line();
- transform: rotate(130deg);
- }
- to {
- @include rtl.ignore-next-line();
- transform: rotate(265deg);
- }
- }
- }
- /// Keyframes for the expansion and contraction of the arc for the
- /// right semi-circle.
- /// @access private
- @mixin right-spin-keyframes_ {
- @keyframes mdc-circular-progress-right-spin {
- from {
- @include rtl.ignore-next-line();
- transform: rotate(-265deg);
- }
- 50% {
- @include rtl.ignore-next-line();
- transform: rotate(-130deg);
- }
- to {
- @include rtl.ignore-next-line();
- transform: rotate(-265deg);
- }
- }
- }
|