makki-toast 1.2.1 → 2.0.10

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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <a href="https://danieljimenezc.github.io/makki-toast/MakkiHeader.png"><img alt="makki toast - Try it" src="https://danieljimenezc.github.io/makki-toast/MakkiHeader.png"/></a>
2
2
  <div align="center">
3
- <img src="https://badgen.net/npm/v/makki-toast" alt="NPM Version" />
3
+ <img src="https://img.shields.io/npm/v/makki-toast" alt="NPM Version" />
4
4
  <img src="https://img.shields.io/bundlephobia/minzip/makki-toast" alt="Minzip size"/>
5
5
  <img src="https://img.shields.io/npm/dt/makki-toast" alt="Download" />
6
6
  <img src="https://img.shields.io/github/license/DanielJimenezC/makki-toast-package" alt="Licence" />
@@ -10,16 +10,16 @@
10
10
  <div align="center">
11
11
  <strong>Creative makki toast.</strong>
12
12
  </div>
13
- <div align="center">Easy to use, customizable & compatible with dark mode.</div>
13
+ <div align="center">Easy to use, customizable & support promise</div>
14
14
  <br />
15
15
  <div align="center">
16
16
  <a href="https://danieljimenezc.github.io/makki-toast/">Website</a>
17
17
  <span> · </span>
18
- <a href="https://danieljimenezc.github.io/makki-toast/#/docs">Documentation</a>
18
+ <a href="https://danieljimenezc.github.io/makki-toast/docs">Documentation</a>
19
19
  </div>
20
20
  <br />
21
21
  <div align="center">
22
- <sub>Build by <a href="https://daniel-jimenez.tech">Daniel Jimenez</a></sub>
22
+ <sub>Build by <a href="https://github.com/DanielJimenezC">Daniel Jimenez</a></sub>
23
23
  </div>
24
24
  <br />
25
25
 
@@ -40,72 +40,154 @@ npm install makki-toast@latest
40
40
  ```
41
41
  ## Getting Started
42
42
 
43
- Add the makki toast and it will take care of render the alerts.
44
- #### Import Makki Toast
43
+ Add the makki toast and it will take care of render the alerts. From version 2.0.0 it's for Angular 21
44
+
45
+ #### Import Makki Toast in app.ts
45
46
  ```jsx
46
- import { Toast } from 'makki-toast'
47
+ import { Component } from '@angular/core'
48
+ import { RouterOutlet } from '@angular/router'
49
+ import { ToasterComponent } from 'makki-toast'
50
+
51
+ @Component({
52
+ selector: 'app-root',
53
+ standalone: true,
54
+ imports: [RouterOutlet, ToasterComponent],
55
+ templateUrl: './app.html',
56
+ styleUrl: './app.css'
57
+ })
58
+ export class App {
59
+ constructor() {}
60
+ }
47
61
  ```
48
62
 
49
- #### Info
63
+ #### Import Makki Toast in app.html
50
64
  ```jsx
51
- const toast = new Toast()
65
+ <app-toaster></app-toaster>
66
+ <router-outlet></router-outlet>
67
+ ```
52
68
 
53
- const handleToast = () => {
54
- toast.info('Simple text', false)
55
- }
69
+ #### Import Makki Toast in Component
70
+ ```jsx
71
+ import { ToastService } from 'makki-toast'
72
+
73
+ constructor(
74
+ private readonly toast: ToastService,
75
+ ) {}
56
76
  ```
57
77
 
58
- #### Success
78
+ #### Info
59
79
  ```jsx
60
- const toast = new Toast()
80
+ this.toast.info({
81
+ title: 'Info toast',
82
+ description: 'Info toast message',
83
+ });
84
+ ```
61
85
 
62
- const handleToast = () => {
63
- toast.success('Simple text', false)
64
- }
86
+ #### Success
87
+ ```jsx
88
+ this.toast.success({
89
+ title: 'Success toast',
90
+ description: 'Success toast message'
91
+ });
65
92
  ```
66
93
 
67
94
  #### Warning
68
95
  ```jsx
69
- const toast = new Toast()
70
-
71
- const handleToast = () => {
72
- toast.warning('Simple text', false)
73
- }
96
+ this.toast.warning({
97
+ title: 'Warning toast',
98
+ description: 'Warning toast message'
99
+ });
74
100
  ```
75
101
 
76
- #### Danger
102
+ #### Error
77
103
  ```jsx
78
- const toast = new Toast()
104
+ this.toast.error({
105
+ title: 'Error toast',
106
+ description: 'Error toast message'
107
+ });
108
+ ```
79
109
 
80
- const handleToast = () => {
81
- toast.danger('Simple text', false)
82
- }
110
+ #### Action
111
+ ```jsx
112
+ this.toast.action({
113
+ title: 'Action toast',
114
+ description: 'Action toast message',
115
+ button: {
116
+ title: 'View Details',
117
+ onClick: () => console.log('show')
118
+ },
119
+ });
83
120
  ```
84
121
 
85
- #### Custom
122
+ #### Promise
86
123
  ```jsx
87
- import { Toast } from 'makki-toast'
124
+ this.toast.promise(
125
+ fetchData(),
126
+ {
127
+ loading: {
128
+ title: 'Loading...',
129
+ },
130
+ success: (data) => ({
131
+ title: 'Complete',
132
+ description: 'promise complete message'
133
+ }),
134
+ error: (err) => ({
135
+ title: 'Error',
136
+ description: err.message
137
+ })
138
+ }
139
+ );
140
+ ```
88
141
 
89
- const App = () => {
90
- const toast = new Toast()
142
+ #### Component in description without data
143
+ ```jsx
144
+ this.toast.promise(
145
+ fetchData(),
146
+ {
147
+ loading: {
148
+ title: 'Loading...',
149
+ },
150
+ success: (data) => ({
151
+ title: 'Complete',
152
+ description: DataComponent
153
+ }),
154
+ error: (err) => ({
155
+ title: 'Error',
156
+ description: err.message
157
+ })
158
+ }
159
+ );
160
+ ```
91
161
 
92
- const handleToast = () => {
93
- toast.show({
94
- autoClose: 5000,
95
- darkMode: false,
96
- message: 'Simple text',
97
- position: 'top-right'
162
+ #### Component in description with share data
163
+ ```jsx
164
+ this.toast.promise(
165
+ fetchData(),
166
+ {
167
+ loading: {
168
+ title: 'Loading...',
169
+ },
170
+ success: (data) => ({
171
+ title: 'Complete',
172
+ description: {
173
+ component: DataComponent,
174
+ inputs: {
175
+ data: data
176
+ }
177
+ }
178
+ }),
179
+ error: (err) => ({
180
+ title: 'Error',
181
+ description: err.message
98
182
  })
99
183
  }
100
-
101
- return (
102
- <div>
103
- <button onClick={handleToast}>Show Makki Toast</button>
104
- </div>
105
- )
184
+ );
185
+
186
+ export class DataComponent {
187
+ @Input() data!: any;
106
188
  }
107
189
  ```
108
190
 
109
191
  ## Documentation
110
192
 
111
- Find the full documentation on [official documentation](https://danieljimenezc.github.io/makki-toast/#/docs)
193
+ Find the full documentation on [official documentation](https://danieljimenezc.github.io/makki-toast/docs)