previous(); $current = url()->current(); } catch (Throwable) { return null; } $isHome = rtrim($previous, '/') === rtrim(url('/'), '/'); return $previous === $current || $isHome ? null : $previous; } /** * The error layout's own rules for a page with its build: `components/error-page.css` and the * stylesheets it imports, prebuilt into resources/dist/error-page.css (`npm run * build:stylesheets`) and inlined beside the application's Vite tags, which bring everything * else. * * Nothing is dropped from it, because nothing in it needs a build: the package's only * `@font-face` is `tokens/font.css`'s, which only the foundation reaches and the application's * build serves, and no stylesheet the layout imports writes a `url()` a request would have to * resolve (tests/Feature/ErrorPagesTest.php checks both). An application whose entry also * imports this layout (through `all.css`, say) gets the same rules twice, in the same layers and * with the same declarations; the second copy decides nothing the first had not, so that is * harmless. */ public static function layoutStyles(): HtmlString { return new HtmlString(self::dist('error-page.css')); } /** * A stylesheet for a page without its build: the foundation and the error layout's own rules, * prebuilt into resources/dist/error-page-fallback.css — the same inlining a Vite build does, * so the fallback can never drift from `resources/css/components/error-page.css` the way a * hand-written copy did, and without the `@font-face` (there is no build here to serve the font * file; the brand typeface's stack in tokens/type.css falls back to the system fonts) — with * the application's colours appended in `material-scheme.css`'s own shape * (`SchemeStylesheet::withProfiles()`): the standard level, the medium and high contrast levels * under `[data-contrast]`, and a block per colour profile under `[data-scheme]`, built from * `Scheme::forStylesheet()` on every call. `` has already written * `data-theme`, `data-contrast` and `data-scheme` onto `` by the time this tag is parsed * (it renders first), so the browser resolves the right block on its own — nothing here decides * an active profile in PHP. */ public static function fallbackStyles(): HtmlString { return new HtmlString(self::dist('error-page-fallback.css').SchemeStylesheet::withProfiles(...Scheme::forStylesheet())); } /** * A prebuilt stylesheet under resources/dist/. */ protected static function dist(string $file): string { return (string) file_get_contents(dirname(__DIR__, 2)."/resources/dist/{$file}"); } }