forked from laysense/laysite
36 lines
2.1 KiB
PHP
36 lines
2.1 KiB
PHP
<?php
|
|
use App\Content\DesignLibrary;
|
|
use App\Content\View;
|
|
|
|
$e = View::escape(...);
|
|
$data = $item['payload'];
|
|
$errorId = static fn (string $name): string => 'design-error-' . View::escape($name);
|
|
$describe = static fn (string $name): string => ' aria-describedby="' . $errorId($name) . '"'
|
|
. ($field === $name ? ' aria-invalid="true"' : '');
|
|
$fieldError = static function (string $name) use ($errorId, $field, $error, $e): void {
|
|
$invalid = $field === $name;
|
|
?>
|
|
<small class="design-field-error" id="<?= $errorId($name) ?>" data-field-error="<?= $e($name) ?>" role="alert" tabindex="-1"<?= $invalid ? '' : ' hidden' ?>><?= $invalid ? $e($error) : '' ?></small>
|
|
<?php
|
|
};
|
|
?>
|
|
<a class="back-link" href="/admin/design">返回站点设计</a>
|
|
<header class="admin-heading">
|
|
<h1>配色方案</h1>
|
|
<?php if ($key !== 'new'): ?>
|
|
<?= View::fragment('admin-view-link', ['href' => '/admin/design/palette/' . $key . '/preview', 'icon' => 'preview', 'label' => '预览已保存的配置']) ?>
|
|
<?php endif ?>
|
|
</header>
|
|
<?= View::fragment('admin-feedback', ['error' => $field === '' ? $error : '', 'saved' => $saved]) ?>
|
|
<form class="admin-form admin-panel" method="post" action="/admin/design/palette/<?= $e($key) ?>">
|
|
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
|
<input type="hidden" name="version" value="<?= $e($item['version']) ?>">
|
|
<label>配置名称<input name="name" maxlength="100" value="<?= $e($item['name']) ?>" required<?= $describe('name') ?>><?php $fieldError('name'); ?></label>
|
|
<div class="palette-fields">
|
|
<?php foreach (DesignLibrary::COLORS as $color => [$label, $fallback]): ?>
|
|
<label><?= $e($label) ?><input type="<?= $field === $color ? 'text' : 'color' ?>" name="<?= $e($color) ?>" value="<?= $e($data[$color] ?? $fallback) ?>"<?= $describe($color) ?>><?php $fieldError($color); ?></label>
|
|
<?php endforeach ?>
|
|
</div>
|
|
<div class="form-submit"><button type="submit" class="button button-primary"><?= View::fragment('studio-icon', ['icon' => 'save']) ?>保存配置</button></div>
|
|
</form>
|