3.2.27: 评论嵌套引导线按层变色(1层浅蓝/2层深蓝/3层点赞色/更深扩展色轮换,深层线恢复绘制);导航多级下拉修复(depth=2 截断改 0,深层父项 dropdown-submenu + hover 右侧弹出,移动端平铺)

This commit is contained in:
2026-10-25 09:52:07 +08:00
parent 92ffced7cf
commit 0239cbeb2a
7 changed files with 139 additions and 10 deletions
+9 -4
View File
@@ -653,7 +653,11 @@
bottom: 0; bottom: 0;
left: calc(var(--yq-my-indent, 55px) - var(--yq-guide-w, 2px) - var(--yq-guide-gap, 8px)); left: calc(var(--yq-my-indent, 55px) - var(--yq-guide-w, 2px) - var(--yq-guide-gap, 8px));
width: var(--yq-guide-w, 2px); width: var(--yq-guide-w, 2px);
background-color: var(--yq-guide, var(--yq-primary, #00a2ff)); /* 3.2.27:颜色按嵌套层区分 —— 由各评论 li 注入的 --yq-guide-c 决定
(PHP 端 yang_comment_guide_color():第1层保持浅蓝、第2层深蓝、
第3层点赞按钮色 #fb5235、更深扩展色板循环)。
未注入时回落到主题浅蓝,老缓存/插件渲染的评论不受影响。 */
background-color: var(--yq-guide-c, var(--yq-guide, var(--yq-primary, #00a2ff)));
pointer-events: none; pointer-events: none;
} }
@@ -714,9 +718,10 @@
padding-left: var(--yq-my-indent); padding-left: var(--yq-my-indent);
} }
.yang-children .yang-children .yang-children::before { /* 3.2.27:第三层起的引导线**不再关闭**。
content: none; * 原来 content:none 的理由是"三条同色竖线叠成表格观感";现在线按层
} * 变色(浅蓝→深蓝→橙红→…),颜色本身就是层级信号,同色重复的
* 前提不复存在,这条规则跟着过期 —— 保留它第三层就没有线可变色了。 */
/* 新提交的评论:淡入 + 短暂底色,让用户看到自己刚发的那条 */ /* 新提交的评论:淡入 + 短暂底色,让用户看到自己刚发的那条 */
@keyframes yang-comment-in { @keyframes yang-comment-in {
+59
View File
@@ -293,6 +293,65 @@ button:focus {
transform: rotate(180deg); transform: rotate(180deg);
} }
/*--------------------------------------------------------------
导航多级下拉(3.2.27)
--------------------------------------------------------------
* Bootstrap 4 原生不支持嵌套下拉(.dropdown-submenu 在 BS3 有、
* BS4 删了),主题自己补齐。标记来自 theme-navwalker.php:
* 深层父项 <li class="... dropdown-submenu">,子菜单仍是 <ul class="dropdown-menu">。
*
* 桌面端(>992px)交互:**悬停父项,子菜单从右侧弹出**——
* left:100% 让子菜单左边缘贴住 li 右边缘,无缝隙(有缝隙鼠标
* 移过去就会离开 li,子菜单闪没);top:0 让两行首行对齐。
* 子菜单触发链接不带 data-toggle,开合完全走 CSS hover,
* 避免 Bootstrap 的 dropdown JS 用 Popper 重算位置、把子菜单
* 拽回"父项正下方",跟"从右侧弹出"打架。
*
* 移动端(≤992px):悬停不存在,改为**随父级展开直接平铺**:
* position:static + display:block,用左缩进表达层级。
* 整个菜单收起时它也在 .collapse 里,不会提前露出。 */
.navbar-light .navbar-nav .dropdown-submenu {
position: relative;
}
.navbar-light .navbar-nav .dropdown-submenu > .dropdown-menu {
top: 0;
left: 100%;
margin-top: -6px;
}
.navbar-light .navbar-nav .dropdown-submenu:hover > .dropdown-menu {
display: block;
}
/* 深层父项的箭头:顶层的 kicon 下箭头在这里换成朝右的 CSS 三角,
表达"向右还有一层"。必须同时清掉 kicon 字体与 rotate(180deg),
否则 content:"" 配上图标字体渲染不出任何东西。 */
.navbar-light .navbar-nav .dropdown-submenu > a.dropdown-toggle::after {
content: "";
border-top: 0.32em solid transparent;
border-bottom: 0.32em solid transparent;
border-left: 0.32em solid currentColor;
font-family: inherit;
transform: none;
vertical-align: 0.08em;
}
@media screen and (max-width: 992px) {
.navbar-light .navbar-nav .dropdown-submenu > .dropdown-menu {
position: static;
display: block;
float: none;
margin-left: 16px;
border-left: 1px solid rgba(255, 255, 255, 0.25);
}
.navbar-light .navbar-nav .dropdown-submenu > a.dropdown-toggle::after {
display: none;
}
}
@media only screen and (min-width: 992px) { @media only screen and (min-width: 992px) {
.k-nav { .k-nav {
border-bottom: 1px solid transparent; border-bottom: 1px solid transparent;
+1 -1
View File
File diff suppressed because one or more lines are too long
+4 -1
View File
@@ -62,7 +62,10 @@ wp_body_open();
if ( has_nav_menu('header_menu') ) { if ( has_nav_menu('header_menu') ) {
wp_nav_menu( array( wp_nav_menu( array(
'theme_location' => 'header_menu', 'theme_location' => 'header_menu',
'depth' => 2, /* 3.2.27:原来是 2 —— WP 只输出两层,二级子菜单
在 HTML 里根本不存在,"只显示一级菜单"就是它。
0 = 不限层数,能出几层由菜单管理器决定。 */
'depth' => 0,
'container' => 'div', 'container' => 'div',
'container_class' => 'collapse navbar-collapse', 'container_class' => 'collapse navbar-collapse',
'container_id' => 'navbarResponsive', 'container_id' => 'navbarResponsive',
+45 -1
View File
@@ -106,6 +106,37 @@ function yang_comments_plugin_active()
* 否则子评论会被挤到 </li> 外面(详见下方注释) * 否则子评论会被挤到 </li> 外面(详见下方注释)
* @return string * @return string
*/ */
/**
* 嵌套引导线的按层配色(3.2.27)。
*
* $depth 是「线里装着的评论」的深度:
* 2 = 直接回复(第 1 层嵌套)→ 返回 '',CSS 回落到主题浅蓝(保持现状);
* 3 = 第 2 层嵌套 → 深蓝;
* 4 = 第 3 层嵌套 → 点赞按钮背景色(.btn-thumbs 的 #fb5235);
* 5+ → 扩展色板按层循环:确定性的"随机"——同层恒同色、相邻层必异色,
* 页面刷新不变(真随机会让同一层的线各页各色,层级信号反而乱)。
*
* 颜色都取饱和偏深的中明度色:线上是白底,太浅的(如淡黄)贴白底看不见。
*
* @param int $depth 评论深度(最小 2,即第 1 层嵌套)
* @return string 颜色值;'' 表示用 CSS 默认(主题浅蓝)
*/
function yang_comment_guide_color($depth)
{
if ($depth <= 2) {
return '';
}
if ($depth === 3) {
return '#0057b8'; // 深蓝:与浅蓝同色相,明度拉开
}
if ($depth === 4) {
return '#fb5235'; // 点赞按钮(.btn-thumbs)的背景/描边色
}
$pool = array('#7c4dff', '#00a77a', '#e91e63', '#f59e0b', '#5b8def', '#8bc34a');
return $pool[($depth - 5) % count($pool)];
}
function yang_comment_html($comment, $args = array(), $depth = 1, $is_ajax = false, $close_li = true) function yang_comment_html($comment, $args = array(), $depth = 1, $is_ajax = false, $close_li = true)
{ {
if (!($comment instanceof WP_Comment)) { if (!($comment instanceof WP_Comment)) {
@@ -151,9 +182,22 @@ function yang_comment_html($comment, $args = array(), $depth = 1, $is_ajax = fal
} }
$o = array(); $o = array();
/* 嵌套引导线按层配色(3.2.27):
线画在子容器 ol.yang-children 的 ::before 上,颜色从 --yq-guide-c 取。
给本 li 注入的值 = 「本条的直接回复那一层」该用的颜色:
第 1 层嵌套(直接回复)→ 不注入,CSS 回落到主题浅蓝(保持现状);
第 2 层 → 深蓝;第 3 层 → 点赞按钮背景色 #fb5235;
更深 → 扩展色板按层循环(确定性的"随机",同层同色、跨层异色)。
自定义属性沿 DOM 继承:内层 li 自己注入的值会覆盖继承值,
所以每个 ol 读到的都是离它最近的那个父 li 注入的颜色。 */
$guide_c = yang_comment_guide_color($depth + 1);
$style_attr = '';
if ($guide_c !== '') {
$style_attr = ' style="--yq-guide-c:' . esc_attr($guide_c) . ';"';
}
$o[] = '<li id="comment-' . $comment_id . '" class="' . esc_attr(implode(' ', $classes)) . '"' $o[] = '<li id="comment-' . $comment_id . '" class="' . esc_attr(implode(' ', $classes)) . '"'
. ' data-comment-id="' . $comment_id . '"' . ' data-comment-id="' . $comment_id . '"'
. ' data-depth="' . $depth . '">'; . ' data-depth="' . $depth . '"' . $style_attr . '>';
// ── 头像列 ── // ── 头像列 ──
$o[] = '<div class="yang-comment-avatar">'; $o[] = '<div class="yang-comment-avatar">';
+20 -2
View File
@@ -184,7 +184,14 @@ if (!class_exists('WP_Bootstrap_Navwalker')) {
$id = $id ? ' id="' . esc_attr($id) . '"' : ''; $id = $id ? ' id="' . esc_attr($id) . '"' : '';
if ($args->has_children) { if ($args->has_children) {
$output .= $indent . '<li' . $id . ' class="nav-item dropdown" ' . '>'; /* 3.2.27:深层(第二级起)的父项加 dropdown-submenu ——
Bootstrap 4 原生不支持嵌套下拉,主题用这个类 + CSS
(hover 时子菜单 left:100% 从右侧弹出)补上。 */
if (0 === $depth) {
$output .= $indent . '<li' . $id . ' class="nav-item dropdown" ' . '>';
} else {
$output .= $indent . '<li' . $id . ' class="nav-item dropdown dropdown-submenu" ' . '>';
}
} else { } else {
$output .= $indent . '<li' . $id . ' class="nav-item" ' . '>'; $output .= $indent . '<li' . $id . ' class="nav-item" ' . '>';
} }
@@ -205,13 +212,24 @@ if (!class_exists('WP_Bootstrap_Navwalker')) {
$atts['target'] = !empty($item->target) ? $item->target : ''; $atts['target'] = !empty($item->target) ? $item->target : '';
$atts['rel'] = !empty($item->xfn) ? $item->xfn : ''; $atts['rel'] = !empty($item->xfn) ? $item->xfn : '';
// If the item has children, add atts to the <a>. // If the item has children, add atts to the <a>.
if (isset($args->has_children) && $args->has_children && 0 === $depth && $args->depth > 1) { // 3.2.27:$args->depth > 1 → !== 1。原来 depth=0(不限层数)时
// 这个条件为假,顶层父项会失去 data-toggle,一级下拉都开不了。
// depth===1 表示"菜单只要一层",那才真的不该有下拉。
if (isset($args->has_children) && $args->has_children && 0 === $depth && $args->depth !== 1) {
$atts['href'] = '#'; $atts['href'] = '#';
$atts['data-toggle'] = 'dropdown'; $atts['data-toggle'] = 'dropdown';
$atts['aria-haspopup'] = 'true'; $atts['aria-haspopup'] = 'true';
$atts['aria-expanded'] = 'false'; $atts['aria-expanded'] = 'false';
$atts['class'] = 'dropdown-toggle nav-link'; $atts['class'] = 'dropdown-toggle nav-link';
$atts['id'] = 'menu-item-dropdown-' . $item->ID; $atts['id'] = 'menu-item-dropdown-' . $item->ID;
} elseif (isset($args->has_children) && $args->has_children && $depth > 0) {
/* 3.2.27:深层父项 —— 保留真实链接(点它进分类页),
只补 dropdown-toggle 让箭头出现;**不加 data-toggle**,
开合交给 CSS hover(.dropdown-submenu:hover > .dropdown-menu),
避免 Bootstrap 的 dropdown JS 用 Popper 把子菜单位置
重算到父项下方、和"从右侧弹出"打架。 */
$atts['href'] = !empty($item->url) ? $item->url : '#';
$atts['class'] = 'dropdown-item dropdown-toggle';
} else { } else {
$atts['href'] = !empty($item->url) ? $item->url : '#'; $atts['href'] = !empty($item->url) ? $item->url : '#';
// For items in dropdowns use .dropdown-item instead of .nav-link. // For items in dropdowns use .dropdown-item instead of .nav-link.
+1 -1
View File
@@ -1,7 +1,7 @@
/* /*
Theme Name: Kratos_Yang Theme Name: Kratos_Yang
Text Domain: kratos_Yang Text Domain: kratos_Yang
Version: 3.2.26 Version: 3.2.27
Requires PHP: 7.0 Requires PHP: 7.0
Description: 这是一个Kratos主题的分支版本,用来增加一些定制化功能。 Description: 这是一个Kratos主题的分支版本,用来增加一些定制化功能。
Tags: 博客, 双栏, 响应式, 自定义背景, 自定义颜色, 自定义图标, 自定义菜单, 特色图像, 收录优化, 邮件中心, 主题选项, 小工具, 文章置顶, 无障碍友好 Tags: 博客, 双栏, 响应式, 自定义背景, 自定义颜色, 自定义图标, 自定义菜单, 特色图像, 收录优化, 邮件中心, 主题选项, 小工具, 文章置顶, 无障碍友好