Skip to content

Commit 2914f1b

Browse files
committed
feat: add a text spinner widget to the price preview component
1 parent 2b9bc33 commit 2914f1b

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

package-lock.json

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/page-account/lib/AccountPricePreview.tsx

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Tasks } from "@keybr/lang";
12
import { paddlePriceId } from "@keybr/thirdparties";
23
import { Para } from "@keybr/widget";
34
import { type PricePreviewResponse } from "@paddle/paddle-js";
@@ -31,6 +32,26 @@ export function AccountPricePreview() {
3132
}, [paddle]);
3233
const [item = null] = preview?.data?.details?.lineItems ?? [];
3334
return (
34-
<Para>Premium account price: {item?.formattedTotals?.total ?? "..."}</Para>
35+
<Para>
36+
Premium account price: {item?.formattedTotals?.total ?? <Spinner />}
37+
</Para>
3538
);
3639
}
40+
41+
function Spinner() {
42+
const [size, setSize] = useState(3);
43+
useEffect(() => {
44+
const tasks = new Tasks();
45+
tasks.delayed(100, () => {
46+
if (size >= 3) {
47+
setSize(0);
48+
} else {
49+
setSize(size + 1);
50+
}
51+
});
52+
return () => {
53+
tasks.cancelAll();
54+
};
55+
}, [size]);
56+
return <span>{"".padStart(size, ".")}</span>;
57+
}

packages/page-account/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"dependencies": {
99
"@keybr/debug": "*",
1010
"@keybr/intl": "*",
11+
"@keybr/lang": "*",
1112
"@keybr/pages-shared": "*",
1213
"@keybr/request": "*",
1314
"@keybr/thirdparties": "*",

0 commit comments

Comments
 (0)