@laravel-inertia-toast/react 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +6 -127
  3. package/package.json +1 -1
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) Victor Abbah Nkoms
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md CHANGED
@@ -1,133 +1,12 @@
1
- # @laravel-inertia-toast/react
1
+ # Laravel Inertia Toast
2
2
 
3
- React adapter for [Laravel Inertia Toast](https://github.com/veekthoven/laravel-inertia-toast) beautiful toast notifications for Laravel + Inertia.js applications.
3
+ This is an opinionated package that provides beautiful toast notifications for Laravel + Inertia.js applications; Fluent PHP API, multi-toast support, redirect-safe, with Vue 3 and React adapters.
4
4
 
5
- ## Demo
5
+ ## Documentation
6
6
 
7
- **React:**
8
- ![React](../demo/react.png)
9
-
10
- **See it in action:**
11
- ![Vue](../demo/toast-demo.gif)
12
-
13
- ## Installation
14
-
15
- ```bash
16
- npm install @laravel-inertia-toast/react
17
- ```
18
-
19
- ## Setup
20
-
21
- ### 1. Add the Provider
22
-
23
- Wrap your app with `<ToastProvider>` and add `<Toasts />`:
24
-
25
- ```jsx
26
- // in your resources/js/app.tsx
27
-
28
- import { createRoot } from 'react-dom/client';
29
- import { ToastProvider, Toasts } from '@laravel-inertia-toast/react'
30
-
31
- setup({ el, App, props }) {
32
- const root = createRoot(el);
33
-
34
- root.render(
35
- <ToastProvider
36
- config={{
37
- position: 'top-right'
38
- duration: 5000,
39
- maxVisible: 5,
40
- }}
41
- >
42
- <App {...props} />
43
- <Toasts />
44
- </ToastProvider>
45
- );
46
- },
47
- ```
48
-
49
- ### 2. Tailwind CSS
50
-
51
- Since the toast components use Tailwind classes internally, add the package to Tailwind's source detection.
52
-
53
- **Tailwind v4** — add this `@source` directive to your CSS file (e.g. `resources/css/app.css`):
54
-
55
- ```css
56
- @source "../../node_modules/@laravel-inertia-toast/react/dist/**/*.js";
57
- ```
58
-
59
- **Tailwind v3** — add to `tailwind.config.js`:
60
-
61
- ```js
62
- module.exports = {
63
- content: [
64
- // ...
65
- './node_modules/@laravel-inertia-toast/react/dist/**/*.js',
66
- ],
67
- }
68
- ```
69
-
70
- > The relative paths above assume standard Laravel project structure. Adjust if your setup differs.
71
-
72
- ## Client-Side Usage
73
-
74
- Use the `useToast()` hook to trigger toasts from your components:
75
-
76
- ```jsx
77
- import { useToast } from '@laravel-inertia-toast/react'
78
-
79
- function MyComponent() {
80
- const { success, error, info, warning } = useToast()
81
-
82
- return (
83
- <>
84
- <button onClick={() => success('Copied to clipboard!')}>
85
- Copy
86
- </button>
87
- <button onClick={() => error('Item has been removed.', { title: 'Deleted' })}>
88
- Delete
89
- </button>
90
- </>
91
- )
92
- }
93
- ```
94
-
95
- ### With Title and Duration
96
-
97
- Pass an options object as the second argument to include a title and/or custom duration:
98
-
99
- ```jsx
100
- success('Profile has been updated.', { title: 'Success' })
101
- warning('Session expiring soon.', { title: 'Warning', duration: 10000 })
102
- ```
103
-
104
- ## Server-Side Usage
105
-
106
- Pair with the PHP package for server-side toasts:
107
-
108
- ```bash
109
- composer require veekthoven/laravel-inertia-toast
110
- ```
111
-
112
- ```php
113
- use InertiaToast\Facades\Toast;
114
-
115
- Toast::success('Profile updated!');
116
- Toast::error('Something went wrong.', title: 'Error');
117
- Toast::info('Check your email for a confirmation link.');
118
- Toast::warning('Your subscription is about to expire.');
119
-
120
- return redirect()->route('dashboard');
121
- ```
122
-
123
- For full documentation, configuration options, and the PHP helper API, see the [main repository](https://github.com/veekthoven/laravel-inertia-toast).
124
-
125
- ## Requirements
126
-
127
- - React 18+
128
- - Inertia.js v2.3.3+
129
- - Tailwind CSS v3 or v4
7
+ Documentation for the Laravel Inertia Toast package can be found here: [https://veekthoven-laravel-inertia-toast-24-61.mintlify.app/introduction](https://veekthoven-laravel-inertia-toast-24-61.mintlify.app/introduction).
130
8
 
131
9
  ## License
132
10
 
133
- MIT
11
+ This package is an open-sourced software licensed under the [MIT license](LICENSE.md).
12
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@laravel-inertia-toast/react",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "React toast components for Laravel Inertia Toast",
5
5
  "license": "MIT",
6
6
  "type": "module",