@cicciosgamino/snack-bar 1.3.0 → 1.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.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.4.0] - 02-01-2025
10
+ ### Added
11
+ - New method `show(msg, time=2700, bkColor='#333', txtColor='#f5f5f5')` to show the snackbar with custom message, time, background-color and text-color
12
+
9
13
  ## [1.3.0] - 06-06-2023
10
14
 
11
15
  ### Changed
package/LICENSE CHANGED
@@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
652
652
  If the program does terminal interaction, make it output a short
653
653
  notice like this when it starts in an interactive mode:
654
654
 
655
- snack-bar Copyright (C) 2023 @cicciosgamino
655
+ snack-bar Copyright (C) 2026 @cicciosgamino
656
656
  This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657
657
  This is free software, and you are welcome to redistribute it
658
658
  under certain conditions; type `show c' for details.
package/README.md CHANGED
@@ -63,6 +63,7 @@ npm install --save @cicciosgamino/snack-bar
63
63
 
64
64
  | Name | Description
65
65
  | -------- | -------------
66
+ | `show(msg, time=2700, bkColor='#333', txtColor='#f5f5f5') => void` | Show the snackbar with custom message, time, background-color and text-color
66
67
  | `closeSnackbar() => void` | Close the snackbar
67
68
 
68
69
 
package/index.html CHANGED
@@ -86,14 +86,21 @@
86
86
  <script>
87
87
  window.addEventListener('DOMContentLoaded', () => {
88
88
  const snack = document.querySelector('snack-bar')
89
+
89
90
  setTimeout(() => {
90
91
  // active the snack
91
92
  snack.setAttribute('active', '')
92
93
  }, 1000)
94
+
93
95
  setTimeout(() => {
94
96
  // close the snack (before timing ended)
95
97
  snack.closeSnackbar()
96
- }, 28000)
98
+ }, 2800)
99
+
100
+ setTimeout(() => {
101
+ // re-active the snack
102
+ snack.show('Reactivated SnackBar!', 3000, '#ff0000', '#fff')
103
+ }, 3200)
97
104
  })
98
105
  </script>
99
106
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cicciosgamino/snack-bar",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Simple snackbar Lit Element",
5
5
  "main": "snack-bar.js",
6
6
  "module": "snack-bar.js",
@@ -30,6 +30,6 @@
30
30
  "lit": "*"
31
31
  },
32
32
  "devDependencies": {
33
- "vite": "^4.3.9"
33
+ "vite": "^7.3.0"
34
34
  }
35
35
  }
package/snack-bar.js CHANGED
@@ -152,6 +152,20 @@ class SnackBar extends LitElement {
152
152
  super.disconnectedCallback()
153
153
  }
154
154
 
155
+ /**
156
+ * Direct method to show the snackbar
157
+ * @returns {void}
158
+ */
159
+ show (msg, time=2700, bkColor='#333', txtColor='#f5f5f5') {
160
+
161
+ this.title = msg
162
+ this.timing = time
163
+
164
+ this.style.setProperty('--snack-bk-color', bkColor)
165
+ this.style.setProperty('--snack-txt-color', txtColor)
166
+ this.setAttribute('active', '')
167
+ }
168
+
155
169
  updated (changed) {
156
170
  if (changed.has('active')) {
157
171
  if (this.hasAttribute('active')) {