-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: page remake, toast size for older toasts, comments, toasticon, …
…readme
- Loading branch information
Showing
13 changed files
with
375 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,144 @@ | ||
# Griller | ||
|
||
## Griller | ||
A fully customizable React Toast Component | ||
|
||
First, run the development server: | ||
## Installation | ||
|
||
Install the package using npm: | ||
|
||
```bash | ||
npm run dev | ||
# or | ||
yarn dev | ||
# or | ||
pnpm dev | ||
# or | ||
bun dev | ||
npm install griller | ||
``` | ||
|
||
## Usage | ||
|
||
### Wrap your app with the Toaster component | ||
|
||
First, you need to wrap your application with the `Toaster` component. This component will manage the state and positioning of your toasts. | ||
|
||
```jsx | ||
import { Toaster } from "griller/toaster"; | ||
|
||
export default function RootLayout({ children }: Readonly<{ children: ReactNode }>) { | ||
return ( | ||
<html lang="en"> | ||
<body className={inter.className}> | ||
<Toaster> | ||
{children} | ||
</Toaster> | ||
</body> | ||
</html> | ||
); | ||
} | ||
``` | ||
|
||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. | ||
### Creating toasts | ||
|
||
To create a toast, use the `useToast` hook in your component: | ||
|
||
```jsx | ||
import { Toast } from "griller/toast"; | ||
|
||
const { addToast } = useToast(); | ||
|
||
<button onClick={() => | ||
addToast({title: 'Toast Notification'}) | ||
}> | ||
Show Toast | ||
</button> | ||
``` | ||
|
||
## Features | ||
|
||
- ✨ Fully customizable appearance | ||
- 🌐 Multiple positioning options | ||
- ⏱️ Configurable duration | ||
- 🌓 Light and dark themes | ||
- 🔘 Close and action buttons | ||
- 📚 Stacking and expanding layouts | ||
|
||
## API | ||
|
||
### Toaster Props | ||
|
||
| Prop | Type | Default | Description | | ||
|:-----|:-----|:--------|:------------| | ||
| `children` | `ReactNode` | - | The content to be wrapped by the Toaster | | ||
| `layout` | `"stack" \| "expand"` | `"stack"` | How toasts are displayed | | ||
| `scaleDecrease` | `number` | `0.03` | Scale decrease for each toast in stack layout | | ||
|
||
### Toast Props | ||
|
||
| Prop | Type | Default | Description | | ||
|:-----|:-----|:--------|:------------| | ||
| `title` | `string` | - | Toast title (required) | | ||
| `subtitle` | `string` | - | Toast subtitle | | ||
| `icon` | `ReactNode` | - | Icon to display | | ||
| `position` | `"tr" \| "tl" \| "tc" \| "br" \| "bl" \| "bc"` | `"br"` | Toast position | | ||
| `theme` | `"light" \| "dark"` | `"light"` | Toast theme | | ||
| `closeButton` | `boolean` | `false` | Show close button | | ||
| `actionButton` | `boolean` | `false` | Show action button | | ||
| `onAction` | `() => void` | - | Action button callback | | ||
| `actionButtonText` | `string` | `"Undo"` | Action button text | | ||
| `duration` | `number` | `3000` | Toast duration in ms | | ||
|
||
## Customization | ||
|
||
Griller allows for extensive customization through custom classnames: | ||
|
||
- `titleClassname` | ||
- `secondTitleClassname` | ||
- `iconClassname` | ||
- `closeClassname` | ||
- `closeDivClassname` | ||
- `motionClassname` | ||
- `actionButtonClassname` | ||
|
||
## Examples | ||
|
||
### Basic Toast | ||
|
||
```jsx | ||
addToast({ | ||
title: 'Hello World', | ||
subtitle: 'This is a basic toast', | ||
position: 'tr', | ||
duration: 5000 | ||
}); | ||
``` | ||
|
||
### Toast with Action | ||
|
||
```jsx | ||
addToast({ | ||
title: 'File Deleted', | ||
subtitle: 'Your file has been permanently deleted', | ||
actionButton: true, | ||
actionButtonText: 'Undo', | ||
onAction: () => { | ||
console.log('Undo delete'); | ||
} | ||
}); | ||
``` | ||
|
||
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. | ||
## License | ||
|
||
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font. | ||
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. | ||
|
||
## Learn More | ||
## Contributing | ||
|
||
To learn more about Next.js, take a look at the following resources: | ||
Contributions are welcome! Please feel free to submit a Pull Request. | ||
|
||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. | ||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. | ||
1. Fork the Project | ||
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`) | ||
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`) | ||
4. Push to the Branch (`git push origin feature/AmazingFeature`) | ||
5. Open a Pull Request | ||
|
||
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! | ||
## Support | ||
|
||
## Deploy on Vercel | ||
If you have any questions or need help integrating Griller into your project, please open an issue on the GitHub repository. | ||
|
||
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. | ||
--- | ||
|
||
Check out the [documentation](https://griller.ahsmus.com) for more details. | ||
Made with ❤️ by [mvriu5](https://x.com/mvriu5) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.