faw_toast 1.1.0 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 388801daee3762cfcdb98f9cc86bbd9bd4b643b44be12fb1a7e7b3735bd8b2e3
4
- data.tar.gz: 48da98ea26d645b0da0d43d01e85fc4e517a277d2211cefa723437a71e52a93e
3
+ metadata.gz: b381797da514941ee2394cd7bcc634016d1af89942057800a7aab6c7a0c02435
4
+ data.tar.gz: 8d6e392357aea77ba878035fd476efc8f2d0f0db944abeccecc13e7dd2e738a4
5
5
  SHA512:
6
- metadata.gz: 191847095c4655292ed92a25cca273feadfca6028e5fc787418952d5f1d211067dc1bbdc223715290f5a49122713045b2aa88b6ce5b05e64efe5aa11493de5e7
7
- data.tar.gz: 1a1d6ab0d7247a8473a3c850742399826ab4e5b1570b482ff898741f2e3caca2129548241998361006e4ce430ab41fc2794520c3f7b20392d63da0331b707f6a
6
+ metadata.gz: 2ad38aa056e63c5c9cc82f13f8958c68cc3afe233793589d324f833124427fb21843ee486d987c72ce9675fc0661c3342b8600123ab3d49d90942b253bc3c9a3
7
+ data.tar.gz: 340e8bd832e3b8280c2137be0be7def84f918e825e4476e9e3ed4e854a4d735e8c7b62e4e37835ab257fee1c4de388cd2f1c9de030c6474e4a3fd995d05af31c
data/README.md CHANGED
@@ -1,7 +1,8 @@
1
1
  # FawToast
2
-
3
2
  A simple, configurable toast notification system for Rails applications. FawToast provides an easy way to display flash messages as toast notifications with minimal setup.
4
3
 
4
+ [![Gem Version](https://badge.fury.io/rb/faw_toast.svg)](https://badge.fury.io/rb/faw_toast)
5
+
5
6
  ## Features
6
7
 
7
8
  - Easy integration with Rails 7+ applications
@@ -40,11 +41,23 @@ rails generate faw_toast:install
40
41
  This will:
41
42
  1. Create a configuration initializer at `config/initializers/faw_toast.rb`
42
43
  2. Add the toast container to your application layout
43
- 3. Import the required stylesheet and JavaScript controller
44
+
45
+ Include the css and javascript files in your `application.html.erb` layout file.
46
+
47
+ For `propshaft`
48
+ ```erb
49
+ <%= stylesheet_link_tag "faw_toast", "data-turbo-track": "reload" %>
50
+ <%= javascript_include_tag "faw_toast", "data-turbo-track": "reload", type: "module" %>
51
+ ```
52
+ and if you are using `sprockets` include the following lines in your `config/manifest.js`
53
+ ```javascript
54
+ //= link faw_toast.js
55
+ //= link faw_toast.css
56
+ ```
44
57
 
45
58
  ## Usage
46
59
 
47
- FawToast works with Rails flash messages. You can use it like this:
60
+ FawToast works with Rails flash messages. You can use it like this
48
61
 
49
62
  ```ruby
50
63
  # In your controller
@@ -55,6 +68,18 @@ def create
55
68
  end
56
69
  ```
57
70
 
71
+ ```ruby
72
+ # In your background job or service object
73
+ flash = {}
74
+ flash[type] = message
75
+ Turbo::StreamsChannel.broadcast_append_to(
76
+ channel,
77
+ target: "faw-toast-container",
78
+ partial: "faw_toast/toast",
79
+ locals: { flash: flash }
80
+ )
81
+ ```
82
+
58
83
  FawToast supports the following flash types out of the box:
59
84
  - `:success` - Green border
60
85
  - `:alert` - Red border
@@ -94,7 +119,7 @@ FawToast uses CSS animations to show and hide toast notifications automatically.
94
119
  2. The flash message content
95
120
  3. A progress bar that indicates how much time is left before the toast disappears
96
121
 
97
- The toast appears with a slide-in animation, stays visible for the configured duration, and then slides out automatically. No JavaScript interaction is required for the basic functionality.
122
+ The toast appears with a slide-in animation, stays visible for the configured duration, and then slides out automatically
98
123
 
99
124
  ## Development
100
125
 
@@ -1,4 +1,7 @@
1
- document.addEventListener('DOMContentLoaded', function() {
1
+ document.addEventListener('DOMContentLoaded', faw_init);
2
+ document.addEventListener('turbo:load', faw_init);
3
+
4
+ function faw_init() {
2
5
  function setupToastListeners() {
3
6
  const toasts = document.querySelectorAll('.faw-toast');
4
7
 
@@ -26,4 +29,4 @@ document.addEventListener('DOMContentLoaded', function() {
26
29
  childList: true,
27
30
  subtree: true
28
31
  });
29
- });
32
+ }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FawToast
4
- VERSION = "1.1.0"
4
+ VERSION = "1.2.0"
5
5
  end
@@ -37,20 +37,6 @@ module FawToast
37
37
  say "Please manually import the FawToast stylesheet in your application", :red
38
38
  end
39
39
  end
40
-
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
54
40
  end
55
41
  end
56
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faw_toast
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - alexwebgr