From 94b1eabd8eff5fa3afc2ce6752eb6f21d226e4ce Mon Sep 17 00:00:00 2001 From: Matteo Gassend Date: Fri, 18 Oct 2024 18:22:23 +0200 Subject: [PATCH] add: custom alpine + clipboard directive --- resources/js/app.js | 13 +++++++++++++ resources/views/components/layouts/app.blade.php | 4 +++- .../views/livewire/profile/keys/table.blade.php | 4 ++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/resources/js/app.js b/resources/js/app.js index e59d6a0..c18ef1f 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -1 +1,14 @@ import './bootstrap'; +import { Livewire, Alpine } from '../../vendor/livewire/livewire/dist/livewire.esm'; + +// Register any Alpine directives, components, or plugins here... +Alpine.directive('clipboard', (el) => { + let text = el.textContent + + el.addEventListener('click', () => { + console.log("copying") + navigator.clipboard.writeText(text) + }) +}) + +Livewire.start() diff --git a/resources/views/components/layouts/app.blade.php b/resources/views/components/layouts/app.blade.php index 9fe494c..8d2a73f 100644 --- a/resources/views/components/layouts/app.blade.php +++ b/resources/views/components/layouts/app.blade.php @@ -5,7 +5,8 @@ {{ $title ?? 'Page Title' }} - @vite('resources/css/app.css') + @livewireStyles + @vite(['resources/css/app.css', 'resources/js/app.js']) @fluxStyles @@ -65,6 +66,7 @@ @persist('toast') @endpersist + @livewireScriptConfig @fluxScripts diff --git a/resources/views/livewire/profile/keys/table.blade.php b/resources/views/livewire/profile/keys/table.blade.php index 448f3e7..2ad46b2 100644 --- a/resources/views/livewire/profile/keys/table.blade.php +++ b/resources/views/livewire/profile/keys/table.blade.php @@ -49,11 +49,11 @@ -
+
Here's your new API key

Make sure to save it somewhere; you won't be able to see it again

-

{{$this->textToken}}

+

{{$this->textToken}}