Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(toast): introduce Toast component #4437

Draft
wants to merge 38 commits into
base: canary
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
bd9146d
feat: initial commit
macci001 Dec 21, 2024
42f2ecd
chore: adding the animation
macci001 Dec 24, 2024
2a73f8a
chore: nits
macci001 Dec 24, 2024
f479b3b
chore: fixes and adding draft1 of stories
macci001 Dec 25, 2024
df7d9c4
chore: adding the docs draft
macci001 Dec 26, 2024
26f05d7
chore: adding the swiping interaction for toast removal
macci001 Dec 26, 2024
b21d91a
chore: adding the tests
macci001 Dec 27, 2024
a36b58a
fix: improving the progress bar logix
macci001 Dec 27, 2024
b04b54b
chore: refactoring and refining the animations
macci001 Dec 27, 2024
68eea8b
fix: making the animations compatible with the positons
macci001 Dec 28, 2024
4c36049
chore: fixing the styles
macci001 Dec 28, 2024
5530248
chore: modifying the animations
macci001 Dec 30, 2024
6823ce5
chore: improving the animations
macci001 Dec 31, 2024
beb4988
chore: adding the decorator to the story-book
macci001 Dec 31, 2024
03d8685
chore: fixing the animations and positions
macci001 Jan 1, 2025
983d94f
fix: handle expand region on touch
macci001 Jan 1, 2025
c38a181
feat: adding the promises support
macci001 Jan 1, 2025
5c322ae
chore: updating the styles
macci001 Jan 1, 2025
4871b60
chore: improving styles
macci001 Jan 2, 2025
404dddf
chore: styles correction
jrgarciadev Jan 5, 2025
012d422
fix: adding junior's suggestions
macci001 Jan 6, 2025
ce3032d
chore: correcting styles
macci001 Jan 6, 2025
792a691
fix: fixing the timer behavior
macci001 Jan 8, 2025
2c38868
chore: adding the spinner to the toast
macci001 Jan 8, 2025
e4a836a
chore: full width for mobile
macci001 Jan 8, 2025
5154678
chore: modifying styles
macci001 Jan 8, 2025
1678ff6
chore: fixing the positions on smaller devices
macci001 Jan 8, 2025
48bfc0e
chore: adding story with description
macci001 Jan 8, 2025
a1a43fc
chore: adding credits for sonner
macci001 Jan 8, 2025
1e1b1b4
fix: adding junior's suggestions
macci001 Jan 8, 2025
6dd58dd
chore: adding the exit animation
macci001 Jan 8, 2025
f28f578
fix: adding junior's suggestions
macci001 Jan 9, 2025
62bd839
chore: improving the swipe animations
macci001 Jan 9, 2025
a553719
fix: fixing the swipe animations on touch
macci001 Jan 10, 2025
26e4599
chore: adding tests
macci001 Jan 10, 2025
0f59b66
chore: adding swipe threshild and initial position variable
macci001 Jan 10, 2025
f14e526
fix: fixing autoclose in timeout
macci001 Jan 10, 2025
39acb34
chore: modifying the docs
macci001 Jan 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/shaggy-beers-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@nextui-org/shared-icons": patch
"@nextui-org/toast": patch
"@nextui-org/theme": patch
---

Introducing the toast component(#2560)
31 changes: 31 additions & 0 deletions apps/docs/app/examples/toast/color/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"use client";
import {addToast, Button, ToastProvider} from "@nextui-org/react";

export default function App() {
return (
<>
<ToastProvider />
<div className="flex flex-wrap gap-x-2">
{["default", "primary", "secondary", "success", "warning", "danger"].map((color) => (
<Button
key={color}
className="w-fit m-2"
// @ts-ignore
color={color}
variant={"bordered"}
onPress={() =>
addToast({
title: "Toast title",
description: "Toast displayed successfully",
// @ts-ignore
color: color,
})
}
>
Show {color} toast
</Button>
))}
</div>
</>
);
}
39 changes: 39 additions & 0 deletions apps/docs/app/examples/toast/custom-icon/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"use client";
import {addToast, Button, ToastProvider} from "@nextui-org/react";

export default function App() {
return (
<>
<ToastProvider />
<Button
className="w-fit m-2"
onPress={() =>
addToast({
title: "Toast title",
description: "Toast displayed successfully",
icon: (
<svg height={24} viewBox="0 0 24 24" width={24}>
<g
fill="none"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeMiterlimit={10}
strokeWidth={1.5}
>
<path
d="M11.845 21.662C8.153 21.662 5 21.088 5 18.787s3.133-4.425 6.845-4.425c3.692 0 6.845 2.1 6.845 4.4s-3.134 2.9-6.845 2.9z"
data-name="Stroke 1"
/>
<path d="M11.837 11.174a4.372 4.372 0 10-.031 0z" data-name="Stroke 3" />
</g>
</svg>
),
})
}
>
Show toast with custom icon
</Button>
</>
);
}
57 changes: 57 additions & 0 deletions apps/docs/app/examples/toast/custom-style/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"use client";

import {addToast, Button, cn, ToastProvider} from "@nextui-org/react";

const CustomToastComponent = () => {
return (
<>
<Button
className="m-2"
onPress={() => {
addToast({
title: "Sucessful!",
description: "Document uploaded to cloud successful.",
classNames: {
base: cn([
"bg-default-50 dark:bg-background shadow-sm",
"border-1",
"relative before:content-[''] before:absolute before:z-10",
"before:left-0 before:top-[-1px] before:bottom-[-1px] before:w-1",
"rounded-l-none border-l-0",
"min-w-[350px]",
"rounded-md",
"flex flex-col items-start",
"before:bg-primary border-primary-200 dark:border-primary-100",
,
]),
icon: "w-6 h-6 fill-current",
},
endContent: (
<div className="ms-11 my-2 flex gap-x-2">
<Button color={"primary"} size="sm" variant="bordered">
View Document
</Button>
<Button className="underline-offset-2" color={"primary"} size="sm" variant="light">
Maybe Later
</Button>
</div>
),
});
}}
>
Show Toast
</Button>
</>
);
};

export default function App() {
return (
<>
<ToastProvider />
<div className="flex gap-2">
<CustomToastComponent />
</div>
</>
);
}
22 changes: 22 additions & 0 deletions apps/docs/app/examples/toast/hidden-icon/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"use client";
import {addToast, Button, ToastProvider} from "@nextui-org/react";

export default function App() {
return (
<>
<ToastProvider />
<Button
className="w-fit m-2"
onPress={() =>
addToast({
title: "Toast title",
description: "Toast displayed successfully",
hideIcon: true,
})
}
>
Show toast with hidden icon
</Button>
</>
);
}
23 changes: 23 additions & 0 deletions apps/docs/app/examples/toast/position/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"use client";
import {addToast, Button, ToastProvider} from "@nextui-org/react";

export default function App() {
return (
<>
<ToastProvider position="center-bottom" />
<div className="flex flex-wrap gap-x-2">
<Button
className="w-fit m-2"
onPress={() =>
addToast({
title: "Toast title",
description: "Toast displayed successfully",
})
}
>
Show toast at right-top
</Button>
</div>
</>
);
}
31 changes: 31 additions & 0 deletions apps/docs/app/examples/toast/radius/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"use client";

import {addToast, Button, ToastProvider} from "@nextui-org/react";

export default function App() {
return (
<>
<ToastProvider />
<div className="flex flex-wrap gap-x-2">
{["none", "sm", "md", "lg", "full"].map((radius) => (
<Button
key={radius}
className="w-fit m-2"
variant={"bordered"}
onPress={() =>
addToast({
title: "Toast title",
description: "Toast displayed successfully",
// @ts-ignore
radius: radius,
color: "primary",
})
}
>
Show radius-{radius} toast
</Button>
))}
</div>
</>
);
}
21 changes: 21 additions & 0 deletions apps/docs/app/examples/toast/usage/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"use client";
import {addToast, Button, ToastProvider} from "@nextui-org/react";

export default function App() {
return (
<>
<ToastProvider />
<Button
className="w-fit m-2"
onPress={() =>
addToast({
title: "Toast title",
description: "Toast displayed successfully",
})
}
>
Show toast
</Button>
</>
);
}
30 changes: 30 additions & 0 deletions apps/docs/app/examples/toast/variant/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"use client";
import {addToast, Button, ToastProvider} from "@nextui-org/react";

export default function App() {
return (
<>
<ToastProvider />
<div className="flex flex-wrap gap-x-2">
{["solid", "bordered", "flat", "faded"].map((variant) => (
<Button
key={variant}
className="w-fit m-2"
variant={"bordered"}
onPress={() =>
addToast({
title: "Toast title",
description: "Toast displayed successfully",
// @ts-ignore
variant: variant,
color: "secondary",
})
}
>
Show {variant} toast
</Button>
))}
</div>
</>
);
}
28 changes: 28 additions & 0 deletions apps/docs/app/examples/toast/with-action/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"use client";
import {addToast, Button, ToastProvider} from "@nextui-org/react";

export default function App() {
return (
<>
<ToastProvider />
<Button
className="w-fit m-2"
onPress={() => {
addToast({
title: "Toast Title",
description: "Toast Description",
endContent: (
<Button color="warning" size="sm" variant="flat">
Upgrade
</Button>
),
color: "warning",
variant: "faded",
});
}}
>
Show Toast
</Button>
</>
);
}
22 changes: 22 additions & 0 deletions apps/docs/app/examples/toast/with-timeout/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"use client";
import {addToast, Button, ToastProvider} from "@nextui-org/react";

export default function App() {
return (
<>
<ToastProvider />
<Button
className="w-fit m-2"
onPress={() => {
addToast({
title: "Toast Title",
description: "Toast Description",
timeout: 3000,
});
}}
>
Show Toast
</Button>
</>
);
}
2 changes: 1 addition & 1 deletion apps/docs/config/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@
"title": "Toast",
"keywords": "toast, notification, message",
"path": "/docs/components/toast.mdx",
"comingSoon": true
"newPost": true
},
{
"key": "textarea",
Expand Down
30 changes: 30 additions & 0 deletions apps/docs/content/components/toast/color.raw.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {addToast, Button, ToastProvider} from "@nextui-org/react";

export default function App() {
return (
<>
<ToastProvider />
<div className="flex flex-wrap gap-x-2">
{["default", "primary", "secondary", "success", "warning", "danger"].map((color) => (
<Button
key={color}
className="w-fit m-2"
// @ts-ignore
color={color}
variant={"bordered"}
onPress={() =>
addToast({
title: "Toast title",
description: "Toast displayed successfully",
// @ts-ignore
color: color,
})
}
>
Show {color} toast
</Button>
))}
</div>
</>
);
}
9 changes: 9 additions & 0 deletions apps/docs/content/components/toast/color.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import App from "./color.raw.jsx?raw";

const react = {
"/App.jsx": App,
};

export default {
...react,
};
Loading
Loading