and_one 0.3.0 → 0.3.1
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/CHANGELOG.md +6 -0
- data/README.md +7 -2
- data/lib/and_one/dev_toast.rb +17 -6
- data/lib/and_one/version.rb +1 -1
- data/lib/and_one.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f97b3753e3181eb460649cb7624c9744d03df8dfb6205bae46f8069cc47d3448
|
|
4
|
+
data.tar.gz: 815b5b9c7f5617faae5f77ac11e87ee4aa6653933a5c475a4fa5c5283ec1765d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1c3a672c29fffc69baadee284fc973e335fa1a64086369a7e3852f71e7c49fa3402ab86c0d3b8d79e1ca69be380a14a8d7eafda0de17686daa23ff8e67be62ec
|
|
7
|
+
data.tar.gz: eeaa76d8407541c4668bc211a1aacba0eb528917ae36ae093948cd12514974a6df7c611a5de64880aa59ee9f4115cda22ecac9525e36e2081662c640360afbb9
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.3.1] - 2026-03-05
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **Configurable toast position** — `AndOne.dev_toast_position` accepts `:top_right` (default), `:top_left`, `:bottom_right`, or `:bottom_left`. The slide-in animation direction adjusts automatically to match.
|
|
8
|
+
|
|
3
9
|
## [0.3.0] - 2026-03-05
|
|
4
10
|
|
|
5
11
|
### Removed
|
data/README.md
CHANGED
|
@@ -152,11 +152,12 @@ When an N+1 is detected during a request, AndOne injects a small toast notificat
|
|
|
152
152
|
|
|
153
153
|
This is enabled by default in development — no configuration needed. The toast auto-dismisses after 8 seconds, but hovering over it keeps it open.
|
|
154
154
|
|
|
155
|
-
To disable it:
|
|
155
|
+
To change the position or disable it:
|
|
156
156
|
|
|
157
157
|
```ruby
|
|
158
158
|
# config/initializers/and_one.rb
|
|
159
|
-
AndOne.
|
|
159
|
+
AndOne.dev_toast_position = :bottom_right # :top_right (default), :top_left, :bottom_right, :bottom_left
|
|
160
|
+
AndOne.dev_toast = false # disable entirely
|
|
160
161
|
```
|
|
161
162
|
|
|
162
163
|
The toast only appears on HTML responses with a 200 status, so it won't interfere with API endpoints, redirects, or error pages.
|
|
@@ -236,6 +237,10 @@ AndOne.configure do |config|
|
|
|
236
237
|
# In-page toast notifications (default: true in development)
|
|
237
238
|
config.dev_toast = true
|
|
238
239
|
|
|
240
|
+
# Toast position (default: :top_right)
|
|
241
|
+
# Options: :top_right, :top_left, :bottom_right, :bottom_left
|
|
242
|
+
config.dev_toast_position = :top_right
|
|
243
|
+
|
|
239
244
|
# Path to ignore file (default: Rails.root/.and_one_ignore)
|
|
240
245
|
config.ignore_file_path = Rails.root.join(".and_one_ignore").to_s
|
|
241
246
|
|
data/lib/and_one/dev_toast.rb
CHANGED
|
@@ -8,9 +8,19 @@ module AndOne
|
|
|
8
8
|
# or can be enabled manually:
|
|
9
9
|
# AndOne.dev_toast = true
|
|
10
10
|
#
|
|
11
|
-
# The toast appears as a fixed-position badge
|
|
12
|
-
#
|
|
11
|
+
# The toast appears as a fixed-position badge and auto-dismisses after
|
|
12
|
+
# 8 seconds (click to keep open).
|
|
13
|
+
#
|
|
14
|
+
# Position is configurable via `AndOne.dev_toast_position`:
|
|
15
|
+
# :top_right (default), :top_left, :bottom_right, :bottom_left
|
|
13
16
|
module DevToast
|
|
17
|
+
POSITIONS = {
|
|
18
|
+
top_right: { vertical: "top", horizontal: "right", slide_from: "-1rem" },
|
|
19
|
+
top_left: { vertical: "top", horizontal: "left", slide_from: "-1rem" },
|
|
20
|
+
bottom_right: { vertical: "bottom", horizontal: "right", slide_from: "1rem" },
|
|
21
|
+
bottom_left: { vertical: "bottom", horizontal: "left", slide_from: "1rem" }
|
|
22
|
+
}.freeze
|
|
23
|
+
|
|
14
24
|
module_function
|
|
15
25
|
|
|
16
26
|
# Injects toast HTML/JS/CSS before </body> in an HTML response.
|
|
@@ -33,6 +43,7 @@ module AndOne
|
|
|
33
43
|
end.first(5)
|
|
34
44
|
|
|
35
45
|
extra = count > 5 ? "<div class=\"and-one-toast-extra\">...and #{count - 5} more</div>" : ""
|
|
46
|
+
pos = POSITIONS[AndOne.dev_toast_position || :top_right] || POSITIONS[:top_right]
|
|
36
47
|
|
|
37
48
|
<<~HTML
|
|
38
49
|
<div id="and-one-toast" class="and-one-toast" role="status" aria-live="polite">
|
|
@@ -50,8 +61,8 @@ module AndOne
|
|
|
50
61
|
<style>
|
|
51
62
|
.and-one-toast {
|
|
52
63
|
position: fixed;
|
|
53
|
-
|
|
54
|
-
|
|
64
|
+
#{pos[:vertical]}: 1rem;
|
|
65
|
+
#{pos[:horizontal]}: 1rem;
|
|
55
66
|
z-index: 999999;
|
|
56
67
|
background: #1a1a2e;
|
|
57
68
|
color: #e0e0e0;
|
|
@@ -120,8 +131,8 @@ module AndOne
|
|
|
120
131
|
text-decoration: underline;
|
|
121
132
|
}
|
|
122
133
|
@keyframes and-one-slide-in {
|
|
123
|
-
from { transform: translateY(
|
|
124
|
-
to { transform: translateY(0);
|
|
134
|
+
from { transform: translateY(#{pos[:slide_from]}); opacity: 0; }
|
|
135
|
+
to { transform: translateY(0); opacity: 1; }
|
|
125
136
|
}
|
|
126
137
|
</style>
|
|
127
138
|
<script>
|
data/lib/and_one/version.rb
CHANGED
data/lib/and_one.rb
CHANGED