makki-toast 1.0.0 → 1.2.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 (5) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +109 -3
  3. package/index.js +51 -6
  4. package/package.json +17 -6
  5. package/style.css +17 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Daniel Jimenez
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 all
13
+ 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 THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,5 +1,111 @@
1
- # Makki Toast
1
+ <a href="https://daniel-jimenez.tech/makki-toast/"><img alt="makki toast - Try it" src="https://daniel-jimenez.tech/images/makkitoast.png"/></a>
2
+ <div align="center">
3
+ <img src="https://badgen.net/npm/v/makki-toast" alt="NPM Version" />
4
+ <img src="https://img.shields.io/bundlephobia/minzip/makki-toast" alt="Minzip size"/>
5
+ <img src="https://img.shields.io/npm/dt/makki-toast" alt="Download" />
6
+ <img src="https://img.shields.io/github/license/DanielJimenezC/makki-toast-package" alt="Licence" />
7
+
8
+ </div>
9
+ <br />
10
+ <div align="center">
11
+ <strong>Creative makki toast.</strong>
12
+ </div>
13
+ <div align="center">Easy to use, customizable & compatible with dark mode.</div>
14
+ <br />
15
+ <div align="center">
16
+ <a href="https://daniel-jimenez.tech/makki-toast/">Website</a>
17
+ <span> · </span>
18
+ <a href="https://daniel-jimenez.tech/makki-toast/#/docs">Documentation</a>
19
+ </div>
20
+ <br />
21
+ <div align="center">
22
+ <sub>Build by <a href="https://daniel-jimenez.tech">Daniel Jimenez</a></sub>
23
+ </div>
24
+ <br />
2
25
 
3
- Fancy makki toast
26
+ ## Features
4
27
 
5
- Create by Daniel Jimenez
28
+ - **Easy to use**
29
+ - **Customizable**
30
+ - **Dark mode**
31
+ - **Lightweight**
32
+ - **Accessible**
33
+
34
+ ## Installation
35
+
36
+ #### With NPM
37
+
38
+ ```sh
39
+ npm install makki-toast@latest
40
+ ```
41
+ ## Getting Started
42
+
43
+ Add the makki toast and it will take care of render the alerts.
44
+ #### Import Makki Toast
45
+ ```jsx
46
+ import { Toast } from 'makki-toast'
47
+ ```
48
+
49
+ #### Info
50
+ ```jsx
51
+ const toast = new Toast()
52
+
53
+ const handleToast = () => {
54
+ toast.info('Simple text', false)
55
+ }
56
+ ```
57
+
58
+ #### Success
59
+ ```jsx
60
+ const toast = new Toast()
61
+
62
+ const handleToast = () => {
63
+ toast.success('Simple text', false)
64
+ }
65
+ ```
66
+
67
+ #### Warning
68
+ ```jsx
69
+ const toast = new Toast()
70
+
71
+ const handleToast = () => {
72
+ toast.warning('Simple text', false)
73
+ }
74
+ ```
75
+
76
+ #### Danger
77
+ ```jsx
78
+ const toast = new Toast()
79
+
80
+ const handleToast = () => {
81
+ toast.danger('Simple text', false)
82
+ }
83
+ ```
84
+
85
+ #### Custom
86
+ ```jsx
87
+ import { Toast } from 'makki-toast'
88
+
89
+ const App = () => {
90
+ const toast = new Toast()
91
+
92
+ const handleToast = () => {
93
+ toast.show({
94
+ autoClose: 5000,
95
+ darkMode: false,
96
+ message: 'Simple text',
97
+ position: 'top-right'
98
+ })
99
+ }
100
+
101
+ return (
102
+ <div>
103
+ <button onClick={handleToast}>Show Makki Toast</button>
104
+ </div>
105
+ )
106
+ }
107
+ ```
108
+
109
+ ## Documentation
110
+
111
+ Find the full documentation on [official documentation](https://daniel-jimenez.tech/makki-toast/#/docs)
package/index.js CHANGED
@@ -16,7 +16,43 @@ const DEFAULT_VALUES = {
16
16
 
17
17
  export class Toast {
18
18
  show(options) {
19
- new ToastAlert(options);
19
+ new ToastAlert(options)
20
+ }
21
+ info(message, theme) {
22
+ new ToastAlert({
23
+ autoClose: 5000,
24
+ darkMode: theme,
25
+ message: message,
26
+ status: 'info',
27
+ position: 'top-right'
28
+ })
29
+ }
30
+ success(message, theme) {
31
+ new ToastAlert({
32
+ autoClose: 5000,
33
+ darkMode: theme,
34
+ message: message,
35
+ status: 'success',
36
+ position: 'top-right'
37
+ })
38
+ }
39
+ warning(message, theme) {
40
+ new ToastAlert({
41
+ autoClose: 5000,
42
+ darkMode: theme,
43
+ message: message,
44
+ status: 'warning',
45
+ position: 'top-right'
46
+ })
47
+ }
48
+ danger(message, theme) {
49
+ new ToastAlert({
50
+ autoClose: 5000,
51
+ darkMode: theme,
52
+ message: message,
53
+ status: 'danger',
54
+ position: 'top-right'
55
+ })
20
56
  }
21
57
  }
22
58
 
@@ -69,6 +105,8 @@ class ToastAlert {
69
105
  this.#toastElement.classList.add('makki-warning')
70
106
  else if (value === 'danger')
71
107
  this.#toastElement.classList.add('makki-danger')
108
+ else if (value === 'info')
109
+ this.#toastElement.classList.add('makki-info')
72
110
  else if (value === 'none')
73
111
  this.#toastElement.classList.add('makki-none')
74
112
  } catch (error) {
@@ -128,7 +166,12 @@ class ToastAlert {
128
166
  }
129
167
  else if (this.#statusValue === 'danger') {
130
168
  iconToast.classList.add('bx')
131
- iconToast.classList.add('bx-error-alt')
169
+ iconToast.classList.add('bx-x')
170
+ this.#iconElement = iconToast
171
+ }
172
+ else if (this.#statusValue === 'info') {
173
+ iconToast.classList.add('bx')
174
+ iconToast.classList.add('bx-info-circle')
132
175
  this.#iconElement = iconToast
133
176
  }
134
177
  else if (this.#statusValue === 'none') {
@@ -170,6 +213,8 @@ class ToastAlert {
170
213
  bgColor = '#ECC94B'
171
214
  else if (this.#statusValue === 'danger')
172
215
  bgColor = '#D74B4B'
216
+ else if (this.#statusValue === 'info')
217
+ bgColor = '#3182CE'
173
218
 
174
219
  this.#toastElement.style.setProperty('--makki-progress-bg', bgColor)
175
220
  if (value) {
@@ -239,9 +284,9 @@ function getTextColor(bgColor) {
239
284
  }
240
285
 
241
286
  function calcTintColor(or,og,ob) {
242
- const r = or + Math.round((255 - or) * 0.25)
243
- const g = og + Math.round((255 - og) * 0.25)
244
- const b = ob + Math.round((255 - ob) * 0.25)
287
+ const r = or + Math.round((255 - or) * 0.18)
288
+ const g = og + Math.round((255 - og) * 0.18)
289
+ const b = ob + Math.round((255 - ob) * 0.18)
245
290
  return { r, g, b }
246
291
  }
247
292
 
@@ -279,7 +324,7 @@ function validatePosition(position) {
279
324
  }
280
325
 
281
326
  function validateStatus(status) {
282
- const styles = ['success', 'warning', 'danger', 'none']
327
+ const styles = ['success', 'warning', 'danger', 'info', 'none']
283
328
  if (!styles.includes(status.toLowerCase()))
284
329
  throw new Error('toast status is wrong')
285
330
  return
package/package.json CHANGED
@@ -1,14 +1,25 @@
1
1
  {
2
2
  "name": "makki-toast",
3
- "version": "1.0.0",
4
- "description": "Fancy makki toast",
3
+ "version": "1.2.0",
4
+ "description": "Easy to use and customizable toast",
5
+ "author": "Daniel Jimenez <danieljimenezcanales@gmail.com>",
6
+ "homepage": "https://daniel-jimenez.tech/makki-toast/",
7
+ "license": "MIT",
8
+ "repository": "DanielJimenezC/makki-toast-package",
5
9
  "main": "index.js",
6
10
  "scripts": {
7
11
  "test": "echo \"Error: no test specified\" && exit 1"
8
12
  },
9
13
  "keywords": [
10
- "Toast"
11
- ],
12
- "author": "Daniel Jimenez",
13
- "license": "ISC"
14
+ "accessible",
15
+ "alert",
16
+ "frontend",
17
+ "makki-toast",
18
+ "notification",
19
+ "notify",
20
+ "react",
21
+ "toast",
22
+ "ui",
23
+ "web"
24
+ ]
14
25
  }
package/style.css CHANGED
@@ -12,6 +12,7 @@
12
12
  display: flex;
13
13
  flex-direction: column;
14
14
  gap: 0.5rem;
15
+ z-index: 99;
15
16
  }
16
17
 
17
18
  .makki-toast-container[data-position^="top-"] {
@@ -150,6 +151,22 @@
150
151
  opacity: 1;
151
152
  }
152
153
 
154
+ .makki-info.makki-light-toast {
155
+ background-color: #2768A5;
156
+ color: #EDF2F7;
157
+ }
158
+
159
+ .makki-info.makki-dark-toast {
160
+ background-color: #5A9BD8;
161
+ color: #EDF2F7;
162
+ }
163
+
164
+ .makki-info.makki-light-toast:hover,
165
+ .makki-info.makki-dark-toast:hover {
166
+ background-color: #3182CE;
167
+ opacity: 1;
168
+ }
169
+
153
170
  .makki-light-toast.makki-none,
154
171
  .makki-dark-toast.makki-none {
155
172
  background-color: var(--makki-toast-bg-color);