faw_toast 1.0.0 → 1.1.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.
- checksums.yaml +4 -4
- data/app/{javascript → assets/javascripts}/faw_toast.js +0 -8
- data/app/assets/stylesheets/faw_toast.css +88 -0
- data/app/assets/stylesheets/faw_toast.css.map +7 -0
- data/lib/faw_toast/version.rb +1 -1
- data/lib/generators/faw_toast/install/install_generator.rb +13 -37
- metadata +13 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 388801daee3762cfcdb98f9cc86bbd9bd4b643b44be12fb1a7e7b3735bd8b2e3
|
4
|
+
data.tar.gz: 48da98ea26d645b0da0d43d01e85fc4e517a277d2211cefa723437a71e52a93e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 191847095c4655292ed92a25cca273feadfca6028e5fc787418952d5f1d211067dc1bbdc223715290f5a49122713045b2aa88b6ce5b05e64efe5aa11493de5e7
|
7
|
+
data.tar.gz: 1a1d6ab0d7247a8473a3c850742399826ab4e5b1570b482ff898741f2e3caca2129548241998361006e4ce430ab41fc2794520c3f7b20392d63da0331b707f6a
|
@@ -1,12 +1,7 @@
|
|
1
|
-
// Self-initializing toast handler
|
2
1
|
document.addEventListener('DOMContentLoaded', function() {
|
3
|
-
console.log('DOMContentLoaded');
|
4
|
-
// Function to handle toast animations
|
5
2
|
function setupToastListeners() {
|
6
|
-
// Find all toast elements
|
7
3
|
const toasts = document.querySelectorAll('.faw-toast');
|
8
4
|
|
9
|
-
// Add animation end listeners to each toast
|
10
5
|
toasts.forEach(function(toast) {
|
11
6
|
toast.addEventListener('animationend', function(event) {
|
12
7
|
// Only remove the toast when the slideOut animation completes
|
@@ -17,10 +12,8 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
17
12
|
});
|
18
13
|
}
|
19
14
|
|
20
|
-
// Initial setup
|
21
15
|
setupToastListeners();
|
22
16
|
|
23
|
-
// Also handle dynamically added toasts (for turbo/ajax)
|
24
17
|
const observer = new MutationObserver(function(mutations) {
|
25
18
|
mutations.forEach(function(mutation) {
|
26
19
|
if (mutation.addedNodes.length) {
|
@@ -29,7 +22,6 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
29
22
|
});
|
30
23
|
});
|
31
24
|
|
32
|
-
// Start observing the document for added nodes
|
33
25
|
observer.observe(document.body, {
|
34
26
|
childList: true,
|
35
27
|
subtree: true
|
@@ -0,0 +1,88 @@
|
|
1
|
+
.faw-toast-container {
|
2
|
+
position: fixed;
|
3
|
+
z-index: 9999;
|
4
|
+
pointer-events: none;
|
5
|
+
display: flex;
|
6
|
+
flex-direction: column;
|
7
|
+
gap: 0.5rem; }
|
8
|
+
.faw-toast-container.faw-toast-top-right {
|
9
|
+
top: 1rem;
|
10
|
+
right: 1rem; }
|
11
|
+
.faw-toast-container.faw-toast-top-left {
|
12
|
+
top: 1rem;
|
13
|
+
left: 1rem; }
|
14
|
+
.faw-toast-container.faw-toast-bottom-right {
|
15
|
+
bottom: 1rem;
|
16
|
+
right: 1rem; }
|
17
|
+
.faw-toast-container.faw-toast-bottom-left {
|
18
|
+
bottom: 1rem;
|
19
|
+
left: 1rem; }
|
20
|
+
.faw-toast-container.faw-toast-top-center {
|
21
|
+
top: 1rem;
|
22
|
+
left: 50%;
|
23
|
+
transform: translateX(-50%); }
|
24
|
+
.faw-toast-container.faw-toast-bottom-center {
|
25
|
+
bottom: 1rem;
|
26
|
+
left: 50%;
|
27
|
+
transform: translateX(-50%); }
|
28
|
+
|
29
|
+
.faw-toast {
|
30
|
+
margin-bottom: 10px;
|
31
|
+
padding: 1rem;
|
32
|
+
border-radius: 4px;
|
33
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
34
|
+
position: relative;
|
35
|
+
overflow: hidden;
|
36
|
+
animation: faw-toast-slideIn 0.3s ease-in-out, faw-toast-slideOut 0.3s ease-in-out var(--faw-toast-duration) forwards;
|
37
|
+
max-width: 24rem;
|
38
|
+
width: 100%;
|
39
|
+
pointer-events: auto;
|
40
|
+
background-color: white; }
|
41
|
+
.faw-toast.faw-toast-border-l-10 {
|
42
|
+
border-left-width: 10px;
|
43
|
+
border-left-style: solid; }
|
44
|
+
.faw-toast.faw-toast-border-green-500 {
|
45
|
+
border-left-color: #10b981; }
|
46
|
+
.faw-toast.faw-toast-border-red-500 {
|
47
|
+
border-left-color: #ef4444; }
|
48
|
+
.faw-toast.faw-toast-border-sky-600 {
|
49
|
+
border-left-color: #0284c7; }
|
50
|
+
.faw-toast.faw-toast-border-indigo-500 {
|
51
|
+
border-left-color: #6366f1; }
|
52
|
+
.faw-toast .faw-toast-content {
|
53
|
+
flex: 1; }
|
54
|
+
.faw-toast .faw-toast-close {
|
55
|
+
cursor: pointer;
|
56
|
+
color: #6b7280; }
|
57
|
+
.faw-toast .faw-toast-close:hover {
|
58
|
+
color: #111827; }
|
59
|
+
.faw-toast .faw-toast-progress {
|
60
|
+
position: absolute;
|
61
|
+
bottom: 0;
|
62
|
+
left: 0;
|
63
|
+
height: 3px;
|
64
|
+
background-color: rgba(0, 0, 0, 0.2);
|
65
|
+
width: 100%;
|
66
|
+
animation: faw-toast-progress var(--faw-toast-duration) linear; }
|
67
|
+
|
68
|
+
@keyframes faw-toast-slideIn {
|
69
|
+
from {
|
70
|
+
transform: translateX(100%);
|
71
|
+
opacity: 0; }
|
72
|
+
to {
|
73
|
+
transform: translateX(0);
|
74
|
+
opacity: 1; } }
|
75
|
+
@keyframes faw-toast-slideOut {
|
76
|
+
from {
|
77
|
+
transform: translateX(0);
|
78
|
+
opacity: 1; }
|
79
|
+
to {
|
80
|
+
transform: translateX(100%);
|
81
|
+
opacity: 0; } }
|
82
|
+
@keyframes faw-toast-progress {
|
83
|
+
from {
|
84
|
+
width: 100%; }
|
85
|
+
to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iB,EAAE,OAAO;EAG5B,6BAAmB;IACjB,IAAI,EAAE,CAAC;EAGT,2BAAiB;IACf,MAAM,EAAE,OAAO;IACf,KAAK,EAAE,OAAO;IAEd,iCAAQ;MACN,KAAK,EAAE,OAAO;EAIlB,8BAAoB;IAClB,QAAQ,EAAE,QAAQ;IAClB,MAAM,EAAE,CAAC;IACT,IAAI,EAAE,CAAC;IACP,MAAM,EAAE,GAAG;IACX,gBAAgB,EAAE,kBAAkB;IACpC,KAAK,EAAE,IAAI;IACX,SAAS,EAAE,mDAAmD;;AAIlE,4BASC;EARC,IAAK;IACH,SAAS,EAAE,gBAAgB;IAC3B,OAAO,EAAE,CAAC;EAEZ,EAAG;IACD,SAAS,EAAE,aAAa;IACxB,OAAO,EAAE,CAAC;AAId,6BASC;EARC,IAAK;IACH,SAAS,EAAE,aAAa;IACxB,OAAO,EAAE,CAAC;EAEZ,EAAG;IACD,SAAS,EAAE,gBAAgB;IAC3B,OAAO,EAAE,CAAC;AAId,6BAOC;EANC,IAAK;IACH,KAAK,EAAE,IAAI;EAEb,EAAG;IACD,KAAK,EAAE,CAAC",
|
4
|
+
"sources": ["faw_toast.scss"],
|
5
|
+
"names": [],
|
6
|
+
"file": "faw_toast.css"
|
7
|
+
}
|
data/lib/faw_toast/version.rb
CHANGED
@@ -38,43 +38,19 @@ module FawToast
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
def add_javascript_import
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
def update_tsconfig
|
56
|
-
gem_path = `bundle show faw_toast`.chomp
|
57
|
-
|
58
|
-
# Default tsconfig structure if file doesn't exist
|
59
|
-
tsconfig = if File.exist?("tsconfig.json")
|
60
|
-
JSON.parse(File.read("tsconfig.json"))
|
61
|
-
else
|
62
|
-
{
|
63
|
-
"compilerOptions" => {
|
64
|
-
"baseUrl" => ".",
|
65
|
-
"paths" => {}
|
66
|
-
}
|
67
|
-
}
|
68
|
-
end
|
69
|
-
|
70
|
-
tsconfig["compilerOptions"] ||= {}
|
71
|
-
tsconfig["compilerOptions"]["paths"] ||= {}
|
72
|
-
tsconfig["compilerOptions"]["paths"]["faw_toast"] = ["#{gem_path}/app/javascript/faw_toast.js"]
|
73
|
-
|
74
|
-
File.write("tsconfig.json", JSON.pretty_generate(tsconfig))
|
75
|
-
|
76
|
-
say "Updated tsconfig.json with FawToast paths", :green
|
77
|
-
end
|
41
|
+
# def add_javascript_import
|
42
|
+
# if File.exist?("app/javascript/application.js")
|
43
|
+
# append_to_file "app/javascript/application.js" do
|
44
|
+
# "import \"faw_toast\"\n"
|
45
|
+
# end
|
46
|
+
# elsif File.exist?("app/assets/javascripts/application.js")
|
47
|
+
# append_to_file "app/assets/javascripts/application.js" do
|
48
|
+
# "//= require faw_toast\n"
|
49
|
+
# end
|
50
|
+
# else
|
51
|
+
# say "Please manually import the FawToast JavaScript in your application", :red
|
52
|
+
# end
|
53
|
+
# end
|
78
54
|
end
|
79
55
|
end
|
80
56
|
end
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faw_toast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- alexwebgr
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2025-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
@@ -14,16 +14,22 @@ dependencies:
|
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '7.0'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '9.0'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '7.0'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '9.0'
|
27
33
|
description: FawToast provides an easy way to display flash messages as toast notifications
|
28
34
|
in Rails applications
|
29
35
|
email:
|
@@ -35,8 +41,10 @@ files:
|
|
35
41
|
- LICENSE.txt
|
36
42
|
- README.md
|
37
43
|
- Rakefile
|
44
|
+
- app/assets/javascripts/faw_toast.js
|
45
|
+
- app/assets/stylesheets/faw_toast.css
|
46
|
+
- app/assets/stylesheets/faw_toast.css.map
|
38
47
|
- app/assets/stylesheets/faw_toast.scss
|
39
|
-
- app/javascript/faw_toast.js
|
40
48
|
- app/views/faw_toast/_toast.html.erb
|
41
49
|
- lib/faw_toast.rb
|
42
50
|
- lib/faw_toast/configuration.rb
|