From 9cd4f9ceabf808217991c9015cab45698a921c75 Mon Sep 17 00:00:00 2001 From: JonBarakMierke Date: Fri, 19 Dec 2025 20:55:09 -0600 Subject: [PATCH] feat: add optional on-screen toggle button for WireSpy panel --- config/wire-spy.php | 8 ++++++++ resources/views/toolbar.blade.php | 2 +- resources/views/trigger.blade.php | 30 ++++++++++++++++++++++++++++++ src/SupportAutoInjectedAssets.php | 18 +++++++++++++++++- 4 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 resources/views/trigger.blade.php diff --git a/config/wire-spy.php b/config/wire-spy.php index 1d83eaa..cb7c4e2 100644 --- a/config/wire-spy.php +++ b/config/wire-spy.php @@ -16,4 +16,12 @@ * - Combine with other keys using dot notation, like 'super.l' for 'Cmd+L' or 'Ctrl+L'. */ 'keybinding' => 'super.l', + + + /** + * By default WireSpy can only be triggered by keyboard shortcuts. + * If you need to trigger the panel's visibility by a button either set the WIRE_SPY_BUTTON_ENABLED to true + * in your .env file or publish the config file and set the value to true. + */ + 'button_enabled' => env('WIRE_SPY_BUTTON_ENABLED', false), ]; diff --git a/resources/views/toolbar.blade.php b/resources/views/toolbar.blade.php index 21b1dc5..4e7058e 100644 --- a/resources/views/toolbar.blade.php +++ b/resources/views/toolbar.blade.php @@ -1,4 +1,4 @@ -
+
@include('wire-spy::navbar')
diff --git a/resources/views/trigger.blade.php b/resources/views/trigger.blade.php new file mode 100644 index 0000000..a2f9719 --- /dev/null +++ b/resources/views/trigger.blade.php @@ -0,0 +1,30 @@ + diff --git a/src/SupportAutoInjectedAssets.php b/src/SupportAutoInjectedAssets.php index a7c0c94..727c9e1 100644 --- a/src/SupportAutoInjectedAssets.php +++ b/src/SupportAutoInjectedAssets.php @@ -34,7 +34,17 @@ public static function provide() $assetsHead .= sprintf('', file_get_contents(base_path('vendor/wire-elements/wire-spy/dist/wire-spy.min.css')))."\n"; $assetsBody .= sprintf('', $cacheId)."\n"; - $assetsBody .= Blade::render('
'); + if (static::shouldInjectWireSpyTriggerButton()) { + $assetsBody .= view('wire-spy::trigger')->render() . "\n"; + } + $assetsBody .= Blade::render(' +
+
+
+ +
+
+ '); } if ($assetsHead === '' && $assetsBody === '') { @@ -63,4 +73,10 @@ protected static function shouldInjectWireSpyAssets() return false; } + + protected static function shouldInjectWireSpyTriggerButton(): bool + { + return static::shouldInjectWireSpyAssets() + && config('wire-spy.button_enabled'); + } }