Files
livewire-material/resources/views/error-pages/errors/minimal.blade.php
T
Andreas Reinhold / reiniandClaude Opus 5 70c983b7bb Inline the error layout's own rules beside the app's build
Plan step 46, from SealShare's breakpoint walk: an application imports
the stylesheets its own views render, and none renders the error layout,
so under a real build its 403/404/500 pages drew unstyled. With a build
the page now keeps the app's Vite tags (foundation, tokens, scheme, font)
and inlines Stylesheets::bundle() of components/error-page.css and its
imports beside them (ErrorPage::layoutStyles(), cached). Without a build
the fallback is unchanged. An application imports nothing for its error
pages; one that imports all.css gets the same layered rules twice, which
is harmless.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 16:10:01 +02:00

89 lines
4.2 KiB
PHP

{{-- The layout every error page extends: this package's 403, 404, 419, 429, 500 and 503, and the
framework's own 401 and 402, which extend `errors::minimal` and find this file before the
framework's (the provider appends this folder's parent to `view.paths`).
Sections the framework layout's `title`, `code` and `message`, plus three of its own, so
either layout renders the other's pages:
`title` the browser tab, followed by the app name;
`code` the status, drawn in display type over the shape;
`headline` what happened, in a few words (without it, `message` is the headline);
`message` one sentence on what to do about it;
`shape` an M3 Expressive shape name (`cookie-7` by default), in primary-container;
`actions` the buttons; by default a filled Home and, when the visitor came from a page on
the way here, a text Back.
The page carries its own component rules, so an application imports nothing for it: its CSS
entry imports the stylesheets its own views render, and none of them renders this layout.
With a build, the app's own Vite entries (`livewire-material.showcase.vite`) bring the
foundation, tokens, scheme and font, and a `<style data-md-error-styles>` beside them inlines
this layout's own resources/css/components/error-page.css with the button and shape
stylesheets it imports (`ErrorPage::layoutStyles()`, `Stylesheets::bundle()`, cached). An app
whose entry imports them too (`all.css`) gets the same layered rules twice, which is harmless:
the second copy repeats the first, in the same layers. But an error page is also what shows
while a deploy has no build yet, so when those tags cannot be made the page brings a
stylesheet built in PHP instead: the foundation and this layout's own rules, inlined the same
way rather than copied by hand, plus the app's scheme from its scheme data in the same
selector shape `material:scheme` writes (`src/Support/ErrorPage.php::fallbackStyles()`). The
two paths draw the same `data-md-error-*` hooks by construction, nothing to keep in step by
hand. The shape turns once a minute, unless the visitor asks for reduced motion. --}}
@php
$assets = \NoNameWeb\LivewireMaterial\Support\ErrorPage::assets();
$back = \NoNameWeb\LivewireMaterial\Support\ErrorPage::backUrl();
@endphp
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="robots" content="noindex" />
<title>@yield('title') · {{ config('app.name') }}</title>
<x-livewire-material::theme-script />
@if ($assets !== null)
{{ $assets }}
<style data-md-error-styles>{{ \NoNameWeb\LivewireMaterial\Support\ErrorPage::layoutStyles() }}</style>
@else
<style data-md-error-fallback>{{ \NoNameWeb\LivewireMaterial\Support\ErrorPage::fallbackStyles() }}</style>
@endif
</head>
<body>
<main data-md-error-page>
<div data-md-error-art>
<div data-md-error-shape>
<x-livewire-material::shape :name="trim($__env->yieldContent('shape', 'cookie-7'))" />
</div>
<p data-md-error-code>@yield('code')</p>
</div>
<h1 data-md-error-headline>
@hasSection('headline')
@yield('headline')
@else
@yield('message')
@endif
</h1>
@hasSection('headline')
<p data-md-error-message>@yield('message')</p>
@endif
<div data-md-error-actions>
@hasSection('actions')
@yield('actions')
@else
<x-livewire-material::button :link="url('/')" :label="__('Go home')" variant="filled" size="md" no-wire-navigate />
@if ($back !== null)
<x-livewire-material::button :link="$back" :label="__('Go back')" variant="text" size="md" no-wire-navigate />
@endif
@endif
</div>
</main>
</body>
</html>