Skip to content

Commit c7cd1f4

Browse files
committed
fix(ToastUI): Fixes alignment and width
1 parent 6674f65 commit c7cd1f4

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

apps/webapp/app/components/primitives/Toast.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,29 @@ export function Toast() {
2222
});
2323
}, [toastMessage]);
2424

25-
return <Toaster />;
25+
return <Toaster className="" />;
2626
}
2727

2828
export function ToastUI({
2929
variant,
3030
message,
3131
t,
32+
toastWidth = 356, // Default width, matches what sonner provides by default
3233
}: {
3334
variant: "error" | "success";
3435
message: string;
3536
t: string;
37+
toastWidth?: string | number;
3638
}) {
3739
return (
38-
<div className="rounded-lg border border-slate-750 bg-midnight-900 shadow-md">
40+
<div
41+
className={`self-end rounded-lg border border-slate-750 bg-midnight-900 shadow-md`}
42+
style={{
43+
width: toastWidth,
44+
}}
45+
>
3946
<div
40-
className="flex gap-2 rounded-lg bg-no-repeat p-4 text-bright"
47+
className="flex w-full gap-2 rounded-lg bg-no-repeat p-4 text-bright"
4148
style={{
4249
background:
4350
"radial-gradient(at top, hsla(271, 91%, 65%, 0.18), hsla(221, 83%, 53%, 0.18)) hsla(221, 83%, 53%, 0.18)",
@@ -49,7 +56,7 @@ export function ToastUI({
4956
<ExclamationCircleIcon className="h-6 w-6 text-rose-600" />
5057
)}
5158
{message}
52-
<button className="p-1" onClick={() => toast.dismiss(t)}>
59+
<button className="ms-auto p-1" onClick={() => toast.dismiss(t)}>
5360
<XMarkIcon className="h-4 w-4 text-bright" />
5461
</button>
5562
</div>

apps/webapp/app/components/stories/ToastUI.stories.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import type { Meta, StoryObj } from "@storybook/react";
22
import { Toaster, toast } from "sonner";
33
import { ToastUI } from "../primitives/Toast";
4-
import { ExclamationCircleIcon, XMarkIcon } from "@heroicons/react/20/solid";
5-
import { CheckCircleIcon } from "@heroicons/react/24/solid";
64
import { Button } from "../primitives/Buttons";
75

86
const meta: Meta = {
@@ -27,7 +25,7 @@ function Collection() {
2725
variant="primary/large"
2826
onClick={() =>
2927
toast.custom((t) => <ToastUI variant="success" message="Success" t={t as string} />, {
30-
duration: 5000,
28+
duration: Infinity, // Prevents auto-dismissal for demo purposes
3129
})
3230
}
3331
>
@@ -37,7 +35,7 @@ function Collection() {
3735
variant="primary/large"
3836
onClick={() =>
3937
toast.custom((t) => <ToastUI variant="error" message="Error" t={t as string} />, {
40-
duration: 5000,
38+
duration: Infinity,
4139
})
4240
}
4341
>

0 commit comments

Comments
 (0)