-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsyntax-entry.blade.php
47 lines (44 loc) · 1.87 KB
/
syntax-entry.blade.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
@php
use Illuminate\Support\Str;
$value = $getState();
$validJson = !is_string($value) && Str::isJson(json_encode($value));
@endphp
<x-dynamic-component class="filament-syntax-entry-component" :component="$getEntryWrapperView()" :entry="$entry" wire:ignore>
<div
class="filament-syntax-entry"
x-load-js="[@js(\Filament\Support\Facades\FilamentAsset::getScriptSrc(
id: 'filament-syntax-entry-scripts',
package: 'parallax/filament-syntax-entry'
))]"
x-load-css="[@js(\Filament\Support\Facades\FilamentAsset::getStyleHref(
id: 'filament-syntax-entry-styles',
package: 'parallax/filament-syntax-entry'
))]"
>
<div
x-data="{
theme: localStorage.getItem('theme') ?? @js(filament()->getDefaultThemeMode()->value),
init() {
this.updateTheme();
const observer = new MutationObserver(() => this.updateTheme());
observer.observe(document.documentElement, {
attributes: true,
attributeFilter: ['class']
});
this.$watch('theme', () => this.updateTheme());
this.cleanup = () => observer.disconnect();
},
updateTheme() {
this.$el.className = document.documentElement.classList.contains('dark')
? 'syntax-entry-theme-{{ $getDarkModeTheme() ?? $getTheme() }}'
: 'syntax-entry-theme-{{ $getTheme() }}';
},
cleanup: () => {}
}"
x-init="init()"
x-on:destroyed="cleanup"
>
<pre><code>{{ $validJson ? json_encode($value, JSON_PRETTY_PRINT) : $value }}</code></pre>
</div>
</div>
</x-dynamic-component>