Release LaySite 1.4.0 canvas editing and layers

This commit is contained in:
2026-11-26 01:28:51 +08:00
parent d5bedabaa1
commit 2e9b5fa17c
19 changed files with 915 additions and 227 deletions
+26 -15
View File
@@ -1,6 +1,7 @@
<?php
use App\Content\Buttons;
use App\Content\CanvasStyle;
use App\Content\SiteDesign;
use App\Content\View;
$e = View::escape(...);
@@ -11,6 +12,12 @@ $showHero = $page['visibility']['hero'] ?? true;
$heroLinks = array_filter($page['sections'], static fn (array $section): bool => $section['style'] === 'hero-links');
$alignments = $page['alignments'];
$presentation = $page['presentation'] ?? [];
$showBreadcrumbs = !$home && !$shared && !$system;
$customCrumbs = array_key_exists('breadcrumbLinks', $presentation);
$crumbs = !$showBreadcrumbs ? [] : ($customCrumbs
? SiteDesign::parseLinks($presentation['breadcrumbLinks']) : [['/', '首页'], ['/' . $page['slug'], $page['name']]]);
$customHero = array_key_exists('heroHtml', $presentation);
$renderManagedHero = !$customHero || $canvas;
$style = static fn (string $role): string => CanvasStyle::classes($presentation, $role);
$text = static fn (string $role, string $value): string => CanvasStyle::text($presentation, $role, $value);
$styleField = static fn (string $role): string => $canvas ? ' data-studio-style-field="' . $role . '"' : '';
@@ -21,24 +28,27 @@ $field = static fn (string $name): string => $canvas ? ' data-studio-field="' .
<?php if ($showHero || $canvas || $heroLinks): ?>
<section class="hero hero-<?= $e($page['slug']) ?><?= $style('hero') ?>" id="home" data-enter<?= $canvas ? ' data-studio-hero' : '' ?><?= $styleField('hero') ?>>
<?php if ($showHero || $canvas): ?>
<div class="wrap hero-inner<?= $page['image'] === '' ? ' hero-text-only' : '' ?>"<?= $canvas ? ' data-studio-hero-content' : '' ?><?= $showHero ? '' : ' hidden' ?>>
<?php if ($customHero || $canvas): ?>
<div class="studio-hero-html rich"<?= $canvas ? ' data-studio-hero-source data-studio-part="body"' : '' ?><?= !$customHero || !$showHero ? ' hidden' : '' ?>><?= $presentation['heroHtml'] ?? '' ?></div>
<?php endif ?>
<?php if ($renderManagedHero): ?>
<div class="wrap hero-inner<?= $page['image'] === '' ? ' hero-text-only' : '' ?>"<?= $canvas ? ' data-studio-hero-content' : '' ?><?= $showHero && !$customHero ? '' : ' hidden' ?>>
<div class="hero-copy">
<?php if (!$home && !$shared && !$system): ?>
<nav class="breadcrumbs" aria-label="面包屑" itemscope itemtype="https://schema.org/BreadcrumbList">
<span itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
<a itemprop="item" href="/"><span itemprop="name">首页</span></a>
<meta itemprop="position" content="1">
</span>
<span class="crumb-divider" aria-hidden="true">/</span>
<span itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
<a itemprop="item" href="/<?= $e($page['slug']) ?>" aria-current="page"><span itemprop="name"<?= $field('name') ?>><?= $e($page['name']) ?></span></a>
<meta itemprop="position" content="2">
</span>
<?php if ($showBreadcrumbs && ($crumbs || $canvas)): ?>
<nav class="breadcrumbs<?= $style('breadcrumbs') ?>" aria-label="面包屑" itemscope itemtype="https://schema.org/BreadcrumbList"<?= $canvas ? ' data-studio-breadcrumbs' : '' ?><?= $styleField('breadcrumbs') ?><?= $crumbs ? '' : ' hidden' ?>>
<?php foreach ($crumbs as $index => [$url, $label]): ?>
<?php $role = 'crumb-' . $index; ?>
<?php if ($index > 0): ?><span class="crumb-divider" aria-hidden="true">/</span><?php endif ?>
<span itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
<a itemprop="item" href="<?= $e($url) ?>"<?= $index === count($crumbs) - 1 ? ' aria-current="page"' : '' ?><?= $styleField($role) ?> class="<?= trim($style($role)) ?>"><span itemprop="name"><?= $text($role, $label) ?></span></a>
<meta itemprop="position" content="<?= $index + 1 ?>">
</span>
<?php endforeach ?>
</nav>
<?php else: ?>
<p class="overline hero-label"><?= $e($site['name']) ?></p>
<?php elseif (!$showBreadcrumbs): ?>
<p class="overline hero-label"<?= $field('eyebrow') ?><?= $styleField('eyebrow') ?>><?= $text('eyebrow', $presentation['heroEyebrow'] ?? $site['name']) ?></p>
<?php endif ?>
<h1<?= isset($alignments['heading']) ? ' class="' . trim(View::alignmentClass($alignments['heading'])) . '"' : '' ?><?= $alignField('heading') ?>><span class="hero-heading-primary<?= $style('heading') ?>"<?= $field('heading') ?><?= $styleField('heading') ?>><?= $text('heading', $page['heading']) ?></span><?php if ($canvas): ?><span class="studio-accent<?= $style('accent') ?>"<?= $field('accent') ?><?= $styleField('accent') ?>><?= $text('accent', $page['accent']) ?></span><?php elseif ($page['accent'] !== ''): ?><br><span class="<?= trim($style('accent')) ?>"><?= $text('accent', $page['accent']) ?></span><?php endif ?></h1>
<h1<?= isset($alignments['heading']) ? ' class="' . trim(View::alignmentClass($alignments['heading'])) . '"' : '' ?><?= $alignField('heading') ?>><span class="hero-heading-primary<?= $style('heading') ?>"<?= $field('heading') ?><?= $styleField('heading') ?>><?= $text('heading', $page['heading']) ?></span><?php if ($canvas || $page['accent'] !== ''): ?><span class="hero-accent<?= $style('accent') ?>"<?= $field('accent') ?><?= $styleField('accent') ?>><?= $text('accent', $page['accent']) ?></span><?php endif ?></h1>
<p class="hero-lead<?= View::alignmentClass($alignments['lead'] ?? null) ?><?= $style('lead') ?>"<?= $field('lead') ?><?= $alignField('lead') ?><?= $styleField('lead') ?>><?= $text('lead', $page['lead']) ?></p>
<div class="actions hero-actions<?= View::alignmentClass($alignments['actions'] ?? null) ?><?= $style('actions') ?>"<?= $alignField('actions') ?><?= $styleField('actions') ?>>
<?php foreach (Buttons::validate($page['actions']) as $index => [$url, $label, $buttonStyle, $blank]): ?>
@@ -54,6 +64,7 @@ $field = static fn (string $name): string => $canvas ? ' data-studio-field="' .
<?php endif ?>
</div>
<?php endif ?>
<?php endif ?>
<?php foreach ($heroLinks as $section): ?>
<?= View::fragment('section', ['section' => $section, 'moment' => false, 'canvas' => $canvas, 'pageSlug' => $page['slug']]) ?>
<?php endforeach ?>