Skip to content

Commit 55a4728

Browse files
committed
packages/ui: Add Spinner, Img (#7925)
<!-- ## 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 primarily focuses on refactoring the `Spinner` component across multiple applications by centralizing its import path and removing redundant files. It also introduces a new spinner style in the Tailwind configuration. ### Detailed summary - Deleted multiple `Spinner.tsx` and `Spinner.module.css` files from various directories. - Updated imports of `Spinner` to a centralized path: `@workspace/ui/components/spinner`. - Added new spinner animation styles in `tailwind.config.ts`. - Updated the `Spinner` component to use Tailwind classes for styling instead of CSS modules. - Adjusted stories for `Spinner` to reflect the new structure and styles. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent c5ef55e commit 55a4728

File tree

143 files changed

+269
-458
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+269
-458
lines changed

apps/dashboard/src/@/components/billing/renew-subscription-button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { toast } from "sonner";
77
import { reSubscribePlan } from "@/actions/billing";
88
import type { Team } from "@/api/team/get-team";
99
import { Button } from "@/components/ui/button";
10-
import { Spinner } from "@/components/ui/Spinner/Spinner";
10+
import { Spinner } from "@/components/ui/Spinner";
1111
import { useDashboardRouter } from "@/lib/DashboardRouter";
1212
import { pollWithTimeout } from "@/utils/pollWithTimeout";
1313
import { tryCatch } from "@/utils/try-catch";

apps/dashboard/src/@/components/blocks/DangerSettingCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
DialogTitle,
1111
DialogTrigger,
1212
} from "@/components/ui/dialog";
13-
import { Spinner } from "@/components/ui/Spinner/Spinner";
13+
import { Spinner } from "@/components/ui/Spinner";
1414
import { cn } from "../../lib/utils";
1515
import { DynamicHeight } from "../ui/DynamicHeight";
1616

apps/dashboard/src/@/components/blocks/ExportToCSVButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { DownloadIcon } from "lucide-react";
33
import Papa from "papaparse";
44
import { toast } from "sonner";
55
import { Button } from "@/components/ui/button";
6-
import { Spinner } from "@/components/ui/Spinner/Spinner";
6+
import { Spinner } from "@/components/ui/Spinner";
77
import { cn } from "../../lib/utils";
88

99
export function ExportToCSVButton(props: {
Lines changed: 1 addition & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,3 @@
1-
/* eslint-disable @next/next/no-img-element */
21
"use client";
3-
import { useRef, useState } from "react";
4-
import { cn } from "@/lib/utils";
5-
import { useIsomorphicLayoutEffect } from "../../lib/useIsomorphicLayoutEffect";
62

7-
type imgElementProps = React.DetailedHTMLProps<
8-
React.ImgHTMLAttributes<HTMLImageElement>,
9-
HTMLImageElement
10-
> & {
11-
skeleton?: React.ReactNode;
12-
fallback?: React.ReactNode;
13-
src: string | undefined;
14-
containerClassName?: string;
15-
};
16-
17-
export function Img(props: imgElementProps) {
18-
const [_status, setStatus] = useState<"pending" | "fallback" | "loaded">(
19-
"pending",
20-
);
21-
const status =
22-
props.src === undefined
23-
? "pending"
24-
: props.src === ""
25-
? "fallback"
26-
: _status;
27-
const { className, fallback, skeleton, containerClassName, ...restProps } =
28-
props;
29-
const defaultSkeleton = <div className="animate-pulse bg-accent" />;
30-
const defaultFallback = <div className="bg-accent" />;
31-
const imgRef = useRef<HTMLImageElement>(null);
32-
33-
useIsomorphicLayoutEffect(() => {
34-
const imgEl = imgRef.current;
35-
if (!imgEl) {
36-
return;
37-
}
38-
if (imgEl.complete) {
39-
setStatus("loaded");
40-
} else {
41-
function handleLoad() {
42-
setStatus("loaded");
43-
}
44-
imgEl.addEventListener("load", handleLoad);
45-
return () => {
46-
imgEl.removeEventListener("load", handleLoad);
47-
};
48-
}
49-
}, []);
50-
51-
return (
52-
<div className={cn("relative shrink-0", containerClassName)}>
53-
<img
54-
{...restProps}
55-
// avoid setting empty src string to prevent request to the entire page
56-
alt={restProps.alt || ""}
57-
className={cn(
58-
"fade-in-0 object-cover transition-opacity duration-300",
59-
className,
60-
)}
61-
decoding="async"
62-
onError={() => {
63-
setStatus("fallback");
64-
}}
65-
ref={imgRef}
66-
src={restProps.src || undefined}
67-
style={{
68-
opacity: status === "loaded" ? 1 : 0,
69-
...restProps.style,
70-
}}
71-
/>
72-
73-
{status !== "loaded" && (
74-
<div
75-
className={cn(
76-
"fade-in-0 absolute inset-0 overflow-hidden transition-opacity duration-300 [&>*]:h-full [&>*]:w-full",
77-
className,
78-
)}
79-
style={restProps.style}
80-
>
81-
{status === "pending" && (skeleton || defaultSkeleton)}
82-
{status === "fallback" && (fallback || defaultFallback)}
83-
</div>
84-
)}
85-
</div>
86-
);
87-
}
3+
export { Img } from "@workspace/ui/components/img";

apps/dashboard/src/@/components/blocks/RouteDiscoveryCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type React from "react";
22
import { Button } from "@/components/ui/button";
3-
import { Spinner } from "@/components/ui/Spinner/Spinner";
3+
import { Spinner } from "@/components/ui/Spinner";
44
import { cn } from "@/lib/utils";
55

66
export function RouteDiscoveryCard(

apps/dashboard/src/@/components/blocks/SettingsCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type React from "react";
22
import { Button } from "@/components/ui/button";
3-
import { Spinner } from "@/components/ui/Spinner/Spinner";
3+
import { Spinner } from "@/components/ui/Spinner";
44
import { cn } from "@/lib/utils";
55

66
export function SettingsCard(

apps/dashboard/src/@/components/blocks/TWTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
DropdownMenuItem,
2020
DropdownMenuTrigger,
2121
} from "@/components/ui/dropdown-menu";
22-
import { Spinner } from "@/components/ui/Spinner/Spinner";
22+
import { Spinner } from "@/components/ui/Spinner";
2323
import { Separator } from "@/components/ui/separator";
2424
import {
2525
Table,

apps/dashboard/src/@/components/blocks/TokenSelector.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import type { TokenMetadata } from "@/api/universal-bridge/tokens";
99
import { Img } from "@/components/blocks/Img";
1010
import { SelectWithSearch } from "@/components/blocks/select-with-search";
1111
import { Badge } from "@/components/ui/badge";
12+
import { Spinner } from "@/components/ui/Spinner";
1213
import { fallbackChainIcon } from "@/constants/chain";
1314
import { useAllChainsData } from "@/hooks/chains/allChains";
1415
import { useTokensData } from "@/hooks/tokens";
1516
import { cn } from "@/lib/utils";
1617
import { resolveSchemeWithErrorHandler } from "@/utils/resolveSchemeWithErrorHandler";
17-
import { Spinner } from "../ui/Spinner/Spinner";
1818

1919
type Option = { label: string; value: string };
2020

apps/dashboard/src/@/components/blocks/multi-step-status/multi-step-status.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import {
77
RefreshCwIcon,
88
} from "lucide-react";
99
import { Button } from "@/components/ui/button";
10-
import { DynamicHeight } from "../../ui/DynamicHeight";
11-
import { Spinner } from "../../ui/Spinner/Spinner";
10+
import { DynamicHeight } from "@/components/ui/DynamicHeight";
11+
import { Spinner } from "@/components/ui/Spinner";
1212

1313
export type MultiStepState<T extends string> = {
1414
id: T;

apps/dashboard/src/@/components/blocks/skeletons/GenericLoadingPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22

3-
import { Spinner } from "@/components/ui/Spinner/Spinner";
3+
import { Spinner } from "@/components/ui/Spinner";
44
import { cn } from "@/lib/utils";
55

66
export function GenericLoadingPage({ className }: { className?: string }) {

0 commit comments

Comments
 (0)