Skip to content

[Progress bars]: Bundle theme styles with component #15720

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: simeonoff/scoped-styles
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -536,21 +536,21 @@
// @include paginator($paginator-theme-map);
// }

@if is-used('igx-circular-bar', $exclude) {
$progress-circular-theme-map: progress-circular-theme(
$schema: $schema,
);
$progress-circular-theme-map: meta.call($theme-handler, $progress-circular-theme-map);
@include progress-circular($progress-circular-theme-map);
}
//@if is-used('igx-circular-bar', $exclude) {
// $progress-circular-theme-map: progress-circular-theme(
// $schema: $schema,
// );
// $progress-circular-theme-map: meta.call($theme-handler, $progress-circular-theme-map);
// @include progress-circular($progress-circular-theme-map);
//}

@if is-used('igx-linear-bar', $exclude) {
$progress-linear-theme-map: progress-linear-theme(
$schema: $schema,
);
$progress-linear-theme-map: meta.call($theme-handler, $progress-linear-theme-map);
@include progress-linear($progress-linear-theme-map);
}
//@if is-used('igx-linear-bar', $exclude) {
// $progress-linear-theme-map: progress-linear-theme(
// $schema: $schema,
// );
// $progress-linear-theme-map: meta.call($theme-handler, $progress-linear-theme-map);
// @include progress-linear($progress-linear-theme-map);
//}

// @if is-used('igx-radio', $exclude) {
// $radio-theme-map: radio-theme(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<svg #svg
role="progressbar"
aria-valuemin="0"
[ngClass]="{'igx-circular-svg': true, 'igx-circular-svg--indeterminate': indeterminate}"
[attr.aria-valuemax]="max"
[attr.aria-valuenow]="value">
<svg:circle class="igx-circular-bar__inner" />
<svg:circle #circle class="igx-circular-bar__outer"/>
<svg:circle class="igx-circular-svg__inner" />
<svg:circle #circle class="igx-circular-bar__outer igx-circular-svg__outer"/>

<svg:defs>
<ng-container
Expand All @@ -15,8 +16,8 @@

<ng-template #defaultGradientTemplate>
<svg:linearGradient [id]="gradientId" gradientTransform="rotate(90)">
<stop offset="0%" class="igx-circular-bar__gradient-start" />
<stop offset="100%" class="igx-circular-bar__gradient-end" />
<stop offset="0%" class="igx-circular-svg__gradient-start" />
<stop offset="100%" class="igx-circular-svg__gradient-end" />
</svg:linearGradient>
</ng-template>
</svg>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@use 'themes/base';
@use 'themes/shared';
@use 'themes/light';
@use 'themes/dark';
Original file line number Diff line number Diff line change
@@ -0,0 +1,261 @@
@use 'sass:map';
@use 'igniteui-theming/sass/typography/index' as *;
@use 'igniteui-theming/sass/bem/index' as *;
@use 'igniteui-theming/sass/themes/index' as *;
@use 'igniteui-theming/sass/animations' as *;
@use 'styles/themes/standalone' as *;
@use 'light/tokens' as *;

$theme: $base;
$diameter: calc(var(--circular-size) + var(--stroke-thickness));
$radius: calc(var(--circular-size) / 2 - var(--stroke-thickness) * .5);
$circumference: calc(#{$radius} * 2 * 3.1416);

%circle {
width: 100%;
height: 100%;
fill: transparent;
cx: calc(#{$diameter} / 2);
cy: calc(#{$diameter} / 2);
r: $radius;
transform-origin: center;
}

@keyframes igx-indeterminate-accordion {
0% {
stroke-dashoffset: calc(#{$circumference} * 2);
stroke-dasharray: calc(#{$circumference} * 9 / 10);
}

100% {
stroke-dashoffset: calc(#{$circumference} * 2 / 5);
}
}

@keyframes igx-indeterminate-accordion-rtl {
0% {
stroke-dashoffset: calc(#{$circumference} * -2);
stroke-dasharray: calc(#{$circumference} * 9 / 10);
}

100% {
stroke-dashoffset: calc(#{$circumference} * -2 / 5);
}
}

// Fluent: Circular progress animation for indeterminate state.
// Dynamically changes stroke-dasharray and rotates for a smooth spinning effect.
@keyframes igx-indeterminate-circular-fluent {
0% {
// Start the stroke at the correct position by adjusting the dasharray and dashoffset
stroke-dasharray: calc(#{$circumference} * 0.0001), #{$circumference};
stroke-dashoffset: calc(-1 * #{$circumference} / 4);

// Start at 12 o'clock
transform: rotate(-90deg);
}

50% {
stroke-dasharray: calc(#{$circumference} / 2), calc(#{$circumference} / 2);

// Adjust to keep starting point correct
stroke-dashoffset: calc(-1 * #{$circumference} / 4);

// Continue rotating smoothly
transform: rotate(360deg);
}

100% {
stroke-dasharray: calc(#{$circumference} * 0.0001), #{$circumference};

// Reset properly
stroke-dashoffset: calc(-1 * #{$circumference} / 4);

// Complete the full rotation
transform: rotate(990deg);
}
}

@keyframes igx-indeterminate-circular-fluent-rtl {
0% {
stroke-dasharray: calc(#{$circumference} * 0.0001), #{$circumference};

// Positive offset for opposite direction
stroke-dashoffset: calc(#{$circumference} / 4);
transform: rotate(90deg);
}

50% {
stroke-dasharray: calc(#{$circumference} / 2), calc(#{$circumference} / 2);

// Positive offset for opposite direction
stroke-dashoffset: calc(#{$circumference} / 4);
transform: rotate(-360deg);
}

100% {
stroke-dasharray: calc(#{$circumference} * 0.0001), #{$circumference};

// Positive offset for opposite direction
stroke-dashoffset: calc(#{$circumference} / 4);
transform: rotate(-990deg);
}
}

@keyframes igx-initial-dashoffset {
from {
/* Start with no progress (0%) */
stroke-dashoffset: #{$circumference};
}

to {
stroke-dashoffset: calc(#{$circumference} - var(--_progress-percentage) * #{$circumference});
}
}

// Generic animations
@keyframes igc-initial-counter {
from {
--_progress-integer: 0;
--_progress-fraction: 0;
}
}

@keyframes igx-rotate-center {
0% {
transform: rotate(0);
}

100% {
transform: rotate(360deg);
}
}
Comment on lines +14 to +132
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put these in a separate file to clean this up a bit. Also make sure to put the keyframes in the base layer.


@include layer(base) {
@include b(igx-circular-bar) {
--circular-size: calc(#{var-get($theme, 'diameter')} - var(--stroke-thickness));

display: inline-flex;
align-items: center;
justify-content: center;
position: relative;


@include e(text) {
position: absolute;
color: var-get($theme, 'text-color');
font-size: round(calc(#{var-get($theme, 'diameter')} / var(--scale-factor) - var(--stroke-thickness)), 1px);
line-height: normal;
text-align: center;
font-weight: 600;

animation: igx-initial-counter var(--_transition-duration) ease-in-out;
counter-reset:
progress-integer var(--_progress-integer, 0)
progress-fraction var(--_progress-fraction, 0);
transition:
--_progress-integer var(--_transition-duration) ease-in-out,
--_progress-fraction var(--_transition-duration) ease-in-out;
}

@include e(text, $not: ('fraction')) {
&::before {
content: counter(progress-integer) '%';
}
}

@include e(value, $m: fraction) {
&::before {
content: counter(progress-integer) '.' counter(progress-fraction, decimal-leading-zero) '%';
}
}

@include m(indeterminate) {
@include e(text) {
visibility: hidden;
}
}

@each $modifier in ('danger', 'warning', 'info', 'success') {
@include m($modifier) {
@include e(outer) {
stroke: var-get($theme, 'fill-color-#{$modifier}');
}
}
}

@include m(animation-none) {
--_transition-duration: 0s !important;
}

@include m(hide-counter) {
@include e(text) {
&::before {
display: none;
}
}
}
}

@include b(igx-circular-svg) {
width: $diameter;
height: $diameter;
transform: rotate(-90deg);
transform-origin: center;

@include e(gradient-start) {
stop-color: var(--igx-circular-bar-fill-color-default-end, var(--fill-color-default-end));
}

@include e(gradient-end) {
stop-color: var(--igx-circular-bar-fill-color-default-start, var(--fill-color-default-start));
}

@include e(inner) {
@extend %circle;

stroke-width: var(--stroke-thickness);
stroke: var-get($theme, 'base-circle-color');
}

@include e(outer) {
--_progress-percentage: calc(var(--_progress-whole, 0) / 100);

@extend %circle;

transition: stroke-dashoffset var(--_transition-duration) linear;

stroke: var-get($theme, 'fill-color-default');
stroke-dasharray: #{$circumference} #{$circumference};
stroke-dashoffset: calc(#{$circumference} - var(--_progress-percentage) * #{$circumference});
}

@include m(indeterminate) {
@include e(outer) {
stroke-dashoffset: calc(#{$circumference} * 2);
animation: igx-indeterminate-accordion 1.5s cubic-bezier(0, 0.085, 0.68, 0.53) normal infinite;
}

&:dir(rtl) {
@include e(outer) {
stroke-dashoffset: calc(#{$circumference} + var(--_progress-percentage) * #{$circumference});
}
}
}
}

.igx-circular-svg:not(.igx-circular-svg--indeterminate) {
.igx-circular-svg__outer {
animation: igx-initial-dashoffset var(--_transition-duration) linear;
stroke-dasharray: #{$circumference} #{$circumference};
stroke-dashoffset: calc(#{$circumference} - var(--_progress-percentage) * #{$circumference});
}

&:dir(rtl) {
.igx-circular-svg__outer {
animation: igx-initial-dashoffset-rtl var(--_transition-duration) linear;
animation-direction: reverse;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@use 'sass:meta';
@use 'tokens';
@use 'styles/themes/standalone' as *;

$tokens: meta.module-variables(tokens);
@include themes(igx-circular-bar, $tokens, dark);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@use 'igniteui-theming/sass/themes/index' as *;
@use 'igniteui-theming/sass/themes/schemas/components/dark/progress' as *;

$base: digest-schema($dark-base-progress-circular);
$material: digest-schema($dark-material-progress-circular);
$bootstrap: digest-schema($dark-bootstrap-progress-circular);
$fluent: digest-schema($dark-fluent-progress-circular);
$indigo: digest-schema($dark-indigo-progress-circular);
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@use 'sass:meta';
@use 'tokens';
@use 'styles/themes/standalone' as *;

$tokens: meta.module-variables(tokens);
@include themes(igx-circular-bar, $tokens, light);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@use 'igniteui-theming/sass/themes/index' as *;
@use 'igniteui-theming/sass/themes/schemas/components/light/progress' as *;

$base: digest-schema($light-progress-circular);
$material: digest-schema($material-progress-circular);
$bootstrap: digest-schema($bootstrap-progress-circular);
$fluent: digest-schema($fluent-progress-circular);
$indigo: digest-schema($indigo-progress-circular);
Loading