Skip to content

Commit

Permalink
chore: clean up / styling adjustments in new toast components
Browse files Browse the repository at this point in the history
  • Loading branch information
chambaz committed Nov 17, 2023
1 parent 3e6a431 commit f9d4203
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 273 deletions.
21 changes: 21 additions & 0 deletions apps/marginfi-v2-ui/src/components/common/Toast/ErrorToast.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { FC } from "react";
import { IconAlertTriangle } from "~/components/ui/icons";

export interface ErrorToastProps {
title: string;
message: string;
}

export const ErrorToast: FC<ErrorToastProps> = ({ title, message }) => {
return (
<div className="w-full h-full bg-black text-white rounded-lg shadow-lg z-50 p-1">
<h2 className="text-lg font-semibold">{title}</h2>
<div className="py-3 text-sm">
<div className="flex items-center space-x-2">
<p className="text-red-400">{message}</p>
<IconAlertTriangle size={18} className="text-red-400" />
</div>
</div>
</div>
);
};
45 changes: 45 additions & 0 deletions apps/marginfi-v2-ui/src/components/common/Toast/MultiStepToast.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { FC } from "react";
import { IconLoader, IconCheck, IconAlertTriangle, IconClockHour4 } from "~/components/ui/icons";

export interface MultiStepToastProps {
title: string;
steps: ToastStepWithStatus[];
}

export interface ToastStep {
label: string;
}

export type ToastStatus = "todo" | "pending" | "success" | "error" | "canceled";

export interface ToastStepWithStatus extends ToastStep {
status: ToastStatus;
message?: string;
}

export const MultiStepToast: FC<MultiStepToastProps> = ({ title, steps }) => {
return (
<div className="w-full h-full bg-black text-white rounded-lg shadow-lg z-50 p-1">
<h2 className="text-lg font-semibold">{title}</h2>
<div className="py-3 text-sm space-y-2">
{steps.map((step, index) => (
<div key={index}>
<div className="flex items-center space-x-2">
<h3>{step.label}</h3>
{step.status === "success" ? (
<IconCheck size={18} className="text-green-400" />
) : step.status === "error" ? (
<IconAlertTriangle size={18} className="text-red-400" />
) : step.status === "pending" ? (
<IconLoader size={18} />
) : (
<IconClockHour4 size={18} />
)}
</div>
{step.message && <p className="text-red-400 mt-1">{step.message}</p>}
</div>
))}
</div>
</div>
);
};
35 changes: 0 additions & 35 deletions apps/marginfi-v2-ui/src/components/common/toasts/ErrorToast.tsx

This file was deleted.

This file was deleted.

2 changes: 2 additions & 0 deletions apps/marginfi-v2-ui/src/components/ui/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
IconArrowDown,
IconExternalLink,
IconUserPlus,
IconClockHour4,
} from "@tabler/icons-react";
import { cn } from "~/utils/themeUtils";

Expand Down Expand Up @@ -301,6 +302,7 @@ export {
IconExternalLink,
IconUserPlus,
IconBrandDiscordFilled,
IconClockHour4,

// customed icons
IconBraveWallet,
Expand Down
2 changes: 1 addition & 1 deletion apps/marginfi-v2-ui/src/utils/toastUtils.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Id, toast } from "react-toastify";
import { ToastStep, ToastStepWithStatus, MultiStepToast, ErrorToast } from "~/components/common/toasts";
import { ToastStep, ToastStepWithStatus, MultiStepToast, ErrorToast } from "~/components/common/Toast";

export class MultiStepToastHandle {
private _title: string;
Expand Down
Loading

0 comments on commit f9d4203

Please sign in to comment.