Skip to content

Commit

Permalink
feat: add toast component (#119)
Browse files Browse the repository at this point in the history
* feat: Added toast component

* Added toast in examples
  • Loading branch information
singh-pk authored Jul 4, 2024
1 parent a92d263 commit 99573ec
Show file tree
Hide file tree
Showing 7 changed files with 8,785 additions and 6,677 deletions.
18 changes: 18 additions & 0 deletions apps/www/content/primitives/components/toast.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
title: Toast
description: Toast wrapper and function
---

## Anatomy

Import all parts and piece them together.

<LiveProvider>
<LiveEditor code={`
import { ToastContainer, toast, Button } from '@raystack/apsara'
<Tooltip message="tooltip">
<Button variant="primary" onClick={() => toast("I am toast")}>Toast Yay!</Button>
</Tooltip>
`} border />
</LiveProvider>
1 change: 1 addition & 0 deletions apps/www/utils/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const primitivesRoutes = [
{ title: "Text Field", slug: "docs/primitives/components/textfield" },
{ title: "Tooltip", slug: "docs/primitives/components/tooltip" },
{ title: "Toggle Group", slug: "docs/primitives/components/togglegroup" },
{ title: "Toast", slug: "docs/primitives/components/toast" },
],
},
];
Expand Down
1 change: 1 addition & 0 deletions packages/raystack/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ export { Textarea } from "./textarea";
export { TextField } from "./textfield";
export { ThemeProvider, ThemeSwitcher, useTheme } from "./themprovider";
export { Title } from "./title";
export { ToastContainer, toast } from "./toast";
7 changes: 4 additions & 3 deletions packages/raystack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"types": "dist/index.d.ts",
"sideEffects": false,
"engines": {
"node": ">=12.x.x"
"node": ">=18"
},
"exports": {
".": {
Expand Down Expand Up @@ -77,6 +77,7 @@
"@radix-ui/react-tooltip": "^1.0.7",
"react-day-picker": "^8.10.0",
"react-loading-skeleton": "^3.4.0",
"release-it": "^16.2.1"
"release-it": "^16.2.1",
"sonner": "^1.5.0"
}
}
}
1 change: 1 addition & 0 deletions packages/raystack/toast/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { ToastContainer, toast } from "./toast";
17 changes: 17 additions & 0 deletions packages/raystack/toast/toast.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Toaster, type ToasterProps, toast as sonnerToast } from "sonner";

interface ToastContainerProps extends ToasterProps {}

function ToastContainer(props: ToastContainerProps) {
return <Toaster {...props} />;
}

const toast: typeof sonnerToast = Object.assign(
(...props: Parameters<typeof sonnerToast>) => sonnerToast(...props),
sonnerToast
);

ToastContainer.displayName = "ToastContainer";
(toast as typeof toast & { displayName: string }).displayName = "toast";

export { ToastContainer, toast };
Loading

0 comments on commit 99573ec

Please sign in to comment.