Skip to content

Commit

Permalink
ProgressBar: Fix indeterminate RTL support (WordPress#63129)
Browse files Browse the repository at this point in the history
* ProgressBar: Fix indeterminate RTL support

* CHANGELOG

Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
  • Loading branch information
4 people authored and carstingaxion committed Jul 18, 2024
1 parent cb4f6f6 commit 18aefd3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- `ToolbarButton`: Deprecate `isDisabled` prop and merge with `disabled` ([#63101](https://github.com/WordPress/gutenberg/pull/63101)).
- `Button`: Stabilize `__experimentalIsFocusable` prop as `accessibleWhenDisabled` ([#62282](https://github.com/WordPress/gutenberg/pull/62282)).
- `ToolbarButton`: Always keep focusable when disabled ([#63102](https://github.com/WordPress/gutenberg/pull/63102)).
- `ProgressBar`: Fix indeterminate RTL support. ([#63129](https://github.com/WordPress/gutenberg/pull/63129)).

### Internal

Expand Down
27 changes: 18 additions & 9 deletions packages/components/src/progress-bar/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,28 @@
import styled from '@emotion/styled';
import { css, keyframes } from '@emotion/react';

/**
* WordPress dependencies
*/
import { isRTL } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import { COLORS, CONFIG } from '../utils';

const animateProgressBar = keyframes( {
'0%': {
left: '-50%',
},
'100%': {
left: '100%',
},
} );
function animateProgressBar( isRtl = false ) {
const animationDirection = isRtl ? 'right' : 'left';

return keyframes( {
'0%': {
[ animationDirection ]: '-50%',
},
'100%': {
[ animationDirection ]: '100%',
},
} );
}

// Width of the indicator for the indeterminate progress bar
export const INDETERMINATE_TRACK_WIDTH = 50;
Expand Down Expand Up @@ -67,7 +76,7 @@ export const Indicator = styled.div< {
animationDuration: '1.5s',
animationTimingFunction: 'ease-in-out',
animationIterationCount: 'infinite',
animationName: animateProgressBar,
animationName: animateProgressBar( isRTL() ),
width: `${ INDETERMINATE_TRACK_WIDTH }%`,
} )
: css( {
Expand Down

0 comments on commit 18aefd3

Please sign in to comment.