forked from laysense/laysense.cn
Add category-first template library and improve admin dashboard
This commit is contained in:
@@ -8,16 +8,34 @@ final class BlockTemplates
|
||||
{
|
||||
public const ARTICLE_FEED = '{"categories":["announcement","news","product"],"mode":"merged","limit":6}';
|
||||
|
||||
public const ELEMENTS = [
|
||||
'paragraph' => ['段落', '<p>填写正文。</p>'],
|
||||
'subheading' => ['小标题', '<h3>填写小标题</h3>'],
|
||||
'bullet-list' => ['项目列表', '<ul><li>填写列表项</li><li>填写列表项</li></ul>'],
|
||||
'button' => ['按钮', '<p><a class="button button-primary" href="#contact">联系来笙</a></p>'],
|
||||
'separator' => ['分割线', '<hr class="studio-divider">'],
|
||||
'code' => ['代码块', '<pre class="studio-code"><code>填写代码</code></pre>'],
|
||||
'image' => ['图片', '', 'image/'],
|
||||
'video' => ['视频', '', 'video/'],
|
||||
'audio' => ['音频', '', 'audio/'],
|
||||
public const ELEMENT_GROUPS = [
|
||||
'text-elements' => ['文字与列表', [
|
||||
'paragraph' => ['段落', '<p>填写正文。</p>'],
|
||||
'subheading' => ['小标题', '<h3>填写小标题</h3>'],
|
||||
'lead' => ['导语', '<p class="studio-lead">填写本节的导语。</p>'],
|
||||
'blockquote' => ['引用', '<blockquote><p>填写需要引用的内容。</p></blockquote>'],
|
||||
'bullet-list' => ['项目列表', '<ul><li>填写列表项</li><li>填写列表项</li></ul>'],
|
||||
'ordered-list' => ['编号列表', '<ol><li>填写第一项</li><li>填写第二项</li></ol>'],
|
||||
'definition-list' => ['术语说明', '<dl class="studio-definitions"><dt>填写术语</dt><dd>填写术语说明。</dd></dl>'],
|
||||
]],
|
||||
'link-elements' => ['链接与按钮', [
|
||||
'button' => ['主按钮', '<p><a class="button button-primary" href="#contact">联系来笙</a></p>'],
|
||||
'outline-button' => ['描边按钮', '<p><a class="button button-outline" href="/services">查看服务</a></p>'],
|
||||
'text-link' => ['文字链接', '<p><a href="/articles">阅读文章</a></p>'],
|
||||
'email-link' => ['邮件链接', '<p><a href="mailto:hello@example.com">发送邮件</a></p>'],
|
||||
]],
|
||||
'media-elements' => ['图片与影音', [
|
||||
'image' => ['图片', '', 'image/'],
|
||||
'video' => ['视频', '', 'video/'],
|
||||
'audio' => ['音频', '', 'audio/'],
|
||||
]],
|
||||
'structure-elements' => ['版式与数据', [
|
||||
'separator' => ['分割线', '<hr class="studio-divider">'],
|
||||
'spacer' => ['留白', '<div class="studio-spacer"></div>'],
|
||||
'code' => ['代码块', '<pre class="studio-code"><code>填写代码</code></pre>'],
|
||||
'basic-table' => ['数据表格', '<table><thead><tr><th scope="col">名称</th><th scope="col">数据</th></tr></thead><tbody><tr><td>填写名称</td><td>填写数据</td></tr></tbody></table>'],
|
||||
'disclosure' => ['折叠内容', '<div class="faq"><details><summary>填写折叠标题</summary><div><p>填写展开后的内容。</p></div></details></div>'],
|
||||
]],
|
||||
];
|
||||
|
||||
public const GROUPS = [
|
||||
@@ -31,6 +49,7 @@ final class BlockTemplates
|
||||
'cover' => ['封面与横幅', [
|
||||
'cover' => ['图文封面', '<div class="studio-cover"><img src="/assets/original/pagepan-example.webp" alt="" loading="lazy"><div><h3>用一句话介绍你的产品</h3><p>在首段说明访客能获得什么。</p><a class="button button-primary" href="/services">查看服务</a></div></div>'],
|
||||
'banner' => ['横幅', '<div class="studio-banner"><h3>用一句话介绍你的项目</h3><p>简要说明项目能为访客做什么。</p><a class="button button-primary" href="/services">了解更多</a></div>'],
|
||||
'two-actions' => ['双按钮横幅', '<div class="studio-banner studio-banner-two"><div><h3>选择下一步</h3><p>介绍访客可以立即做什么。</p></div><div class="actions"><a class="button button-primary" href="/services">查看服务</a><a class="button button-outline" href="/#contact">联系我们</a></div></div>'],
|
||||
]],
|
||||
'layout' => ['图文与布局', [
|
||||
'image' => ['图文', '<div class="studio-split"><img src="/assets/original/home-hero.webp" alt="" loading="lazy"><div><h3>介绍主题</h3><p>在这里说明图片或产品。</p></div></div>'],
|
||||
@@ -51,11 +70,14 @@ final class BlockTemplates
|
||||
'faq' => ['常见问题', '<div class="faq"><details><summary>请输入问题</summary><div><p>请输入答案。</p></div></details></div>'],
|
||||
'timeline' => ['时间线', '<ol class="studio-timeline"><li><h3>确定目标</h3><p>填写这一阶段需要完成的事项。</p></li><li><h3>实施与验收</h3><p>填写交付时间与验收标准。</p></li></ol>'],
|
||||
'checklist' => ['清单', '<ul class="studio-checklist"><li>填写必备材料</li><li>填写提交条件</li><li>填写确认事项</li></ul>'],
|
||||
'changelog' => ['更新记录', '<div class="studio-releases"><article><h3>版本 2.0</h3><p>填写主要功能或改进。</p></article><article><h3>版本 1.0</h3><p>填写上一版本的更新内容。</p></article></div>'],
|
||||
'pricing' => ['双方案报价', '<div class="card-grid price-grid studio-pricing"><article class="content-card price-card"><h3>基础方案</h3><p class="price-value">填写价格</p><p>填写方案包含的服务。</p><a class="button button-outline" href="/#contact">咨询基础方案</a></article><article class="content-card price-card"><h3>进阶方案</h3><p class="price-value">填写价格</p><p>填写扩展服务或权益。</p><a class="button button-primary" href="/#contact">咨询进阶方案</a></article></div>'],
|
||||
]],
|
||||
'actions' => ['导航与引导', [
|
||||
'navigation' => ['快速导航', '<ul class="studio-quick-nav"><li><a href="/services">产品与服务</a></li><li><a href="/articles">动态与文章</a></li><li><a href="/#contact">联系来笙</a></li></ul>'],
|
||||
'cta' => ['行动按钮', '<p>说明下一步。</p><p><a class="button button-primary" href="#contact">联系来笙</a></p>'],
|
||||
'resources' => ['资料与链接', '<ul class="studio-resources"><li><a href="/pagepan#download">获取 PAGEPAN</a><span>应用下载</span></li><li><a href="/articles">浏览动态与文档</a><span>网站资源</span></li></ul>'],
|
||||
'contact-card' => ['联系方式', '<div class="studio-contact"><div><h3>联系团队</h3><p>填写咨询范围与回复时间。</p></div><dl class="studio-definitions"><dt>电子邮件</dt><dd><a href="mailto:hello@example.com">hello@example.com</a></dd><dt>服务时间</dt><dd>填写工作时间</dd></dl></div>'],
|
||||
]],
|
||||
];
|
||||
|
||||
|
||||
@@ -591,7 +591,7 @@ class AdminController
|
||||
], $status);
|
||||
}
|
||||
|
||||
return View::render($view, $data + ['token' => $token, 'user' => $this->user], $status, true);
|
||||
return View::render($view, $data + ['token' => $token, 'user' => $this->user, 'adminPath' => $request->path()], $status, true);
|
||||
}
|
||||
|
||||
protected function error(Request $request, string $message, int $status): Response
|
||||
|
||||
@@ -2,24 +2,58 @@
|
||||
use App\Content\View;
|
||||
|
||||
$e = View::escape(...);
|
||||
$live = count(array_filter($pages, static fn (array $page): bool => $page['status'] === 'published'));
|
||||
?>
|
||||
<header class="admin-heading">
|
||||
<div><h1>内容管理</h1><p>管理网站页面、文章、公告和产品动态。</p></div>
|
||||
<div class="actions"><a class="button button-primary" href="/admin/new-page">新建页面</a>
|
||||
<a class="button button-outline" href="/admin/articles/new">新建文章</a></div>
|
||||
<header class="admin-heading dashboard-heading">
|
||||
<h1>网站后台</h1>
|
||||
<div class="actions">
|
||||
<a class="button button-primary" href="/admin/new-page">新建页面</a>
|
||||
<a class="button button-outline" href="/admin/articles/new">写文章</a>
|
||||
</div>
|
||||
</header>
|
||||
<section class="admin-panel" aria-labelledby="pages-title">
|
||||
<h2 id="pages-title">网站页面</h2>
|
||||
<ul class="admin-list">
|
||||
<?php foreach ($pages as $page): ?>
|
||||
<li>
|
||||
<div><strong><?= $e($page['name']) ?></strong><small><?= $e($page['slug'] === 'home' ? '/' : '/' . $page['slug']) ?> · <?= $page['status'] === 'draft' ? '草稿' : '已发布' ?></small></div>
|
||||
<a class="button button-outline" href="/admin/pages/<?= $e($page['slug']) ?>">编辑页面</a>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
</section>
|
||||
<section class="admin-panel" aria-labelledby="recent-title">
|
||||
<div class="admin-heading compact"><h2 id="recent-title">最近编辑的文章</h2><a href="/admin/articles">管理全部文章</a></div>
|
||||
<?= View::fragment('admin-article-list', ['articles' => $articles]) ?>
|
||||
</section>
|
||||
<div class="dashboard-grid">
|
||||
<section class="admin-panel dashboard-pages" aria-labelledby="pages-title" data-page-list>
|
||||
<div class="admin-heading compact">
|
||||
<h2 id="pages-title">网站页面</h2>
|
||||
<p class="field-note"><?= $live ?> 个已发布 · <?= count($pages) - $live ?> 个草稿</p>
|
||||
</div>
|
||||
<div class="dashboard-filters" data-page-filters hidden>
|
||||
<label>查找页面<input type="search" data-page-search placeholder="页面名称或地址"></label>
|
||||
<label>发布状态<select data-page-status>
|
||||
<option value="">全部状态</option>
|
||||
<option value="published">已发布</option>
|
||||
<option value="draft">草稿</option>
|
||||
</select></label>
|
||||
</div>
|
||||
<p class="empty-state" data-page-empty role="status"<?= $pages ? ' hidden' : '' ?>><?= $pages ? '没有匹配的页面。' : '暂无页面。' ?></p>
|
||||
<ul class="admin-list dashboard-page-list">
|
||||
<?php foreach ($pages as $page): ?>
|
||||
<?php $path = $page['slug'] === 'home' ? '/' : '/' . $page['slug']; $published = $page['status'] === 'published'; ?>
|
||||
<li data-page-item="<?= $e($page['status']) ?>" data-page-label="<?= $e($page['name'] . ' ' . $page['title'] . ' ' . $path) ?>">
|
||||
<div class="dashboard-page-label"><strong><?= $e($page['name']) ?></strong><small><?= $e($path) ?></small></div>
|
||||
<span class="dashboard-page-state" data-published="<?= $published ? 'true' : 'false' ?>"><?= $published ? '已发布' : '草稿' ?></span>
|
||||
<div class="dashboard-page-actions">
|
||||
<a class="button button-outline" href="/admin/pages/<?= $e($page['slug']) ?>">编辑页面</a>
|
||||
<a href="<?= $e($published ? $path : '/admin/pages/' . $page['slug'] . '/preview') ?>" target="_blank" rel="noopener"><?= $published ? '查看' : '预览' ?></a>
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
</section>
|
||||
<div class="dashboard-secondary">
|
||||
<section class="admin-panel" aria-labelledby="recent-title">
|
||||
<div class="admin-heading compact"><h2 id="recent-title">最近编辑的文章</h2></div>
|
||||
<?= View::fragment('admin-article-list', ['articles' => $articles]) ?>
|
||||
<a class="back-link" href="/admin/articles">管理全部文章</a>
|
||||
</section>
|
||||
<section class="admin-panel dashboard-settings" aria-labelledby="quick-title">
|
||||
<h2 id="quick-title">站点编辑</h2>
|
||||
<ul>
|
||||
<li><a href="/admin/settings/header">编辑页头</a></li>
|
||||
<li><a href="/admin/settings/footer">编辑页脚</a></li>
|
||||
<li><a href="/admin/settings/cdn">静态资源 CDN</a></li>
|
||||
<li><a href="/admin/media">打开媒体库</a></li>
|
||||
</ul>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+25
-11
@@ -2,6 +2,13 @@
|
||||
use App\Content\View;
|
||||
|
||||
$e = View::escape(...);
|
||||
$active = match (true) {
|
||||
str_starts_with($adminPath, '/admin/article') => 'articles',
|
||||
str_starts_with($adminPath, '/admin/media') => 'media',
|
||||
str_starts_with($adminPath, '/admin/settings') => 'settings',
|
||||
$adminPath === '/admin/password' => '',
|
||||
default => 'pages',
|
||||
};
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
@@ -29,18 +36,25 @@ $e = View::escape(...);
|
||||
<div class="admin-wrap admin-bar-inner">
|
||||
<a class="wordmark" href="/admin" aria-label="来笙内容管理首页"><img src="/assets/wordmark.webp" alt="来笙 Laysense" width="130" height="33"></a>
|
||||
<?php if ($user): ?>
|
||||
<nav aria-label="后台导航">
|
||||
<a href="/admin">页面</a>
|
||||
<a href="/admin/articles">文章</a>
|
||||
<a href="/admin/media">媒体库</a>
|
||||
<a href="/admin/settings/header">网站设置</a>
|
||||
<a href="/admin/password">修改密码</a>
|
||||
<a href="/">访问网站</a>
|
||||
<form method="post" action="/admin/logout">
|
||||
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
||||
<button class="button button-outline" type="submit">退出</button>
|
||||
</form>
|
||||
<nav class="admin-primary" aria-label="后台导航">
|
||||
<a href="/admin"<?= $active === 'pages' ? ' aria-current="page"' : '' ?>>页面</a>
|
||||
<a href="/admin/articles"<?= $active === 'articles' ? ' aria-current="page"' : '' ?>>文章</a>
|
||||
<a href="/admin/media"<?= $active === 'media' ? ' aria-current="page"' : '' ?>>媒体库</a>
|
||||
<a href="/admin/settings/header"<?= $active === 'settings' ? ' aria-current="page"' : '' ?>>网站设置</a>
|
||||
</nav>
|
||||
<div class="admin-utility">
|
||||
<a href="/">访问网站</a>
|
||||
<details class="admin-account">
|
||||
<summary>账户</summary>
|
||||
<div class="admin-account-menu">
|
||||
<a href="/admin/password">修改密码</a>
|
||||
<form method="post" action="/admin/logout">
|
||||
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
||||
<button type="submit">退出登录</button>
|
||||
</form>
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<a class="back-link" href="/">返回网站</a>
|
||||
<?php endif ?>
|
||||
|
||||
+2
-51
@@ -2,7 +2,6 @@
|
||||
use App\Content\Database;
|
||||
use App\Content\SiteDesign;
|
||||
use App\Content\View;
|
||||
use App\Content\BlockTemplates;
|
||||
|
||||
$e = View::escape(...);
|
||||
$slug = $page['slug'];
|
||||
@@ -20,56 +19,8 @@ $previewUrl = '/admin/pages/' . $slug . '/preview';
|
||||
<?= View::fragment('admin-feedback', compact('error', 'saved')) ?>
|
||||
<div class="studio-layout">
|
||||
<aside class="admin-panel studio-library" aria-labelledby="studio-library-title">
|
||||
<h2 id="studio-library-title">区块模板</h2>
|
||||
<?= View::fragment('studio-templates') ?>
|
||||
<details class="studio-layers">
|
||||
<summary>首屏与目录</summary>
|
||||
<button type="button" disabled data-hero-control="image">首屏图片</button>
|
||||
<button type="button" disabled data-hero-control="1">首屏按钮 1</button>
|
||||
<button type="button" disabled data-hero-control="2">首屏按钮 2</button>
|
||||
<button type="button" disabled data-hero-control="navigation">本页目录</button>
|
||||
</details>
|
||||
<details class="studio-layers">
|
||||
<summary>按锚点新建区块</summary>
|
||||
<form class="admin-form" method="post" action="/admin/page-blocks/<?= $e($slug) ?>">
|
||||
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
||||
<input type="hidden" name="operation" value="create">
|
||||
<label>锚点<input name="key" pattern="[a-z0-9]+(-[a-z0-9]+)*" maxlength="70" placeholder="overview" required></label>
|
||||
<label>模板<select name="preset">
|
||||
<?php foreach (BlockTemplates::GROUPS as [$category, $templates]): ?>
|
||||
<optgroup label="<?= $e($category) ?>">
|
||||
<?php foreach ($templates as $preset => [$label]): ?>
|
||||
<option value="<?= $e($preset) ?>"><?= $e($label) ?></option>
|
||||
<?php endforeach ?>
|
||||
</optgroup>
|
||||
<?php endforeach ?>
|
||||
</select></label>
|
||||
<button type="submit" class="button button-outline">新建</button>
|
||||
</form>
|
||||
</details>
|
||||
<details class="studio-layers" id="blocks">
|
||||
<summary>区块顺序</summary>
|
||||
<ul class="admin-list studio-blocks">
|
||||
<?php foreach ($page['sections'] as $index => $item): ?>
|
||||
<li>
|
||||
<div><strong><?= $e($item['title']) ?></strong><small>#<?= $e($item['key']) ?></small></div>
|
||||
<div class="actions studio-block-actions">
|
||||
<button class="button button-outline" type="button" data-canvas-jump="<?= $e($item['key']) ?>" hidden>在画布编辑</button>
|
||||
<a class="button button-outline" href="/admin/pages/<?= $e($slug) ?>/<?= $e($item['key']) ?>">区块设置</a>
|
||||
<form method="post" action="/admin/page-blocks/<?= $e($slug) ?>">
|
||||
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
||||
<input type="hidden" name="key" value="<?= $e($item['key']) ?>">
|
||||
<input type="hidden" name="page_version" value="<?= $e($page['version']) ?>">
|
||||
<input type="hidden" name="version" value="<?= $e($item['version']) ?>">
|
||||
<button class="button button-outline" name="operation" value="up" type="submit" <?= $index === 0 ? 'disabled' : '' ?>>上移</button>
|
||||
<button class="button button-outline" name="operation" value="down" type="submit" <?= $index === count($page['sections']) - 1 ? 'disabled' : '' ?>>下移</button>
|
||||
<button class="button button-outline" name="operation" value="delete" type="submit" data-confirm="删除这个区块?">删除</button>
|
||||
</form>
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
</details>
|
||||
<h2 id="studio-library-title">页面编辑</h2>
|
||||
<?= View::fragment('studio-templates', ['layers' => View::fragment('studio-layers', compact('page', 'slug', 'token'))]) ?>
|
||||
</aside>
|
||||
<div class="studio-workspace">
|
||||
<section class="admin-panel studio-preview" data-preview-studio aria-labelledby="studio-preview-title">
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
use App\Content\BlockTemplates;
|
||||
use App\Content\View;
|
||||
|
||||
$e = View::escape(...);
|
||||
?>
|
||||
<details class="studio-layers">
|
||||
<summary>首屏与目录</summary>
|
||||
<button type="button" disabled data-hero-control="image">首屏图片</button>
|
||||
<button type="button" disabled data-hero-control="1">首屏按钮 1</button>
|
||||
<button type="button" disabled data-hero-control="2">首屏按钮 2</button>
|
||||
<button type="button" disabled data-hero-control="navigation">本页目录</button>
|
||||
</details>
|
||||
<details class="studio-layers">
|
||||
<summary>按锚点新建区块</summary>
|
||||
<form class="admin-form" method="post" action="/admin/page-blocks/<?= $e($slug) ?>">
|
||||
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
||||
<input type="hidden" name="operation" value="create">
|
||||
<label>锚点<input name="key" pattern="[a-z0-9]+(-[a-z0-9]+)*" maxlength="70" placeholder="overview" required></label>
|
||||
<label>模板<select name="preset">
|
||||
<?php foreach (BlockTemplates::GROUPS as [$category, $templates]): ?>
|
||||
<optgroup label="<?= $e($category) ?>">
|
||||
<?php foreach ($templates as $preset => [$label]): ?>
|
||||
<option value="<?= $e($preset) ?>"><?= $e($label) ?></option>
|
||||
<?php endforeach ?>
|
||||
</optgroup>
|
||||
<?php endforeach ?>
|
||||
</select></label>
|
||||
<button type="submit" class="button button-outline">新建</button>
|
||||
</form>
|
||||
</details>
|
||||
<details class="studio-layers" id="blocks">
|
||||
<summary>区块顺序</summary>
|
||||
<ul class="admin-list studio-blocks">
|
||||
<?php foreach ($page['sections'] as $index => $item): ?>
|
||||
<li>
|
||||
<div><strong><?= $e($item['title']) ?></strong><small>#<?= $e($item['key']) ?></small></div>
|
||||
<div class="actions studio-block-actions">
|
||||
<button class="button button-outline" type="button" data-canvas-jump="<?= $e($item['key']) ?>" hidden>在画布编辑</button>
|
||||
<a class="button button-outline" href="/admin/pages/<?= $e($slug) ?>/<?= $e($item['key']) ?>">区块设置</a>
|
||||
<form method="post" action="/admin/page-blocks/<?= $e($slug) ?>">
|
||||
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
||||
<input type="hidden" name="key" value="<?= $e($item['key']) ?>">
|
||||
<input type="hidden" name="page_version" value="<?= $e($page['version']) ?>">
|
||||
<input type="hidden" name="version" value="<?= $e($item['version']) ?>">
|
||||
<button class="button button-outline" name="operation" value="up" type="submit" <?= $index === 0 ? 'disabled' : '' ?>>上移</button>
|
||||
<button class="button button-outline" name="operation" value="down" type="submit" <?= $index === count($page['sections']) - 1 ? 'disabled' : '' ?>>下移</button>
|
||||
<button class="button button-outline" name="operation" value="delete" type="submit" data-confirm="删除这个区块?">删除</button>
|
||||
</form>
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
</details>
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
use App\Content\View;
|
||||
|
||||
$e = View::escape(...);
|
||||
$modules = $kind === 'modules';
|
||||
?>
|
||||
<section role="tabpanel" id="studio-panel-<?= $kind ?>" aria-labelledby="studio-tab-<?= $kind ?>" data-library-panel="<?= $kind ?>" hidden>
|
||||
<ul class="studio-library-categories" data-library-index>
|
||||
<?php foreach ($groups as $group => [$category, $items]): ?>
|
||||
<li><button type="button" data-library-category="<?= $e($group) ?>" data-library-label="<?= $e($category) ?>">
|
||||
<span><?= $e($category) ?></span><small><?= count($items) ?></small>
|
||||
</button></li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
<div class="studio-library-content" data-library-content hidden>
|
||||
<div class="studio-library-category-title">
|
||||
<button type="button" data-library-back>返回分类</button>
|
||||
<h3 data-library-title></h3>
|
||||
</div>
|
||||
<label class="studio-template-search">查找本分类<input type="search" data-template-search autocomplete="off"></label>
|
||||
<?php if ($modules): ?>
|
||||
<label class="studio-insert-mode"><input type="checkbox" data-template-inline> 插入当前正文</label>
|
||||
<?php endif ?>
|
||||
<p class="field-note" data-template-empty hidden role="status">没有匹配的<?= $modules ? '组件' : '元素' ?>。</p>
|
||||
<?php foreach ($groups as $group => [$category, $items]): ?>
|
||||
<div class="<?= $modules ? 'studio-template-cards' : 'studio-element-items' ?>" data-template-group="<?= $e($group) ?>" hidden>
|
||||
<?php foreach ($items as $key => $item): ?>
|
||||
<?php [$label, $markup, $mime] = array_pad($item, 3, ''); ?>
|
||||
<?php if ($modules): ?>
|
||||
<article class="studio-template-card" data-template-card data-library-item data-template-search-text="<?= $e($label . ' ' . $key) ?>">
|
||||
<button type="button" class="studio-template-image" data-template-preview="<?= $e($key) ?>" data-template-title="<?= $e($label) ?>"
|
||||
aria-label="预览<?= $e($label) ?>组件">
|
||||
<img src="/assets/template-previews/<?= $e($key) ?>.webp" alt="" width="768" height="480" loading="lazy">
|
||||
</button>
|
||||
<div class="studio-template-meta">
|
||||
<span><?= $e($label) ?></span>
|
||||
<button type="button" class="button button-outline" disabled data-canvas-template="<?= $e($key) ?>"
|
||||
data-template-title="<?= $e($label) ?>" aria-label="添加<?= $e($label) ?>组件">添加</button>
|
||||
</div>
|
||||
<template data-preset="<?= $e($key) ?>"><?= $markup ?></template>
|
||||
</article>
|
||||
<?php else: ?>
|
||||
<div data-library-item data-template-search-text="<?= $e($label . ' ' . $key) ?>">
|
||||
<button type="button" disabled data-canvas-element="<?= $e($key) ?>"
|
||||
<?php if ($mime): ?>data-element-mime="<?= $e($mime) ?>"<?php endif ?>
|
||||
aria-label="插入<?= $e($label) ?>"><?= $e($label) ?></button>
|
||||
<template data-element="<?= $e($key) ?>"><?= $markup ?></template>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
<?php if ($modules): ?>
|
||||
<p class="field-note" data-template-status role="status"></p>
|
||||
<ul class="studio-pending" data-template-pending aria-label="待保存区块" hidden></ul>
|
||||
<?php else: ?>
|
||||
<p class="field-note" data-element-status role="status"></p>
|
||||
<?php endif ?>
|
||||
</section>
|
||||
@@ -4,55 +4,22 @@ use App\Content\BlockTemplates;
|
||||
use App\Content\View;
|
||||
|
||||
$e = View::escape(...);
|
||||
$labels = ['modules' => '组件', 'elements' => '元素', 'layers' => '图层'];
|
||||
?>
|
||||
<div class="studio-presets" data-canvas-presets>
|
||||
<details class="studio-element-library">
|
||||
<summary>基础元素</summary>
|
||||
<div role="group" aria-label="添加基础元素">
|
||||
<?php foreach (BlockTemplates::ELEMENTS as $key => $element): ?>
|
||||
<?php [$label, $markup, $mime] = array_pad($element, 3, ''); ?>
|
||||
<button type="button" disabled data-canvas-element="<?= $e($key) ?>"
|
||||
<?php if ($mime): ?>data-element-mime="<?= $e($mime) ?>"<?php endif ?>
|
||||
aria-label="插入<?= $e($label) ?>"><?= $e($label) ?></button>
|
||||
<template data-element="<?= $e($key) ?>"><?= $markup ?></template>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
<p class="field-note" data-element-status role="status">选中画布正文后插入。</p>
|
||||
</details>
|
||||
<label class="studio-template-search">搜索模板<input type="search" data-template-search placeholder="按名称或分类搜索" autocomplete="off"></label>
|
||||
<div class="studio-template-filters" role="group" aria-label="模板分类">
|
||||
<button type="button" data-template-filter="" aria-pressed="true">全部</button>
|
||||
<?php foreach (BlockTemplates::GROUPS as $group => [$category]): ?>
|
||||
<button type="button" data-template-filter="<?= $e($group) ?>" aria-pressed="false"><?= $e($category) ?></button>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
<label class="studio-insert-mode"><input type="checkbox" data-template-inline> 插入当前正文</label>
|
||||
<p class="field-note" data-template-status role="status"></p>
|
||||
<ul class="studio-pending" data-template-pending hidden></ul>
|
||||
<p class="field-note" data-template-empty hidden role="status">没有找到匹配的模板。</p>
|
||||
<div class="studio-template-groups">
|
||||
<?php foreach (BlockTemplates::GROUPS as $group => [$category, $templates]): ?>
|
||||
<section class="studio-template-group" data-template-group="<?= $e($group) ?>" aria-labelledby="studio-template-<?= $e($group) ?>">
|
||||
<h3 id="studio-template-<?= $e($group) ?>"><?= $e($category) ?></h3>
|
||||
<div class="studio-template-cards">
|
||||
<?php foreach ($templates as $preset => [$label, $markup]): ?>
|
||||
<article class="studio-template-card" data-template-card data-template-search-text="<?= $e($label . ' ' . $category . ' ' . $preset) ?>">
|
||||
<button type="button" class="studio-template-image" data-template-preview="<?= $e($preset) ?>" data-template-title="<?= $e($label) ?>"
|
||||
aria-label="预览<?= $e($label) ?>模板">
|
||||
<img src="/assets/template-previews/<?= $e($preset) ?>.webp" alt="" width="768" height="480" loading="lazy">
|
||||
</button>
|
||||
<div class="studio-template-meta">
|
||||
<span><?= $e($label) ?></span>
|
||||
<button type="button" class="button button-outline" disabled data-canvas-template="<?= $e($preset) ?>"
|
||||
data-template-title="<?= $e($label) ?>" aria-label="添加<?= $e($label) ?>模板">添加</button>
|
||||
</div>
|
||||
<template data-preset="<?= $e($preset) ?>"><?= $markup ?></template>
|
||||
</article>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
</section>
|
||||
<div class="studio-library-tabs" role="tablist" aria-label="页面编辑工具" data-library-tabs hidden>
|
||||
<?php foreach ($labels as $kind => $label): ?>
|
||||
<button type="button" role="tab" id="studio-tab-<?= $kind ?>" aria-controls="studio-panel-<?= $kind ?>"
|
||||
aria-selected="false" tabindex="-1" data-library-tab="<?= $kind ?>"><?= $e($label) ?></button>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
<?php foreach (['modules' => BlockTemplates::GROUPS, 'elements' => BlockTemplates::ELEMENT_GROUPS] as $kind => $groups): ?>
|
||||
<?= View::fragment('studio-library-panel', compact('kind', 'groups')) ?>
|
||||
<?php endforeach ?>
|
||||
<section role="tabpanel" id="studio-panel-layers" aria-labelledby="studio-tab-layers" data-library-panel="layers">
|
||||
<?= $layers ?>
|
||||
</section>
|
||||
|
||||
<div class="studio-template-peek" data-template-peek aria-hidden="true" hidden>
|
||||
<img alt="">
|
||||
<p></p>
|
||||
|
||||
Reference in New Issue
Block a user