Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.

Commit 236d566

Browse files
committed
feat(spinner): synchronize spinners
If a spinner is unmounted and remounted, or if two different spinners are render after each other they will animation will jump between different states. This adds a synchronization to the spinners so they always will render at the same state at the same time.
1 parent cafaf99 commit 236d566

File tree

8 files changed

+39
-35
lines changed

8 files changed

+39
-35
lines changed

.pnp.cjs

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.
Binary file not shown.

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"focus-trap-react": "8.11.0",
1414
"no-scroll": "2.1.1",
1515
"practical-react-components-icons": "workspace:*",
16-
"react-hooks-shareable": "1.49.0",
16+
"react-hooks-shareable": "1.50.1",
1717
"tabbable": "5.3.1"
1818
},
1919
"devDependencies": {

packages/core/src/Spinner/index.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { HTMLAttributes, FC } from 'react'
2+
import { useSynchronizedAnimation } from 'react-hooks-shareable'
23
import styled, { keyframes, css } from 'styled-components'
34

45
import { shape, componentSize, spacing } from '../designparams'
@@ -85,13 +86,16 @@ export const Spinner: FC<SpinnerProps> = ({
8586
type = 'primary',
8687
label,
8788
...props
88-
}) => (
89-
<Container {...props}>
90-
<Circle type={type} />
91-
{label !== undefined && label.length > 0 ? (
92-
<Label>
93-
<Typography variant="navigation-label">{label}</Typography>
94-
</Label>
95-
) : null}
96-
</Container>
97-
)
89+
}) => {
90+
const ref = useSynchronizedAnimation<HTMLDivElement>()
91+
return (
92+
<Container {...props}>
93+
<Circle type={type} ref={ref} />
94+
{label !== undefined && label.length > 0 ? (
95+
<Label>
96+
<Typography variant="navigation-label">{label}</Typography>
97+
</Label>
98+
) : null}
99+
</Container>
100+
)
101+
}

packages/docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"prism-react-renderer": "1.3.1",
2222
"react": "18.1.0",
2323
"react-dom": "18.1.0",
24-
"react-hooks-shareable": "1.49.0",
24+
"react-hooks-shareable": "1.50.1",
2525
"react-is": "18.1.0",
2626
"react-live": "2.4.1",
2727
"react-router-dom": "6.3.0",

packages/ui-tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"practical-react-components-icons": "workspace:*",
1515
"react": "18.1.0",
1616
"react-dom": "18.1.0",
17-
"react-hooks-shareable": "1.49.0",
17+
"react-hooks-shareable": "1.50.1",
1818
"react-is": "18.1.0",
1919
"react-router-dom": "6.3.0",
2020
"regenerator-runtime": "0.13.9",

yarn.lock

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12367,7 +12367,7 @@ __metadata:
1236712367
prop-types: 15.8.1
1236812368
react: 18.1.0
1236912369
react-dom: 18.1.0
12370-
react-hooks-shareable: 1.49.0
12370+
react-hooks-shareable: 1.50.1
1237112371
react-is: 18.1.0
1237212372
react-test-renderer: 18.1.0
1237312373
react-transition-group: 4.4.2
@@ -12424,7 +12424,7 @@ __metadata:
1242412424
react: 18.1.0
1242512425
react-docgen-typescript: 2.2.2
1242612426
react-dom: 18.1.0
12427-
react-hooks-shareable: 1.49.0
12427+
react-hooks-shareable: 1.50.1
1242812428
react-is: 18.1.0
1242912429
react-live: 2.4.1
1243012430
react-router-dom: 6.3.0
@@ -12539,7 +12539,7 @@ __metadata:
1253912539
practical-react-components-icons: "workspace:*"
1254012540
react: 18.1.0
1254112541
react-dom: 18.1.0
12542-
react-hooks-shareable: 1.49.0
12542+
react-hooks-shareable: 1.50.1
1254312543
react-is: 18.1.0
1254412544
react-router-dom: 6.3.0
1254512545
regenerator-runtime: 0.13.9
@@ -12894,13 +12894,13 @@ __metadata:
1289412894
languageName: node
1289512895
linkType: hard
1289612896

12897-
"react-hooks-shareable@npm:1.49.0":
12898-
version: 1.49.0
12899-
resolution: "react-hooks-shareable@npm:1.49.0"
12897+
"react-hooks-shareable@npm:1.50.1":
12898+
version: 1.50.1
12899+
resolution: "react-hooks-shareable@npm:1.50.1"
1290012900
peerDependencies:
1290112901
"@juggle/resize-observer": ^3.3.1
1290212902
react: ^17.0.2 || ^18.0.0
12903-
checksum: 535d788055e1e844332dd3402c49d2f37908877bd4496a4862233fad4dd0e1a647173e55392b86133918131a1cbd6891510756885c7569f470116502365186b3
12903+
checksum: 9ca8f8c5dcb434dff51d6b6a9da8c898d05aea9f4d0585b579f52feed016a7bf6f45f1b515582b9ec716a361d974f80d6495e2318308ff284d348f3e75293940
1290412904
languageName: node
1290512905
linkType: hard
1290612906

0 commit comments

Comments
 (0)