{{-- A pane: a content region with M3's margins, and its own top app bar if it has a title.
…
M3 puts every piece of content in a pane and lets each carry its own top app bar
(docs/reference/m3/foundations.md § Layout → Scaffold). The body is kept off the window's edge
by M3's margin, 16px below medium (600px) and 24px from it
(docs/reference/m3/foundations-supplement.md § Breakpoints); a pane inside something that
already keeps that margin — the scaffold's content region, a canonical layout, another pane's
body — draws none, so the margin is never doubled; on an `` it draws it again.
`width` caps the pane and centres it: `narrow` (40rem, M3's 40–60 characters a line),
`medium` (60rem), `wide` (80rem) or `full` (the default, all the room it has).
The app bar is ``, drawn when there is a `title`, `actions`, a `leading` slot or
`back`: `title` and `subtitle`, `heading` (`h1` by default; the second pane of a canonical
layout passes `h2`), `sticky` (true: it holds to the top of the window for as long as the pane
is on screen), the `actions` slot at its end. Its leading icon button is the `leading` slot,
or `back`: a URL makes it a link back there, and `true` calls `back()` in the Alpine scope
around it, which `` provides — and which it hides where both panes show, as M3
shows a back button only in a single-pane list-detail. The back arrow mirrors in a
right-to-left document.
`navigation` is the pane's section navigation (``, ``), under the bar
and above the body, with the body's margins; it is not the bar's leading button.
It takes `as` (`div` by default: `section`, `article`, `main` …), `hide-below` and `hide-from`
like every layout component, and the caller's `class` and `style` land on it untouched. Drawn
by resources/css/layout/pane.css. --}}
@props([
'as' => null,
'title' => null,
'subtitle' => null,
'heading' => 'h1',
'sticky' => true,
'back' => null,
'width' => null,
'hideBelow' => null,
'hideFrom' => null,
])
@php
$layout = \NoNameWeb\LivewireMaterial\Support\Layout::class;
$element = $layout::element($as);
$backLink = is_string($back) && $back !== '' ? $back : null;
$backAction = $back === true;
$bar = filled($title) || isset($actions) || isset($leading) || $backLink !== null || $backAction;
$attributes = $attributes->merge(array_filter([
'data-md-pane' => true,
'data-md-width' => $layout::choice($width, ['full', 'narrow', 'medium', 'wide']),
] + $layout::visibility($hideBelow, $hideFrom), fn ($value): bool => $value !== null));
@endphp
<{{ $element }} {{ $attributes }}>
@if ($bar)
@if (isset($leading))
{{ $leading }}
@elseif ($backLink !== null || $backAction)
@if ($backLink !== null)
@else
@endif
@endif
@isset($actions)
{{ $actions }}
@endisset
@endif
@isset($navigation)
{{ $navigation }}
@endisset
{{ $slot }}
{{ $element }}>