generated from filamentphp/plugin-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add constants for layout render hooks (#193)
* Define constants for render hooks in place of hard-coded strings for autocompletion * Document `LayoutRenderHook` in the README * Drop use of hard-coded strings for render hooks internally in favor of `LayoutRenderHook`
- Loading branch information
Showing
3 changed files
with
72 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,71 @@ | ||
@props([ | ||
'title' => null, | ||
'dir' => 'ltr' | ||
'dir' => 'ltr', | ||
]) | ||
|
||
@use(Z3d0X\FilamentFabricator\View\LayoutRenderHook) | ||
|
||
<!DOCTYPE html> | ||
<html | ||
lang="{{ str_replace('_', '-', app()->getLocale()) }}" | ||
dir="{{ $dir }}" | ||
class="filament-fabricator" | ||
> | ||
<head> | ||
{{ \Filament\Support\Facades\FilamentView::renderHook('filament-fabricator::head.start') }} | ||
|
||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<meta name="csrf-token" content="{{ csrf_token() }}"> | ||
|
||
@foreach (\Z3d0X\FilamentFabricator\Facades\FilamentFabricator::getMeta() as $tag) | ||
{{ $tag }} | ||
@endforeach | ||
|
||
@if ($favicon = \Z3d0X\FilamentFabricator\Facades\FilamentFabricator::getFavicon()) | ||
<link rel="icon" href="{{ $favicon }}"> | ||
@endif | ||
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}" dir="{{ $dir }}" class="filament-fabricator"> | ||
|
||
<head> | ||
{{ \Filament\Support\Facades\FilamentView::renderHook(LayoutRenderHook::HEAD_START) }} | ||
|
||
<title>{{ $title ? "{$title} - " : null }} {{ config('app.name') }}</title> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<meta name="csrf-token" content="{{ csrf_token() }}"> | ||
|
||
@foreach (\Z3d0X\FilamentFabricator\Facades\FilamentFabricator::getMeta() as $tag) | ||
{{ $tag }} | ||
@endforeach | ||
|
||
<style> | ||
[x-cloak=""], [x-cloak="x-cloak"], [x-cloak="1"] { display: none !important; } | ||
</style> | ||
@if ($favicon = \Z3d0X\FilamentFabricator\Facades\FilamentFabricator::getFavicon()) | ||
<link rel="icon" href="{{ $favicon }}"> | ||
@endif | ||
|
||
<title>{{ $title ? "{$title} - " : null }} {{ config('app.name') }}</title> | ||
|
||
@foreach (\Z3d0X\FilamentFabricator\Facades\FilamentFabricator::getStyles() as $name => $path) | ||
@if (\Illuminate\Support\Str::of($path)->startsWith('<')) | ||
{!! $path !!} | ||
@else | ||
<link rel="stylesheet" href="{{ $path }}" /> | ||
@endif | ||
@endforeach | ||
|
||
{{ \Filament\Support\Facades\FilamentView::renderHook('filament-fabricator::head.end') }} | ||
</head> | ||
<style> | ||
[x-cloak=""], | ||
[x-cloak="x-cloak"], | ||
[x-cloak="1"] { | ||
display: none !important; | ||
} | ||
</style> | ||
|
||
<body class="filament-fabricator-body"> | ||
{{ \Filament\Support\Facades\FilamentView::renderHook('filament-fabricator::body.start') }} | ||
|
||
{{ $slot }} | ||
@foreach (\Z3d0X\FilamentFabricator\Facades\FilamentFabricator::getStyles() as $name => $path) | ||
@if (\Illuminate\Support\Str::of($path)->startsWith('<')) | ||
{!! $path !!} | ||
@else | ||
<link rel="stylesheet" href="{{ $path }}" /> | ||
@endif | ||
@endforeach | ||
|
||
{{ \Filament\Support\Facades\FilamentView::renderHook(LayoutRenderHook::HEAD_END) }} | ||
</head> | ||
|
||
{{ \Filament\Support\Facades\FilamentView::renderHook('filament-fabricator::scripts.start') }} | ||
<body class="filament-fabricator-body"> | ||
{{ \Filament\Support\Facades\FilamentView::renderHook(LayoutRenderHook::BODY_START) }} | ||
|
||
{{ $slot }} | ||
|
||
{{ \Filament\Support\Facades\FilamentView::renderHook(LayoutRenderHook::SCRIPTS_START) }} | ||
|
||
@foreach (\Z3d0X\FilamentFabricator\Facades\FilamentFabricator::getScripts() as $name => $path) | ||
@if (\Illuminate\Support\Str::of($path)->startsWith('<')) | ||
{!! $path !!} | ||
@else | ||
<script defer src="{{ $path }}"></script> | ||
@endif | ||
@endforeach | ||
|
||
@foreach (\Z3d0X\FilamentFabricator\Facades\FilamentFabricator::getScripts() as $name => $path) | ||
@if (\Illuminate\Support\Str::of($path)->startsWith('<')) | ||
{!! $path !!} | ||
@else | ||
<script defer src="{{ $path }}"></script> | ||
@endif | ||
@endforeach | ||
@stack('scripts') | ||
|
||
@stack('scripts') | ||
{{ \Filament\Support\Facades\FilamentView::renderHook(LayoutRenderHook::SCRIPTS_END) }} | ||
|
||
{{ \Filament\Support\Facades\FilamentView::renderHook('filament-fabricator::scripts.end') }} | ||
{{ \Filament\Support\Facades\FilamentView::renderHook(LayoutRenderHook::BODY_END) }} | ||
</body> | ||
|
||
{{ \Filament\Support\Facades\FilamentView::renderHook('filament-fabricator::body.end') }} | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace Z3d0X\FilamentFabricator\View; | ||
|
||
class LayoutRenderHook | ||
{ | ||
const HEAD_START = 'filament-fabricator::head.start'; | ||
|
||
const HEAD_END = 'filament-fabricator::head.end'; | ||
|
||
const BODY_START = 'filament-fabricator::body.start'; | ||
|
||
const SCRIPTS_START = 'filament-fabricator::scripts.start'; | ||
|
||
const SCRIPTS_END = 'filament-fabricator::scripts.end'; | ||
|
||
const BODY_END = 'filament-fabricator::body.end'; | ||
} |