-
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.
- Loading branch information
Showing
11 changed files
with
154 additions
and
20 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
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,5 +1,12 @@ | ||
# web | ||
|
||
## 0.1.8 | ||
|
||
### Patch Changes | ||
|
||
- Updated dependencies | ||
- [email protected] | ||
|
||
## 0.1.7 | ||
|
||
### Patch Changes | ||
|
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,6 +1,6 @@ | ||
{ | ||
"name": "web", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"private": true, | ||
"scripts": { | ||
"dev": "next dev", | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
# poply | ||
|
||
## 3.1.5 | ||
|
||
### Patch Changes | ||
|
||
- Add README and position prop | ||
|
||
## 3.1.3 | ||
|
||
### Patch Changes | ||
|
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 |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<p align="center"> | ||
<img height=300 src="https://i.imgur.com/MwiRRJB.png" /> | ||
</p> | ||
<p align="center"> | ||
<img src="https://img.shields.io/npm/v/poply.svg?style=for-the-badge"/> | ||
<img src="https://img.shields.io/bundlephobia/minzip/poply?style=for-the-badge"/> | ||
<img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-yellow.svg?style=for-the-badge" /> | ||
</p> | ||
|
||
<p align="center"> | ||
<a href="#">https://poply.dev</a><br/> | ||
<strong>🎉 Lightweight toast component for React 🎉</strong> | ||
</p> | ||
|
||
## Installation | ||
|
||
```sh | ||
# pnpm (recommended): | ||
pnpm add poply | ||
|
||
# npm: | ||
npm install poply | ||
|
||
# yarn: | ||
yarn add poply | ||
``` | ||
|
||
## Usage | ||
|
||
Add `<Toaster />` to your app component: | ||
```tsx | ||
import { Toaster, toast } from 'poply'; | ||
|
||
function App() { | ||
return ( | ||
<div> | ||
<button onClick={() => toast.info('Hello world!')}>Toast</button> | ||
<Toaster /> | ||
</div> | ||
) | ||
} | ||
``` | ||
|
||
### Usage with Next 13 appDir | ||
Import `Toaster` and render it inside of a Client Coponent: | ||
```tsx | ||
// app/toaster-provider.tsx | ||
'use client' | ||
|
||
import { Toaster } from 'poply'; | ||
|
||
export default function ToasterProvider({ children }: { children: React.ReactNode }) { | ||
return ( | ||
<> | ||
{children} | ||
<Toaster /> | ||
</> | ||
); | ||
} | ||
``` | ||
As your provider has been marked as a Client Component, your Server Component can now directly render it: | ||
```tsx | ||
// app/layout.tsx | ||
import ToasterProvider from './toaster-provider'; | ||
|
||
export default function RootLayout({ children }: { children: React.ReactNode }) { | ||
return ( | ||
<html> | ||
<body> | ||
<ToasterProvider> | ||
{children} | ||
</ToasterProvider> | ||
</body> | ||
</html> | ||
); | ||
} | ||
``` | ||
|
||
## Options | ||
|
||
Toaster component accepts following props: | ||
|
||
| Prop | Description | | ||
|------------|----------------------------------| | ||
| bgColor | Color of toast background | | ||
| textColor | Color of text and close icon | | ||
| customComponent | Custom component to render toast | | ||
| position | Position of toast container | | ||
|
||
#### Custom component example: | ||
```tsx | ||
import { Toaster, toast } from 'poply'; | ||
import { CustomToast } from './components/custom-toast'; | ||
|
||
function App() { | ||
return ( | ||
<div> | ||
<button onClick={() => toast.info('Hello world!')}>Toast</button> | ||
<Toaster customComponent={({ message, type }) => <CustomToast message={message} type={type} />} /> | ||
</div> | ||
) | ||
} | ||
``` | ||
|
||
## License | ||
|
||
Licensed under MIT |
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
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const DEFAULT_DURATION = 3000; | ||
export const DEFAULT_POSITION = 'bottom-center'; | ||
export const TOAST_CLOSE_DELAY = 300; |
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