diff --git a/packages/components/src/components/inline-loading/_inline-loading.scss b/packages/components/src/components/inline-loading/_inline-loading.scss index ac14790079e4..5f6055e4f546 100644 --- a/packages/components/src/components/inline-loading/_inline-loading.scss +++ b/packages/components/src/components/inline-loading/_inline-loading.scss @@ -21,14 +21,6 @@ width: 100%; min-height: 2rem; align-items: center; - - .#{$prefix}--loading__svg circle { - stroke-width: 12; - } - - .#{$prefix}--loading__stroke { - stroke-dashoffset: $loading--small__gap; - } } .#{$prefix}--inline-loading__text { diff --git a/packages/components/src/components/loading/_functions.scss b/packages/components/src/components/loading/_functions.scss new file mode 100644 index 000000000000..b70520a30121 --- /dev/null +++ b/packages/components/src/components/loading/_functions.scss @@ -0,0 +1,10 @@ +// +// Copyright IBM Corp. 2016, 2018 +// +// This source code is licensed under the Apache-2.0 license found in the +// LICENSE file in the root directory of this source tree. +// + +@function loading-progress($circumference, $percentage) { + @return $circumference - $percentage / 100 * $circumference; +} diff --git a/packages/components/src/components/loading/_keyframes.scss b/packages/components/src/components/loading/_keyframes.scss index fa1c5c12520b..496e70c31d0f 100644 --- a/packages/components/src/components/loading/_keyframes.scss +++ b/packages/components/src/components/loading/_keyframes.scss @@ -6,6 +6,7 @@ // @import 'vars'; +@import 'functions'; @keyframes rotate { 0% { @@ -31,18 +32,18 @@ /* Stroke animations */ @keyframes init-stroke { 0% { - stroke-dashoffset: 240; + stroke-dashoffset: loading-progress($circumference, 0); } 100% { - stroke-dashoffset: $loading__gap; + stroke-dashoffset: loading-progress($circumference, 81); } } @keyframes stroke-end { 0% { - stroke-dashoffset: $loading__gap; + stroke-dashoffset: loading-progress($circumference, 81); } 100% { - stroke-dashoffset: 240; + stroke-dashoffset: loading-progress($circumference, 0); } } diff --git a/packages/components/src/components/loading/_loading.scss b/packages/components/src/components/loading/_loading.scss index d1fb593ac724..307d542970e8 100644 --- a/packages/components/src/components/loading/_loading.scss +++ b/packages/components/src/components/loading/_loading.scss @@ -8,9 +8,10 @@ @import '../../globals/scss/vars'; @import '../../globals/scss/css--reset'; @import '../../globals/scss/vendor/@carbon/elements/scss/import-once/import-once'; -@import 'keyframes'; -@import 'mixins'; +@import 'functions'; @import 'vars'; +@import 'mixins'; +@import 'keyframes'; /// Loading styles /// @access private @@ -30,18 +31,18 @@ } .#{$prefix}--loading__svg circle { - stroke-dasharray: 240; + stroke-dasharray: $circumference $circumference; stroke-linecap: butt; stroke-width: 10; } .#{$prefix}--loading__stroke { stroke: $interactive-04; - stroke-dashoffset: $loading__gap; + stroke-dashoffset: loading-progress($circumference, 81); } .#{$prefix}--loading--small .#{$prefix}--loading__stroke { - stroke-dashoffset: $loading--small__gap; + stroke-dashoffset: loading-progress($circumference, 48); } .#{$prefix}--loading--stop { diff --git a/packages/components/src/components/loading/_vars.scss b/packages/components/src/components/loading/_vars.scss index fccdf84c3680..6cfe3b3074d7 100644 --- a/packages/components/src/components/loading/_vars.scss +++ b/packages/components/src/components/loading/_vars.scss @@ -8,12 +8,12 @@ /// @type Number /// @access private /// @group loading -$loading__gap: 16; +$radius: 44; /// @type Number /// @access private /// @group loading -$loading--small__gap: 110; +$circumference: $radius * 2 * 3.1416; /// @type Number /// @access private diff --git a/packages/react/src/components/Loading/Loading.js b/packages/react/src/components/Loading/Loading.js index 0357d6382e9b..23c235cc8da5 100644 --- a/packages/react/src/components/Loading/Loading.js +++ b/packages/react/src/components/Loading/Loading.js @@ -34,7 +34,6 @@ function Loading({ [`${prefix}--loading-overlay--stop`]: !active, }); const loadingId = id || `loading-id-${instanceId}`; - const spinnerRadius = small ? '42' : '44'; const loading = (
) : null}