Skip to content
Merged
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
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: Smooth out animation of indeterminate progress bar",
"packageName": "@fluentui/react-progress",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { makeStyles, mergeClasses, shorthands } from '@griffel/react';
import { tokens } from '@fluentui/react-theme';
import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';
import type { ProgressBarState, ProgressBarSlots } from './ProgressBar.types';
import type { SlotClassNames } from '@fluentui/react-utilities';

Expand All @@ -20,18 +19,10 @@ const barThicknessValues = {

const indeterminateProgressBar = {
'0%': {
left: '-100% /* @noflip */',
left: '-33%', // matches indeterminate bar width
},
'100%': {
left: '100% /* @noflip */',
},
};
const indeterminateProgressBarRTL = {
'100%': {
right: '-100% /* @noflip */',
},
'0%': {
right: '100% /* @noflip */',
left: '100%',
},
};

Expand Down Expand Up @@ -90,17 +81,14 @@ const useBarStyles = makeStyles({
)`,
animationName: indeterminateProgressBar,
animationDuration: '3s',
animationTimingFunction: 'linear',
animationIterationCount: 'infinite',
'@media screen and (prefers-reduced-motion: reduce)': {
animationDuration: '0.01ms',
animationIterationCount: '1',
},
},

rtl: {
animationName: indeterminateProgressBarRTL,
},

brand: {
backgroundColor: tokens.colorCompoundBrandBackground,
},
Expand All @@ -123,7 +111,6 @@ export const useProgressBarStyles_unstable = (state: ProgressBarState): Progress
const { color, max, shape, thickness, value } = state;
const rootStyles = useRootStyles();
const barStyles = useBarStyles();
const { dir } = useFluent();

state.root.className = mergeClasses(
progressBarClassNames.root,
Expand All @@ -139,7 +126,6 @@ export const useProgressBarStyles_unstable = (state: ProgressBarState): Progress
barStyles.base,
barStyles.brand,
value === undefined && barStyles.indeterminate,
value === undefined && dir === 'rtl' && barStyles.rtl,
value !== undefined && value > ZERO_THRESHOLD && barStyles.nonZeroDeterminate,
color && value !== undefined && barStyles[color],
state.bar.className,
Expand Down