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>
This commit is contained in:
co-authored by
Claude Opus 5
parent
05f115ab36
commit
70c983b7bb
@@ -146,7 +146,7 @@ The methods are protected. They dispatch a `toast` browser event (`assertDispatc
|
||||
|
||||
Laravel's HTTP error pages — 403, 404, 419, 429, 500, 503, and the framework's own 401 and 402 — render in M3 without setup. The provider appends the package's error views to `view.paths` after the application's, so a file in `resources/views/errors/` always wins.
|
||||
|
||||
- The pages load `config('livewire-material.showcase.vite')` and `<x-theme-script />`, so they use the app's scheme, font and theme. While the build is missing (a deploy in progress) they fall back to an inline stylesheet coloured from `resources/css/material-scheme.json`.
|
||||
- The pages load `config('livewire-material.showcase.vite')` and `<x-theme-script />`, so they use the app's scheme, font and theme, and inline the error layout's own stylesheet beside them. The application imports nothing for them: no `error-page.css` in the CSS entry (the design guard's `missingStylesheets()` does not ask for it, and an entry that imports it through `all.css` does no harm). While the build is missing (a deploy in progress) they fall back to an inline stylesheet coloured from `resources/css/material-scheme.json`.
|
||||
- `abort(403, 'Only the owner can open this share.')` and `abort(503, '…')` show the message as the sentence. Every other string goes through `__()`; translate them in `lang/{locale}.json`.
|
||||
- To change wording or design, run `php artisan vendor:publish --tag=livewire-material-errors`, which copies the layout and pages to `resources/views/errors`. A page extends `errors::minimal` and sets `title`, `code`, `headline`, `message`, `shape` (an `<x-shape>` name) and optionally `actions`:
|
||||
|
||||
|
||||
@@ -17,12 +17,13 @@
|
||||
* section (otherwise `message` doubles as the headline)
|
||||
* [data-md-error-actions]
|
||||
*
|
||||
* The body is matched only when it holds the layout (`body:has(> [data-md-error-page])`): this
|
||||
* file sits in the application's bundle beside every other page, where a bare `body` rule would
|
||||
* restyle them all. `src/Support/ErrorPage.php`'s `fallbackStyles()`, the stylesheet an
|
||||
* application without a Vite build gets instead, inlines this file itself (`Stylesheets::bundle()`,
|
||||
* plan step 40) rather than a hand-written copy, so it keeps the same scoped `body` rule and never
|
||||
* drifts from it.
|
||||
* The page carries this file itself: `src/Support/ErrorPage.php` inlines it, with its imports, into
|
||||
* every error page (`Stylesheets::bundle()`) — beside the application's Vite tags when there is a
|
||||
* build (`layoutStyles()`), inside the whole fallback stylesheet when there is none
|
||||
* (`fallbackStyles()`, plan step 40) — so an application imports nothing for its error pages
|
||||
* (plan step 46). The body is still matched only when it holds the layout
|
||||
* (`body:has(> [data-md-error-page])`): an application that imports `all.css` has this file in
|
||||
* its bundle beside every other page, where a bare `body` rule would restyle them all.
|
||||
*
|
||||
* The page's font is the foundation's, `--md-ref-typeface-brand` on `html` (foundation/base.css),
|
||||
* as the old `font-sans` was; only the fallback, which has no `@font-face`, uses a system stack.
|
||||
|
||||
@@ -12,15 +12,20 @@
|
||||
`actions` the buttons; by default a filled Home and, when the visitor came from a page on
|
||||
the way here, a text Back.
|
||||
|
||||
The app's own Vite entries (`livewire-material.showcase.vite`) bring its scheme, font and
|
||||
the package's stylesheets, including this layout's own,
|
||||
resources/css/components/error-page.css. 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, `Stylesheets::bundle()`-inlined 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. --}}
|
||||
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();
|
||||
@@ -40,6 +45,7 @@
|
||||
|
||||
@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
|
||||
|
||||
Reference in New Issue
Block a user