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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 51b6c654539d7d462eee3fa1f498e12c67d083032532f70e9068357aaf720813
4
- data.tar.gz: 9fbd318564ff10362c9e7f24bed9f05654a4db1cb19b2b6f80e76fe7748ec380
3
+ metadata.gz: f97b3753e3181eb460649cb7624c9744d03df8dfb6205bae46f8069cc47d3448
4
+ data.tar.gz: 815b5b9c7f5617faae5f77ac11e87ee4aa6653933a5c475a4fa5c5283ec1765d
5
5
  SHA512:
6
- metadata.gz: e616668cf8527dd81bdf5d31ab89974ba651a8cdb587f8ff33e5a71fbdae9077474d28da036fc4689ab01fe10a4b7814006c54f25026356606245733c75fab95
7
- data.tar.gz: e4efa724ed029637706a90007a8e4f16005e15c4278c79fb7d6e1dec4a2c2d8bdab03c6b21ae3da9378b53795e7e4aaa39704bdab878880506e021ecfc075edb
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.dev_toast = false
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
 
@@ -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 in the bottom-right corner
12
- # and auto-dismisses after 8 seconds (click to keep open).
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
- bottom: 1rem;
54
- right: 1rem;
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(1rem); opacity: 0; }
124
- to { transform: translateY(0); opacity: 1; }
134
+ from { transform: translateY(#{pos[:slide_from]}); opacity: 0; }
135
+ to { transform: translateY(0); opacity: 1; }
125
136
  }
126
137
  </style>
127
138
  <script>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AndOne
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.1"
5
5
  end
data/lib/and_one.rb CHANGED
@@ -16,7 +16,7 @@ module AndOne
16
16
  :allow_stack_paths, :ignore_queries, :ignore_callers,
17
17
  :min_n_queries, :notifications_callback,
18
18
  :ignore_file_path, :json_logging, :env_thresholds,
19
- :dev_toast
19
+ :dev_toast, :dev_toast_position
20
20
 
21
21
  def configure
22
22
  yield self
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: and_one
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keith Thompson