Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions config/wire-spy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
];
2 changes: 1 addition & 1 deletion resources/views/toolbar.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div x-data="wireSpy" x-on:keydown.window.prevent.{{ config('wire-spy.keybinding', 'super.l') }}="show = !show" x-cloak :style="show ? `height: ${height}px;` : `height: 0`;" :class="isResizing ? '' : 'transition-all'" class="font-sans antialiased fixed z-[99999999] flex flex-col inset left-0 bottom-0 w-full bg-zinc-900 rounded-t-lg text-gray-300">
<div x-data="wireSpy" x-on:keydown.window.prevent.{{ config('wire-spy.keybinding', 'super.l') }}="show = !show" @wire-spy-toggle.window="show = !show" x-cloak :style="show ? `height: ${height}px;` : `height: 0`;" :class="isResizing ? '' : 'transition-all'" class="font-sans antialiased fixed z-[99999999] flex flex-col inset left-0 bottom-0 w-full bg-zinc-900 rounded-t-lg text-gray-300">
@include('wire-spy::navbar')

<div class="flex flex-1 overflow-hidden">
Expand Down
30 changes: 30 additions & 0 deletions resources/views/trigger.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<button
x-data
@click="$dispatch('wire-spy-toggle')"
style="
position: fixed;
bottom: 16px;
right: 16px;
z-index: 99999999;

display: flex;
align-items: center;
justify-content: center;

width: 40px;
height: 40px;

border-radius: 9999px;
background: #18181b;
color: #e5e7eb;

font-size: 18px;
line-height: 1;

cursor: pointer;
box-shadow: 0 4px 12px rgba(0,0,0,.4);
"
title="Toggle WireSpy"
>
🐞
</button>
18 changes: 17 additions & 1 deletion src/SupportAutoInjectedAssets.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,17 @@ public static function provide()

$assetsHead .= sprintf('<style>%s</style>', file_get_contents(base_path('vendor/wire-elements/wire-spy/dist/wire-spy.min.css')))."\n";
$assetsBody .= sprintf('<script src="/livewire/wire-spy.min.js?id=%s"></script>', $cacheId)."\n";
$assetsBody .= Blade::render('<div class="wire-spy"><livewire:wire-spy /></div>');
if (static::shouldInjectWireSpyTriggerButton()) {
$assetsBody .= view('wire-spy::trigger')->render() . "\n";
}
$assetsBody .= Blade::render('
<div class="wire-spy-root">
<div id="wire-spy-trigger"></div>
<div class="wire-spy">
<livewire:wire-spy />
</div>
</div>
');
}

if ($assetsHead === '' && $assetsBody === '') {
Expand Down Expand Up @@ -63,4 +73,10 @@ protected static function shouldInjectWireSpyAssets()

return false;
}

protected static function shouldInjectWireSpyTriggerButton(): bool
{
return static::shouldInjectWireSpyAssets()
&& config('wire-spy.button_enabled');
}
}