playbook_ui_docs 14.12.0.pre.alpha.PBNTR456fixedconftoastrailsautoclose5728 → 14.12.0.pre.alpha.PBNTR456fixedconftoastrailsautoclose5738

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3af0ff71182babeb005dc738eaffeca12951d2663aaa3f5cc8c875c4c401b09a
4
- data.tar.gz: 30f6df3ec10a18ed615b8a31aeb6b5f2407a67daa3239ab8f10e2ac30a848dae
3
+ metadata.gz: 2157a5705a89a2255f41b00ec03a170132064a685d54569e65986a30fbeded78
4
+ data.tar.gz: 28701af4872b652ee0ae94d98219d66b6ba31f2177648836d7f8ef5679cbc7c6
5
5
  SHA512:
6
- metadata.gz: 8b4391f49afba440279c0351303438ce9837a8615d09bcfeb08777af702375e03b5ffdaff68fd8f6f2f358d3ca0fe3f1e4ad4f6b7fb35eebd2e449433e7ce006
7
- data.tar.gz: 55f848fb3a82c882edaae29cb775d2a5da2b5be5692c9bf179b8e7937c4cc1819a1df8cc4b594e1f6f45a7dc293370663d9268390d52e0669cf0c24c2b9a1830
6
+ metadata.gz: f1093825873f938918776401eb41fecb72bdeef1e1d7f6a2458a409eb28e0943e9409fce1c0df605f047b2752a39c15098a98e5be89f1acbc86dad18efcef37d
7
+ data.tar.gz: 5bbc66925afa97af118d5850c816af55f3bc019e0e0f8ca456e0dbb85ff11f28ee4466df2c4a235cbc0e379bc97585ea300806f9326368b2c75e597adb7dccc9
@@ -1,15 +1,5 @@
1
- <%= pb_rails("button", props: { text: "Show Auto Close Toast", variant: "secondary", data: { toast: "#toast-auto-close" } }) %>
2
1
  <%= pb_rails("button", props: { text: "Show Closeable Auto Close Toast", variant: "secondary", data: { toast: "#toast-auto-close-closeable" } }) %>
3
2
 
4
- <%= pb_rails("fixed_confirmation_toast", props: {
5
- auto_close: 3000,
6
- id: "toast-auto-close",
7
- text: "I will disappear in 3 seconds.",
8
- status: "tip",
9
- vertical: "top",
10
- horizontal: "center"
11
- }) %>
12
-
13
3
  <%= pb_rails("fixed_confirmation_toast", props: {
14
4
  auto_close: 10000,
15
5
  closeable: true,
@@ -22,53 +12,22 @@
22
12
 
23
13
  <script>
24
14
  document.addEventListener('DOMContentLoaded', () => {
25
- const toasts = {
26
- '#toast-auto-close': document.querySelector("#toast-auto-close"),
27
- '#toast-auto-close-closeable': document.querySelector("#toast-auto-close-closeable")
28
- }
29
-
30
- const buttons = {
31
- '#toast-auto-close': document.querySelector("button[data-toast='#toast-auto-close']"),
32
- '#toast-auto-close-closeable': document.querySelector("button[data-toast='#toast-auto-close-closeable']")
33
- }
15
+ const toast10SecCloseable = document.querySelector("#toast-auto-close-closeable")
16
+ const button10SecCloseable = document.querySelector("button[data-toast='#toast-auto-close-closeable']")
34
17
 
35
- const hideAllToastsUponPageLoad = () => {
36
- Object.values(toasts).forEach(toast => {
37
- if (toast) toast.style.display = "none"
38
- })
18
+ const originalToast = toast10SecCloseable.cloneNode(true)
19
+
20
+ if (toast10SecCloseable) {
21
+ toast10SecCloseable.remove()
39
22
  }
40
23
 
41
- const showAndAutoCloseToast = (toastId) => {
42
- hideAllToastsUponPageLoad()
43
- const toast = toasts[toastId]
44
-
45
- if (toast) {
46
- toast.style.display = "flex" // Show the selected toast
47
-
48
- const autoCloseClass = Array.from(toast.classList).find(cls => cls.startsWith('auto_close_'))
49
- if (autoCloseClass) {
50
- const duration = parseInt(autoCloseClass.split('_')[2]) || 0; // Use 0 as fallback if parsing fails
51
-
52
- if (toast.autoCloseTimeout) {
53
- clearTimeout(toast.autoCloseTimeout)
54
- }
55
-
56
- toast.autoCloseTimeout = setTimeout(() => {
57
- toast.style.display = "none"
58
- }, duration)
59
- }
24
+ if (button10SecCloseable) {
25
+ button10SecCloseable.onclick = () => {
26
+ const newToast = originalToast.cloneNode(true)
27
+ newToast.style.display = "flex"
28
+
29
+ document.body.appendChild(newToast)
60
30
  }
61
31
  }
62
-
63
- Object.keys(buttons).forEach((key) => {
64
- const button = buttons[key]
65
- if (button) {
66
- button.onclick = () => {
67
- showAndAutoCloseToast(key)
68
- }
69
- }
70
- })
71
-
72
- hideAllToastsUponPageLoad()
73
32
  })
74
- </script>
33
+ </script>
@@ -1,3 +1,3 @@
1
- Auto close is used when you want the confirmation toast to close automatically after a certain time. `auto_close` property will be a delay number in ms.
1
+ Auto close is used when you want the confirmation toast to close automatically after a certain time. `auto_close` property will be a delay number in ms. The `auto_close` property currently only works in rails when it is a closeable one (`closeable: true`).
2
2
 
3
- Script tag in code snippet is for demonstration purposes only. It provides the functionality needed to show and hide the toaster in response to user interaction, and hides them from appearing upon initial page load. In a typical production environment this functionality would be handled by a controller or a separate javascript file.
3
+ The script tag in this code snippet is for demonstration purposes only. It clones the toast in order to have it appear with a button click prompt and not upon initial page load. In a typical production environment the event triggering a fixed confirmation toast to appear would be handled by a controller or a separate javascript file.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playbook_ui_docs
3
3
  version: !ruby/object:Gem::Version
4
- version: 14.12.0.pre.alpha.PBNTR456fixedconftoastrailsautoclose5728
4
+ version: 14.12.0.pre.alpha.PBNTR456fixedconftoastrailsautoclose5738
5
5
  platform: ruby
6
6
  authors:
7
7
  - Power UX
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2025-01-29 00:00:00.000000000 Z
12
+ date: 2025-01-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: playbook_ui