Files
FamilyBook/templates/tasks/_settings_menu.php
T

40 lines
1.9 KiB
PHP
Raw Normal View History

<?php
/**
* 任务模块的「设置」下拉(v24 用户第 10 条)
*
* 用户原话:「和观影一样,新建任务旁边,也是设置,对任务的设置。」
* 所以这里与观影的 _settings_menu.php 用**同一套外观**:只留图标(三条横线)、
* 排在最右侧(靠 CSS 的 margin-left:auto)、条目文字前都有图标。
*
* 用法(require 前 set 好):
* $setCurrent 当前页 key('board'|'settings'|'done'),用来高亮
*/
$setCurrent = (string)($setCurrent ?? '');
$setOn = static function (string $key) use ($setCurrent): string {
return $setCurrent === $key ? ' class="on"' : '';
};
$setIcon = static function (string $name): string {
$paths = [
// 看板设置:分栏
'board' => '<rect x="2" y="3" width="4" height="10" rx="1"/><rect x="7.5" y="3" width="4" height="6" rx="1"/>',
// 已完成:对勾
'done' => '<path d="M3 8.5l3 3 7-7"/>',
];
$d = $paths[$name] ?? '';
if ($d === '') {
return '';
}
return '<svg class="mi" viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"'
. ' fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"'
. ' stroke-linejoin="round">' . $d . '</svg>';
};
?>
<details class="movie-set menu">
<summary class="btn btn-icon" title="任务设置" aria-label="任务设置"><svg viewBox="0 0 16 16" width="18" height="18" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round"><path d="M2.5 4.5h11M2.5 8h11M2.5 11.5h11"/></svg></summary>
<div class="menu-list">
<a href="<?= e(url('tasks/settings')) ?>"<?= $setOn('settings') ?>><?= $setIcon('board') ?><span>分类与看板</span></a>
<a href="<?= e(url('tasks/done')) ?>"<?= $setOn('done') ?>><?= $setIcon('done') ?><span>已完成</span></a>
</div>
</details>
<?php
unset($setCurrent, $setOn, $setIcon);