rails_toastify 0.1.3 → 0.1.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a4c911f3af15f4890c1444105b9f61e171df86f803c36b673664876fd1b5df78
4
- data.tar.gz: 925b7c0a30747f92a1e9f2bf7d1ee306a000a445e7d35722c35b35dcb79bd87a
3
+ metadata.gz: dbe4093e4b00ca6aed884608e36832d9b4739c4101147ed6fb4f09725132c7d8
4
+ data.tar.gz: bdeae6a73e70c205c253d6e428425e18d130df7b0368708a6430225a9e053ea1
5
5
  SHA512:
6
- metadata.gz: 928bab3cac6f526bb1b5261a5fbedb31e33412e335344e60a377c6500c17c14496af4fbe85fb8fa4c8ce7856f29678bf386d38689a431a1cff318872dab7b11b
7
- data.tar.gz: 4af1c98f67a8b37f05089c8d11060398a7a0046dcfd8c6d5d9361e93eff8a2a6c28eef410eb24247eda7f105c3683501bfc9bb63931c38c8f6ccd724c87313bf
6
+ metadata.gz: 65d7805c01a912990470de84c7de94abcfb62d0c62fcaa1cb10669dfff05f84c24f014b69657aa497f95d5eca406cc8f73cdf4ab3f8f9dd9872e8d7e68aac78e
7
+ data.tar.gz: a16b9a1874d6cb99b7b6cce8caa1bd0d57b77856a5e55ead272184bdfd82397318a5b1852eb05575cd22afbf5a5db7e6dcbacbb71c2304eeb107d39756927ba9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ # 0.1.4
2
+
3
+ - Adjustments CSS progress bar and shadow
4
+
5
+ # 0.1.4
6
+
7
+ - Change CSS
8
+ - Change JS
9
+
1
10
  ## 0.1.3
2
11
 
3
12
  - Change README
@@ -1,8 +1,8 @@
1
1
  document.addEventListener('DOMContentLoaded', () => {
2
2
  window.RailsToastify = {
3
- showToast(message, type = 'info', duration = 3000) {
3
+ showToast(message, type = 'info', duration = 5000) {
4
4
  const toastContainer = document.querySelector('.toast-container') || createToastContainer();
5
- const toast = createToast(message, type);
5
+ const toast = createToast(message, type, duration);
6
6
  toastContainer.appendChild(toast);
7
7
  setTimeout(() => {
8
8
  toast.classList.add('fade-out');
@@ -18,10 +18,39 @@ document.addEventListener('DOMContentLoaded', () => {
18
18
  return container;
19
19
  }
20
20
 
21
- function createToast(message, type) {
21
+ function createToast(message, type, duration) {
22
22
  const toast = document.createElement('div');
23
23
  toast.className = `toast toast--${type}`;
24
- toast.textContent = message;
24
+ toast.classList.add('show');
25
+
26
+ const closeButton = document.createElement('button');
27
+ closeButton.className = 'toast__close-button';
28
+ closeButton.innerHTML = '<svg aria-hidden="true" viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7.71 8.23l3.75 3.75-1.48 1.48-3.75-3.75-3.75 3.75L1 11.98l3.75-3.75L1 4.48 2.48 3l3.75 3.75L9.98 3l1.48 1.48-3.75 3.75z"></path></svg>';
29
+ closeButton.addEventListener('click', () => {
30
+ toast.classList.add('hide');
31
+ toast.addEventListener('transitionend', () => toast.remove());
32
+ });
33
+
34
+ const progressBar = document.createElement('div');
35
+ progressBar.className = `toast__progress-bar toast__progress-bar--${type}`;
36
+ progressBar.style.animationDuration = `${duration}ms`;
37
+
38
+ const body = document.createElement('div');
39
+ body.className = 'toast__body';
40
+ body.textContent = message;
41
+
42
+ toast.appendChild(body);
43
+ toast.appendChild(closeButton);
44
+ toast.appendChild(progressBar);
45
+
46
+ toast.addEventListener('click', () => {
47
+ toast.classList.add('hide');
48
+ toast.addEventListener('transitionend', () => toast.remove());
49
+ });
50
+ toast.addEventListener('mouseover', () => progressBar.style.animationPlayState = 'paused');
51
+ toast.addEventListener('mouseout', () => progressBar.style.animationPlayState = 'running');
52
+
25
53
  return toast;
26
54
  }
27
- });
55
+
56
+ });
@@ -12,26 +12,72 @@
12
12
  align-items: center;
13
13
  background-color: #fff;
14
14
  border-radius: 4px;
15
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
15
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.06);
16
16
  padding: 16px;
17
17
  margin: 8px;
18
18
  color: #333;
19
+ position: relative;
20
+ transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out;
21
+ transform: translateX(100%);
22
+ max-width: 300px;
19
23
  }
20
24
 
21
- .toast--success {
22
- border-left: 5px solid #4caf50;
25
+ .toast.show {
26
+ transform: translateX(0);
23
27
  }
24
28
 
25
- .toast--error {
26
- border-left: 5px solid #f44336;
29
+ .toast.hide {
30
+ transform: translateX(100%);
27
31
  }
28
32
 
29
- .toast--info {
30
- border-left: 5px solid #2196f3;
33
+ .toast--success .toast__progress-bar {
34
+ background-color: #4caf50;
31
35
  }
32
36
 
33
- .toast--warning {
34
- border-left: 5px solid #ff9800;
37
+ .toast--error .toast__progress-bar {
38
+ background-color: #f44336;
39
+ }
40
+
41
+ .toast--info .toast__progress-bar {
42
+ background-color: #2196f3;
43
+ }
44
+
45
+ .toast--warning .toast__progress-bar {
46
+ background-color: #ff9800;
47
+ }
48
+
49
+ .toast__close-button {
50
+ color: #333;
51
+ background-color: transparent;
52
+ border: none;
53
+ padding: 0;
54
+ cursor: pointer;
55
+ opacity: 0.7;
56
+ transition: opacity 0.3s;
57
+ align-self: flex-start;
58
+ margin-left: auto;
59
+ }
60
+
61
+ .toast__close-button:hover {
62
+ opacity: 1;
63
+ }
64
+
65
+ .toast__progress-bar {
66
+ position: absolute;
67
+ bottom: 0;
68
+ left: 0;
69
+ width: 100%;
70
+ height: 4px;
71
+ animation: progress-bar 5s linear forwards;
72
+ }
73
+
74
+ @keyframes progress-bar {
75
+ from {
76
+ width: 100%;
77
+ }
78
+ to {
79
+ width: 0;
80
+ }
35
81
  }
36
82
  <% elsif RailsToastify.configuration.framework == :tailwind %>
37
83
  .toast-container {
@@ -39,22 +85,53 @@
39
85
  }
40
86
 
41
87
  .toast {
42
- @apply flex items-center bg-white rounded shadow p-4 my-2 text-gray-800;
88
+ @apply flex items-center bg-white rounded-lg shadow-lg p-4 my-2 text-gray-800 relative max-w-sm;
89
+ transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out;
90
+ transform: translateX(100%);
91
+ }
92
+
93
+ .toast.show {
94
+ transform: translateX(0);
95
+ }
96
+
97
+ .toast.hide {
98
+ transform: translateX(100%);
99
+ }
100
+
101
+ .toast--success .toast__progress-bar {
102
+ @apply bg-green-500;
103
+ }
104
+
105
+ .toast--error .toast__progress-bar {
106
+ @apply bg-red-500;
107
+ }
108
+
109
+ .toast--info .toast__progress-bar {
110
+ @apply bg-blue-500;
43
111
  }
44
112
 
45
- .toast--success {
46
- @apply border-l-4 border-green-500;
113
+ .toast--warning .toast__progress-bar {
114
+ @apply bg-yellow-500;
47
115
  }
48
116
 
49
- .toast--error {
50
- @apply border-l-4 border-red-500;
117
+ .toast__close-button {
118
+ @apply text-gray-800 bg-transparent border-none p-0 cursor-pointer opacity-70 transition-opacity duration-300 self-start ml-auto;
119
+ &:hover {
120
+ @apply opacity-100;
121
+ }
51
122
  }
52
123
 
53
- .toast--info {
54
- @apply border-l-4 border-blue-500;
124
+ .toast__progress-bar {
125
+ @apply absolute bottom-0 left-0 w-full h-1;
126
+ animation: progress-bar 5s linear forwards;
55
127
  }
56
128
 
57
- .toast--warning {
58
- @apply border-l-4 border-yellow-500;
129
+ @keyframes progress-bar {
130
+ from {
131
+ width: 100%;
132
+ }
133
+ to {
134
+ width: 0;
135
+ }
59
136
  }
60
- <% end %>
137
+ <% end %>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsToastify
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.5"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_toastify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elton Santos
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-06-25 00:00:00.000000000 Z
11
+ date: 2024-06-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: "\U0001F389 Rails Toastify allows you to add notifications to your app
14
14
  with ease. Pay Attention: this gem still is in development. Please CONTRIBUTE"