forked from laysense/laysense.cn
Add category-first template library and improve admin dashboard
This commit is contained in:
@@ -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