From 69c47c3c434b603576be281a38f4e69bf1a9227f Mon Sep 17 00:00:00 2001 From: laoyang Date: Thu, 5 Nov 2026 20:23:16 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BD=91=E9=A1=B5=E7=AB=AF=E4=B8=8B=E6=8B=89?= =?UTF-8?q?=E6=A1=86=E6=94=B9=E6=88=90=E8=87=AA=E7=BB=98=E6=B5=AE=E5=B1=82?= =?UTF-8?q?=EF=BC=88=E7=85=A7=20FeedLite=20=E7=9A=84=E5=81=9A=E6=B3=95?= =?UTF-8?q?=EF=BC=89(#85)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 用户 2026-11-05:「网页版的下拉框也太丑了。你参考一下那个反馈系统里面的 下拉框到底是怎么做的?按它的做法做,它也有主题颜色,我们这个也有主题颜色, 就按照一样的做法去做。」 看了 FeedLite(~/code/FeedLite)的实现,关键结论: **原生 ` 收起时能改样式, + 但**展开的选项列表由浏览器/系统绘制,CSS 完全改不动**(只能改 option 底色), + 各平台样式还不统一。所以想"好看"只有一条路:自己画。 + + **但绝不重写 HTML**:原生 select 保留在 DOM 里参与表单提交, + JS 在它旁边生成一个按钮 + 浮层。这样: + · 全站所有 select 自动获得新样式,不用逐个改模板; + · `onchange="this.form.submit()"` 这类内联逻辑照样工作(我们派发原生 change); + · 无 JS 时原生 select 仍可用(只是朴素),不会白屏。 + + ⚠️ 浮层用 `position: fixed` 挂在 body 上 —— 面板/浮层里有很多 + `overflow: hidden`,放在 select 旁边会被裁掉(FeedLite 踩过)。 + ⚠️ 三档浅色由 layout.php 里 PHP 算好(--brand-tint-1/2/3), + 不用 `color-mix()`:那个配 var() 在 Chrome 里会解析成透明。 + ══════════════════════════════════════════════════════════════════════ */ + +/* 原生 select:视觉隐藏但仍参与提交与事件(**不能 display:none**,那样不参与提交) */ +.sel-native { + position: absolute !important; + width: 1px !important; height: 1px !important; + margin: 0 !important; padding: 0 !important; + border: 0 !important; opacity: 0 !important; + pointer-events: none !important; + clip: rect(0 0 0 0) !important; +} + +/* 外层:inline-flex,跟输入框一样参与行内布局 */ +.sel { position: relative; display: inline-flex; vertical-align: middle; max-width: 100%; min-width: 0; } + +/* 触发按钮:外观与普通输入框完全一致(同高同圆角同边框) */ +.sel-btn { + display: inline-flex; align-items: center; gap: 10px; + height: 40px; padding: 0 12px; + border: 1px solid var(--line); border-radius: var(--radius-s); + background: #fff; color: var(--ink); + font-family: inherit; font-size: 14px; line-height: 1; + cursor: pointer; text-align: left; + box-shadow: 0 1px 2px rgba(16,24,40,.04); + transition: border-color .12s, box-shadow .12s, background .12s; + max-width: 100%; min-width: 0; +} +.sel-btn:hover { border-color: var(--brand-2); } +.sel-btn:focus-visible { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint-1, rgba(168,74,40,.10)); } +.sel-txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +/* 未选值(「未分类」「不循环」这类占位)→ 次要色,弱化存在感 */ +.sel-btn.is-placeholder .sel-txt { color: var(--muted); } + +/* 自绘箭头:默认灰;**打开时转 180° 并变主题色** */ +.sel-caret { + width: 11px; height: 7px; flex: none; + background: currentColor; opacity: .55; + -webkit-mask: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='7' viewBox='0 0 11 7'%3E%3Cpath d='M1 1.2 5.5 5.8 10 1.2' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat; + mask: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='7' viewBox='0 0 11 7'%3E%3Cpath d='M1 1.2 5.5 5.8 10 1.2' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat; + transition: transform .16s, background .12s, opacity .12s; +} +.sel-btn.is-open .sel-caret { transform: rotate(180deg); background: var(--brand); opacity: 1; } +/* 打开态整体染主题色:浅主题底 + 主题边框 */ +.sel-btn.is-open { + border-color: var(--brand); + background: var(--brand-tint-1, #FAF2EE); + color: var(--brand); + box-shadow: 0 0 0 3px var(--brand-tint-1, rgba(168,74,40,.10)); +} +.sel-btn.is-open .sel-txt { color: var(--brand); font-weight: 600; } + +/* 浮层:fixed,不被任何 overflow 容器裁切 */ +.sel-panel { + position: fixed; z-index: 9998; + max-height: min(320px, calc(100vh - 32px)); + overflow-y: auto; overscroll-behavior: contain; + padding: 5px; + background: #fff; + border: 1px solid var(--line); + border-radius: 11px; + box-shadow: 0 10px 30px rgba(16,24,40,.16), 0 2px 6px rgba(16,24,40,.06); + animation: selIn .12s ease-out; +} +@keyframes selIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } } +.sel-panel.is-up { animation-name: selInUp; } +@keyframes selInUp { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } } + +/* 列表项 */ +.sel-item { + display: flex; align-items: center; gap: 8px; width: 100%; + padding: 0 10px; height: 34px; + border: 0; border-radius: 7px; + background: transparent; color: var(--ink); + font-family: inherit; font-size: 14px; line-height: 1; + cursor: pointer; text-align: left; white-space: nowrap; + transition: background .1s, color .1s; + -webkit-appearance: none; appearance: none; +} +.sel-item-txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; } + +/* hover / 键盘高亮:主题色最浅一档 */ +.sel-item:hover, .sel-item.is-active { + background: var(--brand-tint-1, #FAF2EE); + color: var(--brand); +} +/* 选中项:深一档 + 主题色文字 + 右侧对勾,一眼看出当前选的是哪个 */ +.sel-item.on { + background: var(--brand-tint-2, #F3E3DC); + color: var(--brand); + font-weight: 600; +} +.sel-item.on:hover, .sel-item.on.is-active { background: var(--brand-tint-3, #EDD5CB); color: var(--brand); } +.sel-item-ck { + width: 13px; height: 10px; flex: none; + background: currentColor; + -webkit-mask: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='13' height='10' viewBox='0 0 13 10'%3E%3Cpath d='M1.5 5.2 4.8 8.4 11.5 1.6' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat; + mask: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='13' height='10' viewBox='0 0 13 10'%3E%3Cpath d='M1.5 5.2 4.8 8.4 11.5 1.6' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat; +} + +/* 面板里的字段行:下拉要占满整行(与输入框同宽) */ +.tk-attr-row > .sel { width: 100%; } +.tk-attr-row > .sel > .sel-btn { width: 100%; } + +/* 窄屏:至少占满可用宽度,别挤成一小坨 */ +@media (max-width: 640px) { + .sel { flex: 1 1 auto; min-width: 0; } + .sel-btn { width: 100%; } +} diff --git a/assets/js/app.js b/assets/js/app.js index a842557..df19e02 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -2848,4 +2848,236 @@ window.fbHomeTaskDrop = function (row, wasStatus) { bindNodeActs(); } window.fbBindNodeActs = bindNodeActs; + +/* ══════════════════════════════════════════════════════════════════════ + #85 自绘下拉框(把原生 select 的展开列表换成自绘浮层) + ══════════════════════════════════════════════════════════════════════ + 🔴 用户 2026-11-05:「网页版的下拉框也太丑了。你参考一下那个反馈系统 + (FeedLite)里面的下拉框到底是怎么做的?按它的做法做。」 + + 为什么必须自绘:原生 `