Skip to content

Commit 38f4a89

Browse files
committed
[MNY-334] SDK: Fix Spinner animation missing sometimes in Next.js (#8553)
<!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR addresses an issue with the `Spinner` component's animation in a Next.js environment, ensuring that the animation works consistently. ### Detailed summary - Updated the `Spinner` component to use a `<circle>` element instead of a `Circle` styled component. - Removed the `StyledCircle` import from `elements.js`. - Added animation styles directly to the `<circle>` element. - Defined the `tw-spinner-circle-dash` keyframe animation within the component. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 31e24f1 commit 38f4a89

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

.changeset/violet-needles-fly.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Fix Spinner animation not working sometimes in Next.js

packages/thirdweb/src/react/web/ui/components/Spinner.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { keyframes } from "@emotion/react";
33
import { useCustomTheme } from "../../../core/design-system/CustomThemeProvider.js";
44
import type { Theme } from "../../../core/design-system/index.js";
55
import { iconSize } from "../../../core/design-system/index.js";
6-
import { StyledCircle, StyledSvg } from "../design-system/elements.js";
6+
import { StyledSvg } from "../design-system/elements.js";
77

88
/**
99
* @internal
@@ -24,20 +24,25 @@ export const Spinner: React.FC<{
2424
viewBox="0 0 50 50"
2525
className="tw-spinner"
2626
>
27-
<Circle
27+
<circle
2828
cx="25"
2929
cy="25"
3030
fill="none"
3131
r="20"
32+
style={{
33+
strokeLinecap: "round",
34+
animation: `tw-spinner-circle-dash 1.5s ease-in-out infinite`,
35+
}}
3236
stroke={props.color ? theme.colors[props.color] : "currentColor"}
3337
strokeWidth={Number(iconSize[props.size]) > 64 ? "2" : "4"}
3438
/>
39+
<style>{dashAnimation}</style>
3540
</Svg>
3641
);
3742
};
38-
3943
// animations
40-
const dashAnimation = keyframes`
44+
const dashAnimation = `
45+
@keyframes tw-spinner-circle-dash {
4146
0% {
4247
stroke-dasharray: 1, 150;
4348
stroke-dashoffset: 0;
@@ -63,8 +68,3 @@ const Svg = /* @__PURE__ */ StyledSvg({
6368
height: "1em",
6469
width: "1em",
6570
});
66-
67-
const Circle = /* @__PURE__ */ StyledCircle({
68-
animation: `${dashAnimation} 1.5s ease-in-out infinite`,
69-
strokeLinecap: "round",
70-
});

packages/thirdweb/src/react/web/ui/design-system/elements.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import styled from "@emotion/styled";
22

33
export const StyledDiv = /* @__PURE__ */ styled.div;
44
export const StyledSvg = /* @__PURE__ */ styled.svg;
5-
export const StyledCircle = /* @__PURE__ */ styled.circle;
65
export const StyledSpan = /* @__PURE__ */ styled.span;
76
export const StyledAnchor = /* @__PURE__ */ styled.a;
87
export const StyledButton = /* @__PURE__ */ styled.button;

0 commit comments

Comments
 (0)