v0.0.2
Demos (demo panel, opens in a new tab)

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

PRO

This component is in Zubazar UI Pro; Zubazar UI Pro brings Zubazar UI with it. Installing Zubazar UI Pro →

The shared layout

BLADE

While the layout setting is empty, the pages are drawn in the layout every theme shares; a Blade page takes it with @extends(Themes::layout('commerce')).

blade
{{-- config/zubazar-ui-pro.php (commerce): 'layout' => null --}}
{{-- resources/views/account/orders.blade.php --}}
@extends(\Zubazar\Themes\Themes::layout('commerce'))
@section('title', 'My orders')

@section('content')
    <div class="zb-container py-10">
        …
    </div>
@endsection
PropValues
layoutnull: the shared layout · a view name: your own layout (SHOP_LAYOUT)

Your own layout

BLADE

Set layout to the name of a view of your own: the theme's look stays and the frame is yours.

blade
{{-- 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>
PropValues
<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

BLADE

<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.

blade
<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
PropValues
modelight | dark | system: fixes the page's appearance
brand-colorFixes the primary colour: default, green, red, yellow, blue, gray, dark or #rrggbb

Page title

BLADE

Shop::pageTitle() builds the tab title from the page's title and the store's name: My cart · Zubazar Store.

blade
{{-- 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?

PropTypeDefaultDescription
title—nullThe tab title; null: Shop::pageTitle()
mode—nulllight · dark · system: fixes the page's appearance; null: the visitor's choice, else the system's
theme—nullA theme's key; null: the request's store theme (Themes::current('commerce'))
scope—nullWhere the visitor's choices are kept; null: the store's (shop), apart from the panel's
brand-color—nullA fixed primary colour (an Appearance::COLORS name or #rrggbb); with both null, the brand_color setting, else the theme's colour
default-brand-color—nullThe colour while the visitor has picked none; with both null, the brand_color setting, else the theme's colour
indentnumber8The 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

2 examples

Your own document

BLADE

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.

blade
<!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>
PropValues
titleThe tab title; null: the application's name
modelight | dark | system; null: the visitor's choice, else the system's
themeA theme's key; null: the request's theme
scopeWhere the choices are kept; null: the request's (shop in the store)
brand-colorA fixed primary colour (an Appearance::COLORS name or #rrggbb); wins over the visitor's choice
default-brand-colorThe colour while the visitor has picked none; null: the theme's colour
nonceThe boot script's CSP nonce; Vite::cspNonce() by default
indentThe indentation of the lines in the page source; 4 by default

Developer notes

Events, hooks and details
  • The shared layout is the zubazar-ui-pro::commerce.layout view: <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-container class: 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 needs id="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 the vite and head settings.
  • 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 head slot 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> without title does not see it, so pass $title ?? null in 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 the zb.theme:commerce group, 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.
Zubazar UI · ZubazarDesigned for people.