faw_toast 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc39d92ac6fc1ce8da21e5b03174d62fa6ab8181655a3d3b8765b64259e08a77
4
- data.tar.gz: 405c14d7a313d6169ce47fac895b219bffcf152ed345c51f751ccebaa73809cf
3
+ metadata.gz: 314d01dd20348f62a6246f377322f8228ef2b021a9f4fc8ce499d76987a19f64
4
+ data.tar.gz: 272d6ce0491dc17f9219050a89fcb5a8209cc61394d2c86007a74a5cf0c539ce
5
5
  SHA512:
6
- metadata.gz: 23df80b449b32f2c360c0f36141d7a19d5514e9d0e7532402b2fd74a617f873d4784eac7f8b6e0a956116b86797117c7189f1aadc27a272b6af29b8101d09f5c
7
- data.tar.gz: 1147a18542a6a9b4ee15d85b9d3e9ee62a071122be40d75adc9234db2115be66083da9d743c0382b975e559f44ad069d09761e1d765b16927a7ee1b1e20566e4
6
+ metadata.gz: 65ee75966b4fadf82dbf968d263753f105b7bdf5a1a0970496456ab8abbfbe2663ec50911aafd7afe645dd57b3e46770a687443099545bae7e2b817b00a2d962
7
+ data.tar.gz: 92ee429a17c88b3669d62e37d001f316670e81203bdff9129ae2f83eb5478795f776ed2d14679b340aa772628ff78a1832ab4066b7d789d1ca9e436f801b0a29
data/README.md CHANGED
@@ -57,6 +57,8 @@ and if you are using `sprockets` include the following lines in your `config/man
57
57
 
58
58
  ## Usage
59
59
 
60
+ ### Basic Usage
61
+
60
62
  FawToast works with Rails flash messages. You can use it like this
61
63
 
62
64
  ```ruby
@@ -85,6 +87,28 @@ Turbo::StreamsChannel.broadcast_append_to(
85
87
  )
86
88
  ```
87
89
 
90
+ ### With Turbo Streams
91
+
92
+ For Turbo Streams applications, you can use the built-in `render_message` helper:
93
+
94
+ ```ruby
95
+ # In your controller
96
+ def create
97
+ # Your logic here
98
+ render_message(:success, :ok, "Item was successfully created!")
99
+ end
100
+ ```
101
+
102
+ The `render_message` method takes three parameters:
103
+ - `flash_type`: The type of flash message (:success, :alert, :danger, etc.)
104
+ - `status`: The HTTP status code to return (:ok, :created, etc.)
105
+ - `message`: The message to display in the toast
106
+
107
+ This helper automatically:
108
+ 1. Sets the flash message
109
+ 2. Renders a Turbo Stream that appends the toast to the toast container
110
+ 3. Sets the appropriate HTTP status code
111
+
88
112
  FawToast supports the following flash types out of the box:
89
113
  - `:success` - Green border
90
114
  - `:alert` - Red border
@@ -20,6 +20,11 @@ module FawToast
20
20
  render_toast
21
21
  end
22
22
  end
23
+
24
+ def render_message(flash_type = :success, status = :ok, message = nil)
25
+ flash.now[flash_type] = message
26
+ render turbo_stream: turbo_stream.append("faw-toast-container", partial: "faw_toast/toast"), status: status
27
+ end
23
28
 
24
29
  def toast_css_variables
25
30
  # Generate a style tag with CSS variables based on configuration
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FawToast
4
- VERSION = "1.3.0"
4
+ VERSION = "1.4.0"
5
5
  end
@@ -15,7 +15,7 @@ module FawToast
15
15
  inject_into_file "app/views/layouts/application.html.erb", after: "<head>" do
16
16
  <<-HTML
17
17
 
18
- <%= toast_css_variables %>
18
+ <%= toast_css_variables %>
19
19
  HTML
20
20
  end
21
21
  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.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - alexwebgr