theshtify 1.0.4 → 2.0.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.
package/package.json CHANGED
@@ -1,27 +1,33 @@
1
- {
2
- "name": "theshtify",
3
- "version": "1.0.4",
4
- "description": "Thesharsol notifyer is a lightweight, vanilla JS toast notification library.",
5
- "main": "index.js",
6
- "directories": {
7
- "lib": "lib"
8
- },
9
- "scripts": {
10
- "test": "echo \"Error: no test specified\" && exit 1"
11
- },
12
- "repository": {
13
- "type": "git",
14
- "url": "git+https://github.com/thesharsol/theshtify.git"
15
- },
16
- "keywords": [
17
- "notification",
18
- "toast",
19
- "notif"
20
- ],
21
- "author": "BEBE EPEE Ivan Sampi",
22
- "license": "MIT",
23
- "bugs": {
24
- "url": "https://github.com/thesharsol/theshtify/issues"
25
- },
26
- "homepage": "https://github.com/thesharsol/theshtify#readme"
27
- }
1
+ {
2
+ "name": "theshtify",
3
+ "version": "2.0.0",
4
+ "description": "Thesharsol notifyer is a lightweight, vanilla JS toast notification library.",
5
+ "main": "lib/theshtify.js",
6
+ "directories": {
7
+ "lib": "lib"
8
+ },
9
+ "scripts": {
10
+ "build": "esbuild lib/theshtifyCDN.js --bundle --outfile=dist/theshtify.cdn.js && esbuild lib/theshtify.js --bundle --minify --outfile=dist/theshtify.min.js",
11
+ "test": "vitest run"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/thesharsol/theshtify.git"
16
+ },
17
+ "keywords": [
18
+ "notification",
19
+ "toast",
20
+ "notif"
21
+ ],
22
+ "author": "BEBE EPEE Ivan Sampi",
23
+ "license": "MIT",
24
+ "bugs": {
25
+ "url": "https://github.com/thesharsol/theshtify/issues"
26
+ },
27
+ "homepage": "https://github.com/thesharsol/theshtify#readme",
28
+ "devDependencies": {
29
+ "esbuild": "^0.27.3",
30
+ "jsdom": "^28.1.0",
31
+ "vitest": "^4.0.18"
32
+ }
33
+ }
package/readme.md CHANGED
@@ -1,331 +1,221 @@
1
- ![Built with JavaScript](https://img.shields.io/badge/Built%20with-JavaScript-red?style=for-the-badge&logo=javascript)
2
-
3
- <!-- [![Thesharsol notifyer](https://img.shields.io/badge/vaui-notif--js-1.0.0-brightgreen.svg)](https://www.npmjs.com/package/vaui-notif) -->
4
- ![MIT License](https://img.shields.io/npm/l/toastify-js)
5
-
6
- Thesharsol notifyer is a lightweight, vanilla JS toast notification library.it is completely customisable, allowing you to adapt the graphics window perfectly to the design of your project
7
-
8
-
9
- ### Installation
10
-
11
- ```
12
- npm i theshtify
13
- ```
14
- ### CDN
15
-
16
- ``` javascript
17
- <script src="https://cdn.jsdelivr.net/npm/theshtify/lib/theshtifyCDN.js"> </script>
18
- <link rel="styleSheet" href="https://cdn.jsdelivr.net/npm/theshtify@1.0.1/css/theshtify.css"/>
19
- ```
20
-
21
- ### ESModule
22
-
23
- ``` javascript
24
- import { theshtify } from "theshtify/lib/theshtify";
25
- import "theshtify/css/theshtify.css";
26
- ```
27
-
28
- ## Features
29
-
30
- * Easy use
31
- * Multiple stacked notifications
32
- * Customizable
33
- * No blocking of execution thread
34
-
35
- ## Customization options
36
-
37
- * Notification Text
38
- * Duration
39
- * Background color
40
- * Close icon display
41
- * Display position
42
- * font
43
- * progress
44
- * border radius
45
- * borders
46
-
47
- ## Presentation
48
- The theshtify function takes as a parameter an object describing your notifications. the various options are available in the descriptions shown below.
49
-
50
- ## Options
51
- <table style="width:100%">
52
- <tr>
53
- <th style="border:1px solid">option</th>
54
- <th style="border:1px solid">Description</th>
55
- <th style="border:1px solid">Type</th>
56
- <th style="border:1px solid">values</th>
57
- <th style="border:1px solid">Required</th>
58
- </tr>
59
- <!-- message -->
60
- <tr>
61
- <td style="border:1px solid">message</td>
62
- <td style="border:1px solid">the message to display in the notification</td>
63
- <td style="border:1px solid">String</td>
64
- <td style="border:1px solid">true,false</td>
65
- <td style="border:1px solid;"><span style="color:green">yes</span></td>
66
- </tr>
67
- <!-- type -->
68
- <tr>
69
- <td style="border:1px solid">type</td>
70
- <td style="border:1px solid">the type of the notification</td>
71
- <td style="border:1px solid">String</td>
72
- <td style="border:1px solid">success | danger | info | warning</td>
73
- <td style="border:1px solid;"><span style="color:green">yes</span></td>
74
- </tr>
75
- <!-- config -->
76
- <tr>
77
- <td style="border:1px solid">config</td>
78
- <td style="border:1px solid">is an object that describe the notifications display settings</td>
79
- <td style="border:1px solid">Object</td>
80
- <td style="border:1px solid"></td>
81
- <td style="border:1px solid;"><span style="color:red">no</span></td>
82
- </tr>
83
-
84
- </table>
85
-
86
- ## Basic example
87
-
88
- ```js
89
- theshtify({message: 'welcome to theshtify',type:'success'});
90
- ```
91
- ## Configuration options
92
-
93
- the configuration options allow you to fully adapt theshtify to the context of your application. the different options are described below
94
-
95
- <table>
96
- <!-- duration -->
97
- <tr>
98
- <th style="border:1px solid">Option</th>
99
- <th style="border:1px solid">Description</th>
100
- <th style="border:1px solid">Type</th>
101
- <th style="border:1px solid">Values</th>
102
- <th style="border:1px solid">Required</th>
103
- </tr>
104
- <tr>
105
- <td style="border:1px solid">duration</td>
106
- <td style="border:1px solid">how long the notice is displayed</td>
107
- <td style="border:1px solid">Number</td>
108
- <td style="border:1px solid">between 1000 and 5000</td>
109
- <td style="border:1px solid;"><span style="color:red">no</span></td>
110
- </tr>
111
- <!-- font -->
112
- <tr>
113
- <td style="border:1px solid">font</td>
114
- <td style="border:1px solid">object describing the various properties of the font: family, size and weight</td>
115
- <td style="border:1px solid">Object</td>
116
- <td style="border:1px solid">
117
- {<br>
118
- size: 14,<br/>
119
- weigth: 900,<br/>
120
- family: 'corbel'
121
- <br/>
122
- }
123
- </td>
124
- <td style="border:1px solid;"><span style="color:red">no</span></td>
125
- </tr>
126
- <!-- x_align -->
127
- <tr>
128
- <td style="border:1px solid">x_align</td>
129
- <td style="border:1px solid">defines the horizontal position of the notification</td>
130
- <td style="border:1px solid">String</td>
131
- <td style="border:1px solid">left | right | middle</td>
132
- <td style="border:1px solid;"><span style="color:red">no</span></td>
133
- </tr>
134
- <!-- y_align -->
135
- <tr>
136
- <td style="border:1px solid">y_align</td>
137
- <td style="border:1px solid">defines the vertical position of the notification</td>
138
- <td style="border:1px solid">String</td>
139
- <td style="border:1px solid">top | bottom | middle</td>
140
- <td style="border:1px solid;"><span style="color:red">no</span></td>
141
- </tr>
142
- <!-- close -->
143
- <tr>
144
- <td style="border:1px solid">closer</td>
145
- <td style="border:1px solid">allows you to condition the display of the part allowing you to close the notification</td>
146
- <td style="border:1px solid">Boolean</td>
147
- <td style="border:1px solid">true | false</td>
148
- <td style="border:1px solid;"><span style="color:red">no</span></td>
149
- </tr>
150
-
151
- <!-- bordered -->
152
- <tr>
153
- <td style="border:1px solid">bordered</td>
154
- <td style="border:1px solid">specifies whether the notification will have a border</td>
155
- <td style="border:1px solid">Boolean</td>
156
- <td style="border:1px solid">true | false</td>
157
- <td style="border:1px solid;"><span style="color:red">no</span></td>
158
- </tr>
159
- <!-- borderWidth -->
160
- <tr>
161
- <td style="border:1px solid">border_width</td>
162
- <td style="border:1px solid">specifies the notification border-width</td>
163
- <td style="border:1px solid">Number</td>
164
- <td style="border:1px solid">any number</td>
165
- <td style="border:1px solid;"><span style="color:red">no</span></td>
166
- </tr>
167
- <!-- radius -->
168
- <tr>
169
- <td style="border:1px solid">radius</td>
170
- <td style="border:1px solid">specifies the notification border-radius</td>
171
- <td style="border:1px solid">Number</td>
172
- <td style="border:1px solid">any number</td>
173
- <td style="border:1px solid;"><span style="color:red">no</span></td>
174
- </tr>
175
- <!-- progress -->
176
- <tr>
177
- <td style="border:1px solid">progress</td>
178
- <td style="border:1px solid">is used to condition the display of the progress bar representing the notification display duration.</td>
179
- <td style="border:1px solid">Boolean</td>
180
- <td style="border:1px solid">true | false</td>
181
- <td style="border:1px solid;"><span style="color:red">no</span></td>
182
- </tr>
183
- <!-- progress_height -->
184
- <tr>
185
- <td style="border:1px solid">progress_height</td>
186
- <td style="border:1px solid">specifies the notification progress bar height</td>
187
- <td style="border:1px solid">Number</td>
188
- <td style="border:1px solid">between 1 and 5</td>
189
- <td style="border:1px solid;"><span style="color:red">no</span></td>
190
- </tr>
191
- <!-- colors -->
192
- <tr>
193
- <td style="border:1px solid">colors</td>
194
- <td style="border:1px solid">this property can only be used if the type is “custom” and allows you to define the colors and types of the different parts of the notification, such as: background color, text color, borders and progress bar.</td>
195
- <td style="border:1px solid">Object</td>
196
- <td style="border:1px solid">
197
- {</br>
198
- bg: '#efefef',</br>
199
- color: 'black',</br>
200
- border: {</br>
201
- type: 'solid',</br>
202
- color: 'gray'</br>
203
- },</br>
204
- progress: {</br>
205
- bg: 'gray'</br>
206
- }</br>
207
- }
208
- </td>
209
- <td style="border:1px solid;"><span style="color:red">no</span></td>
210
- </tr>
211
- <!-- custom_colors -->
212
- <tr>
213
- <td style="border:1px solid">custom_colors</td>
214
- <td style="border:1px solid">this property lets you configure the colors of the different types of notifications to perfectly align the library with your platform's charter.</td>
215
- <td style="border:1px solid">Object</td>
216
- <td style="border:1px solid">
217
- {</br>
218
- bg: '#efefef',</br>
219
- color: 'black',</br>
220
- border: {</br>
221
- type: 'solid',</br>
222
- color: 'gray'</br>
223
- },</br>
224
- progress: {</br>
225
- bg: 'gray'</br>
226
- }</br>
227
- }
228
- </td>
229
- <td style="border:1px solid;"><span style="color:red">no</span></td>
230
- </tr>
231
- </table>
232
-
233
- ## Example with type "custom"
234
- Using the **“custom”** type you can (as described in the table above) describe custom colors for different parts of your notification.
235
- ```js
236
- theshtify(
237
- {
238
- message: 'welcome to theshtify',
239
- type: 'custom',
240
- config:{
241
- colors: {
242
- bg: '#0C7059',/** notification background */
243
- color: '#E0BC29',/** text-color*/
244
- border: {
245
- type: 'solid',/** border-type support all css types */
246
- color: 'gray'/**the border color */
247
- },
248
- progress: {
249
- bg: '#E0BC29'/** the progress bar color */
250
- }
251
- }
252
- }
253
-
254
- }
255
- );
256
- ```
257
- >If you use the **“custom”** type without describing the colors as in the example, or omit certain parameters, theshtify will use the default values configured for the type
258
-
259
- ## Colors configuration example
260
-
261
-
262
- By default theshtify provides 4 types of notifications **success, infos, danger and warning** with corresponding colors. it may be that in the context of your project you want to redefine these colors, to do this simply redefine the description of the type in the **“customColors”**.
263
-
264
- ```js
265
- theshtify(
266
- {
267
- message: 'welcome to theshtify',
268
- type: 'success',
269
- config: {
270
- custom_colors: {
271
- success: {
272
- bg: '#0C7059',
273
- color: '#E0BC29',
274
- border: {
275
- type: 'solid',
276
- color: 'gray'
277
- },
278
- progress: {
279
- bg: '#E0BC29'
280
- }
281
- },
282
- },
283
- }
284
-
285
- }
286
- )
287
- ```
288
-
289
- >In the previous example, theshtify will use the configurations you specified for the **“success”** type. naturally, the other types will use theshtify's default colors, since we only specified custom configurations for the **“success”** type.
290
-
291
- ## Full example
292
-
293
- ```js
294
- let config = {
295
- x_align: 'right',
296
- y_align: 'top',
297
- duration: 5000,
298
- font: {
299
- size: 15,
300
- weight: 900,
301
- family: 'arlon'
302
- },
303
- custom_colors: {
304
- success: {
305
- bg: '#0C7059',
306
- color: '#E0BC29',
307
- border: {
308
- type: 'solid',
309
- color: 'gray'
310
- },
311
- progress: {
312
- bg: '#E0BC29'
313
- }
314
- },
315
- /** you can also add other types configs */
316
- },
317
- radius: 20,
318
- bordered: true,
319
- border_width: 1,
320
- closer: true,
321
- progress: true,
322
- progress_height: 2
323
-
324
- }
325
- theshtify({ message: 'welcome to theshtify', type: 'success', config: config });
326
- ```
327
- >if you're working with modules, you can define the configuration in a separate file and import it at runtime
328
-
329
- ## Errors
330
-
331
- in the event of an error, theshtify will generate an error visible in your browser's console
1
+ ![Built with JavaScript](https://img.shields.io/badge/Built%20with-JavaScript-red?style=for-the-badge&logo=javascript)
2
+ ![npm](https://img.shields.io/npm/v/theshtify)
3
+ ![MIT License](https://img.shields.io/npm/l/theshtify)
4
+
5
+ # Theshtify
6
+
7
+ A lightweight, zero-dependency vanilla JS toast notification library. Fully customizable to match your project's design.
8
+
9
+ ## Installation
10
+
11
+ ### npm
12
+
13
+ ```bash
14
+ npm i theshtify
15
+ ```
16
+
17
+ ### CDN
18
+
19
+ ```html
20
+ <script src="https://cdn.jsdelivr.net/npm/theshtify/dist/theshtify.cdn.js"></script>
21
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/theshtify/css/theshtify.css" />
22
+ ```
23
+
24
+ ### ES Module
25
+
26
+ ```js
27
+ import { theshtify } from "theshtify";
28
+ import "theshtify/css/theshtify.css";
29
+ ```
30
+
31
+ ## Features
32
+
33
+ - Easy to use with a simple API
34
+ - Multiple stacked notifications
35
+ - Fully customizable (colors, fonts, borders, positions...)
36
+ - Non-blocking execution
37
+ - Progress bar with duration tracking
38
+ - Fade in/out CSS animations
39
+ - Click callback support
40
+ - Title support
41
+
42
+ ## Quick start
43
+
44
+ ```js
45
+ theshtify({ message: "Welcome to theshtify", type: "success" });
46
+ ```
47
+
48
+ ## API
49
+
50
+ ```js
51
+ theshtify({ message, type, title, config, callback });
52
+ ```
53
+
54
+ | Parameter | Description | Type | Values | Required |
55
+ | ---------- | ---------------------------------------- | ---------- | -------------------------------------------- | -------- |
56
+ | `message` | The text to display in the notification | `String` | Any string | Yes |
57
+ | `type` | The notification type | `String` | `success` \| `danger` \| `info` \| `warning` \| `custom` | Yes |
58
+ | `title` | A title displayed above the message | `String` | Any string | No |
59
+ | `config` | Display and behavior settings | `Object` | See configuration below | No |
60
+ | `callback` | Function called when the notification is clicked | `Function` | | No |
61
+
62
+ ## Configuration options
63
+
64
+ Pass a `config` object to customize the notification appearance and behavior.
65
+
66
+ | Option | Description | Type | Values | Default |
67
+ | --- | --- | --- | --- | --- |
68
+ | `duration` | How long the notification is displayed (ms) | `Number` | `1000` - `5000` | `5000` |
69
+ | `x_align` | Horizontal position | `String` | `left` \| `right` \| `middle` | `right` |
70
+ | `y_align` | Vertical position | `String` | `top` \| `bottom` \| `middle` | `top` |
71
+ | `closer` | Show the close button | `Boolean` | `true` \| `false` | `false` |
72
+ | `bordered` | Show a border around the notification | `Boolean` | `true` \| `false` | `false` |
73
+ | `border_width` | Border thickness in px | `Number` | Any number | `1` |
74
+ | `radius` | Border radius in px | `Number` | Any number | `5` |
75
+ | `progress` | Show the progress bar | `Boolean` | `true` \| `false` | `false` |
76
+ | `progress_height` | Progress bar height in px | `Number` | `1` - `5` | `2` |
77
+ | `font` | Font settings | `Object` | `{ family, size, weight }` | - |
78
+ | `colors` | Custom colors (only with type `custom`) | `Object` | See below | - |
79
+ | `custom_colors` | Override colors for built-in types | `Object` | See below | - |
80
+ | `main_box_classes` | Additional CSS class to add to the notification | `String` | Any class name | - |
81
+
82
+ ## Examples
83
+
84
+ ### Basic
85
+
86
+ ```js
87
+ theshtify({ message: "File saved successfully", type: "success" });
88
+ ```
89
+
90
+ ### With title and callback
91
+
92
+ ```js
93
+ theshtify({
94
+ message: "Your session will expire soon",
95
+ type: "warning",
96
+ title: "Warning",
97
+ callback: () => {
98
+ console.log("Notification clicked!");
99
+ },
100
+ });
101
+ ```
102
+
103
+ ### Custom type with custom colors
104
+
105
+ Using the `custom` type, you can define your own color scheme for the notification.
106
+
107
+ ```js
108
+ theshtify({
109
+ message: "Welcome to theshtify",
110
+ type: "custom",
111
+ config: {
112
+ colors: {
113
+ bg: "#0C7059",
114
+ color: "#E0BC29",
115
+ border: {
116
+ type: "solid",
117
+ color: "gray",
118
+ },
119
+ progress: {
120
+ bg: "#E0BC29",
121
+ },
122
+ },
123
+ },
124
+ });
125
+ ```
126
+
127
+ > If you use the `custom` type without specifying colors, theshtify will fall back to default values.
128
+
129
+ ### Override built-in type colors
130
+
131
+ By default, theshtify provides 4 notification types (`success`, `info`, `danger`, `warning`) with predefined colors. You can override them with `custom_colors`:
132
+
133
+ ```js
134
+ theshtify({
135
+ message: "Welcome to theshtify",
136
+ type: "success",
137
+ config: {
138
+ custom_colors: {
139
+ success: {
140
+ bg: "#0C7059",
141
+ color: "#E0BC29",
142
+ border: {
143
+ type: "solid",
144
+ color: "gray",
145
+ },
146
+ progress: {
147
+ bg: "#E0BC29",
148
+ },
149
+ },
150
+ },
151
+ },
152
+ });
153
+ ```
154
+
155
+ > Only the types you specify in `custom_colors` are overridden. The others keep their default colors.
156
+
157
+ ### Full configuration
158
+
159
+ ```js
160
+ const config = {
161
+ x_align: "right",
162
+ y_align: "top",
163
+ duration: 5000,
164
+ font: {
165
+ size: 15,
166
+ weight: 900,
167
+ family: "Arial",
168
+ },
169
+ custom_colors: {
170
+ success: {
171
+ bg: "#0C7059",
172
+ color: "#E0BC29",
173
+ border: { type: "solid", color: "gray" },
174
+ progress: { bg: "#E0BC29" },
175
+ },
176
+ // you can also override danger, info, warning...
177
+ },
178
+ radius: 20,
179
+ bordered: true,
180
+ border_width: 1,
181
+ closer: true,
182
+ progress: true,
183
+ progress_height: 2,
184
+ };
185
+
186
+ theshtify({
187
+ message: "Welcome to theshtify",
188
+ type: "success",
189
+ title: "Hello",
190
+ config: config,
191
+ callback: () => console.log("clicked"),
192
+ });
193
+ ```
194
+
195
+ > You can define the configuration in a separate file and import it if you're working with ES modules.
196
+
197
+ ### Color object structure
198
+
199
+ The `colors` and `custom_colors` options share the same structure:
200
+
201
+ ```js
202
+ {
203
+ bg: "#efefef", // background color
204
+ color: "black", // text color
205
+ border: {
206
+ type: "solid", // CSS border style
207
+ color: "gray" // border color
208
+ },
209
+ progress: {
210
+ bg: "gray" // progress bar color
211
+ }
212
+ }
213
+ ```
214
+
215
+ ## Error handling
216
+
217
+ If an invalid configuration is passed, theshtify will log a descriptive error in your browser's console.
218
+
219
+ ## License
220
+
221
+ [MIT](LICENSE)