Document and layout
The HTML document and layout of the store pages: the pages are drawn with the navbar and the footer, in the themes' shared layout or in a layout of your own.
zb:shop.document zubazar/ui-pro
This component is in Zubazar UI Pro; Zubazar UI Pro brings Zubazar UI with it. Installing Zubazar UI Pro →
Your own layout
Set layout to the name of a view of your own: the theme's look stays and the frame is yours.
{{-- config/zubazar-ui-pro.php (commerce): 'layout' => 'layouts.store' --}}
{{-- resources/views/layouts/store.blade.php --}}
<zb:shop.document :title="\Zubazar\Commerce\Shop::pageTitle($title ?? null)" class="flex min-h-dvh flex-col bg-page">
<div class="bg-inverse py-2 text-center text-sm text-on-inverse">Free shipping on orders over ₺750</div>
<zb:shop.site-header />
<main id="main" class="flex-1">
@yield('content')
{{ $slot ?? '' }}
</main>
<zb:shop.site-footer />
</zb:shop.document>
| Prop | Values |
|---|---|
<zb:shop.site-header /> | The skip link and the chosen navbar preset (navbar), else the theme's own navbar |
<zb:shop.site-footer /> | The chosen footer preset (footer), else the theme's own footer |
The document
<zb:shop.document> writes the <head>, the theme's fonts, the notification area and Livewire's scripts in one tag; mode and brand-color fix the look.
<zb:shop.document class="bg-page" mode="light" brand-color="green">
<zb:slot:head>
<link rel="icon" href="/favicon.svg" />
</zb:slot:head>
<zb:shop.site-header />
<main id="main">@yield('content')</main>
</zb:shop.document>
{{-- A page's own script (inside the page) --}}
@push('page-scripts')
<script>…</script>
@endpush
| Prop | Values |
|---|---|
mode | light | dark | system: fixes the page's appearance |
brand-color | Fixes the primary colour: default, green, red, yellow, blue, gray, dark or #rrggbb |
Page title
Shop::pageTitle() builds the tab title from the page's title and the store's name: My cart · Zubazar Store.
{{-- A Blade page --}}
@section('title', 'My cart')
{{-- A Livewire page: ->layout(Themes::layout('commerce'))->title('My cart') --}}
{{-- The layout --}}
<zb:shop.document :title="\Zubazar\Commerce\Shop::pageTitle($title ?? null)">
…
</zb:shop.document>
{{-- In the tab: My cart · Zubazar Store --}}
Props
The values the component takes. What are props and slots?
| Prop | Type | Default | Description |
|---|---|---|---|
title | — | null | The tab title; null: Shop::pageTitle() |
mode | — | null | light · dark · system: fixes the page's appearance; null: the visitor's choice, else the system's |
theme | — | null | A theme's key; null: the request's store theme (Themes::current('commerce')) |
scope | — | null | Where the visitor's choices are kept; null: the store's (shop), apart from the panel's |
brand-color | — | null | A fixed primary colour (an Appearance::COLORS name or #rrggbb); with both null, the brand_color setting, else the theme's colour |
default-brand-color | — | null | The colour while the visitor has picked none; with both null, the brand_color setting, else the theme's colour |
indent | number | 8 | The indentation of the <head> lines in the page source (spaces) |
(attributes) | — | — | Go to the <body>: class … |
Slots: head (lines added at the end of <head>), default (the page)
Advanced
Your own document
If you write the document yourself (e.g. to show the store pages in the panel's layout), put <zb:layout.head> in <head>. Add the @vite, @zubazarFonts, <zb:toast-container /> and @livewireScripts lines yourself.
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}" data-theme="{{ \Zubazar\Ui\Support\Appearance::light() }}">
<head>
<zb:layout.head :title="\Zubazar\Commerce\Shop::pageTitle($title ?? null)">
@vite(config('zubazar-ui-pro.commerce.vite'))
@zubazarFonts(\Zubazar\Themes\Themes::current('commerce')->fontAliases())
</zb:layout.head>
</head>
<body class="bg-page text-body">
<zb:shop.site-header />
<main id="main">@yield('content'){{ $slot ?? '' }}</main>
<zb:shop.site-footer />
<zb:toast-container />
@livewireScripts
</body>
</html>
| Prop | Values |
|---|---|
title | The tab title; null: the application's name |
mode | light | dark | system; null: the visitor's choice, else the system's |
theme | A theme's key; null: the request's theme |
scope | Where the choices are kept; null: the request's (shop in the store) |
brand-color | A fixed primary colour (an Appearance::COLORS name or #rrggbb); wins over the visitor's choice |
default-brand-color | The colour while the visitor has picked none; null: the theme's colour |
nonce | The boot script's CSP nonce; Vite::cspNonce() by default |
indent | The indentation of the lines in the page source; 4 by default |
Skip link
<zb:shop.site-header /> puts a "Skip to content" link before the navbar; in a navbar of your own, add <zb:shop.skip-link /> before it yourself. Click the preview and press Tab.
<zb:shop.skip-link />
<header>…</header>
<main id="main">…</main>
Developer notes
- The shared layout is the
zubazar-ui-pro::commerce.layoutview:<zb:shop.site-header />,<main id="main">and<zb:shop.site-footer />on the theme's page background (bg-page). - A Livewire page takes the layout with
->layout(Themes::layout('commerce'))and gives its title with->title(); a Blade page uses@section('title'). Themes::layout()returns the configured layout, else the theme's own layout, else the shared one; you do not need to change your pages when the layout changes.- Put the content in the
zb-containerclass: it follows the store's width (commerce.content_width) and lines up with the navbar. - In your own layout, Blade pages come through
@yield('content')and Livewire pages through$slot; the navbar and footer are optional, and the content's container needsid="main". - The colours, corners and fonts come from the theme's tokens;
<zb:shop.document>loads the fonts from the theme's descriptor and the assets from theviteandheadsettings. - While the settings panel is on (
commerce.switching),<zb:shop.document>also adds the store settings (<zb:theme-switcher as="drawer">); its attributes go to<body>. - The current theme is written as
<html data-theme>(the theme's dark member in dark mode); the visitor's mode and colour are kept in the store's preference scope (shop), apart from the panel's. - The
headslot is added at the end of<head>; give one page's script with@push('page-scripts'), and the document prints it after Livewire's scripts. - The title takes the page's
@section('title')first, else the given value; with neither, only the store's name (Shop::name()) is written. - Livewire's
->title()reaches the layout as$title; a<zb:shop.document>withouttitledoes not see it, so pass$title ?? nullin the layout. <zb:layout.head>writes the meta tags, the title and the boot script that applies the mode, the theme and the primary colour before the first paint.- In your own document, give
<html>the theme's light member (Appearance::light()); when the route is in thezb.theme:commercegroup, the theme and the preference scope (shop) come from it. - The skip link is hidden until it has focus; a keyboard visitor sees it on the first Tab and goes past the menu to
#main.