portal-worktab-capsule-v2-demo.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1" />
  6. <title>门户 WorkTab · 胶囊居中 + 未激活态 Demo</title>
  7. <style>
  8. :root {
  9. --primary: #10b981;
  10. --primary-dark: #059669;
  11. --primary-bg: #ecfdf5;
  12. --header: #1ca851;
  13. --text: #0f172a;
  14. --muted: #64748b;
  15. --border: #e2e8f0;
  16. --surface: #ffffff;
  17. --strip: #f1f5f9;
  18. }
  19. * { box-sizing: border-box; }
  20. body {
  21. margin: 0;
  22. font-family: Inter, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  23. color: var(--text);
  24. background: #f8fafc;
  25. line-height: 1.5;
  26. }
  27. .page { padding: 20px 24px 56px; max-width: 1120px; margin: 0 auto; }
  28. h1 { font-size: 22px; margin: 0 0 6px; }
  29. .lead { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
  30. .ok, .note {
  31. border-radius: 10px;
  32. padding: 10px 14px;
  33. font-size: 13px;
  34. margin-bottom: 12px;
  35. }
  36. .ok {
  37. background: var(--primary-bg);
  38. border: 1px solid #a7f3d0;
  39. color: #065f46;
  40. }
  41. .note {
  42. background: #fffbeb;
  43. border: 1px solid #fde68a;
  44. color: #92400e;
  45. }
  46. .compare {
  47. display: grid;
  48. gap: 20px;
  49. }
  50. @media (min-width: 900px) {
  51. .compare { grid-template-columns: 1fr 1fr; }
  52. }
  53. .card-label {
  54. display: flex;
  55. justify-content: space-between;
  56. align-items: baseline;
  57. gap: 8px;
  58. margin: 0 0 8px;
  59. }
  60. .card-label h2 { margin: 0; font-size: 15px; }
  61. .card-label span { font-size: 12px; color: var(--muted); }
  62. .frame {
  63. border: 1px solid var(--border);
  64. border-radius: 12px;
  65. overflow: hidden;
  66. background: #f8fafc;
  67. box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  68. }
  69. .portal-header {
  70. display: flex;
  71. align-items: center;
  72. gap: 10px;
  73. height: 56px;
  74. padding: 0 16px;
  75. background: var(--header);
  76. color: #fff;
  77. }
  78. .brand {
  79. display: flex;
  80. align-items: center;
  81. gap: 8px;
  82. font-weight: 600;
  83. font-size: 15px;
  84. }
  85. .brand-mark {
  86. width: 26px;
  87. height: 26px;
  88. border-radius: 7px;
  89. background: rgba(255,255,255,0.2);
  90. display: grid;
  91. place-items: center;
  92. font-size: 11px;
  93. font-weight: 700;
  94. }
  95. .spacer { flex: 1; }
  96. .user-chip {
  97. width: 30px;
  98. height: 30px;
  99. border-radius: 999px;
  100. background: rgba(255,255,255,0.22);
  101. display: grid;
  102. place-items: center;
  103. font-size: 12px;
  104. font-weight: 600;
  105. }
  106. .workspace { padding: 14px 16px 16px; }
  107. .fake-panel {
  108. background: #fff;
  109. border: 1px solid var(--border);
  110. border-radius: 10px;
  111. padding: 14px 16px;
  112. min-height: 96px;
  113. }
  114. .fake-panel h3 { margin: 0 0 4px; font-size: 15px; }
  115. .fake-panel p { margin: 0; color: var(--muted); font-size: 13px; }
  116. /* ========== 旧 B:未激活几乎看不见 ========== */
  117. .old-strip {
  118. display: flex;
  119. align-items: center;
  120. gap: 8px;
  121. min-height: 44px;
  122. padding: 6px 12px;
  123. background: #f8fafc;
  124. border-bottom: 1px solid var(--border);
  125. }
  126. .old-tabs {
  127. display: flex;
  128. flex: 1;
  129. align-items: center;
  130. gap: 6px;
  131. min-width: 0;
  132. overflow: hidden;
  133. }
  134. .old-chip {
  135. appearance: none;
  136. border: 1px solid transparent;
  137. background: transparent;
  138. color: var(--muted);
  139. font-size: 13px;
  140. font-weight: 500;
  141. padding: 6px 10px 6px 12px;
  142. border-radius: 8px;
  143. cursor: pointer;
  144. max-width: 150px;
  145. display: inline-flex;
  146. align-items: center;
  147. gap: 6px;
  148. white-space: nowrap;
  149. }
  150. .old-chip.is-active {
  151. color: var(--primary-dark);
  152. background: #fff;
  153. border-color: #a7f3d0;
  154. font-weight: 600;
  155. box-shadow: 0 1px 2px rgba(16, 185, 129, 0.08);
  156. }
  157. .old-chip.is-home.is-active { background: var(--primary-bg); }
  158. .old-x {
  159. appearance: none;
  160. border: 0;
  161. background: transparent;
  162. width: 18px;
  163. height: 18px;
  164. border-radius: 999px;
  165. color: var(--muted);
  166. cursor: pointer;
  167. opacity: 0;
  168. font-size: 14px;
  169. padding: 0;
  170. }
  171. .old-chip:hover .old-x,
  172. .old-chip.is-active .old-x { opacity: 0.75; }
  173. .old-more {
  174. width: 30px;
  175. height: 30px;
  176. border: 1px solid var(--border);
  177. border-radius: 8px;
  178. background: #fff;
  179. color: var(--muted);
  180. cursor: pointer;
  181. flex-shrink: 0;
  182. }
  183. /* ========== 新 B:上下居中 + 未激活也有样式 ========== */
  184. .new-strip {
  185. display: flex;
  186. align-items: center; /* 整行垂直居中 */
  187. gap: 8px;
  188. height: 48px; /* 固定条高,胶囊在此高度内居中 */
  189. padding: 0 14px;
  190. background: var(--strip);
  191. border-bottom: 1px solid var(--border);
  192. }
  193. .new-tabs {
  194. display: flex;
  195. flex: 1;
  196. align-items: center; /* Tab 与更多按钮同一中线 */
  197. gap: 6px;
  198. min-width: 0;
  199. min-height: 100%;
  200. overflow: hidden;
  201. }
  202. .new-chip {
  203. appearance: none;
  204. display: inline-flex;
  205. align-items: center; /* 文案/关闭钮在胶囊内垂直居中 */
  206. gap: 6px;
  207. height: 32px; /* 固定胶囊高度,相对 48px 条带上下各 8px */
  208. max-width: 160px;
  209. padding: 0 8px 0 12px;
  210. margin: 0;
  211. font-size: 13px;
  212. font-weight: 500;
  213. line-height: 1;
  214. color: #475569;
  215. white-space: nowrap;
  216. cursor: pointer;
  217. background: #fff;
  218. border: 1px solid #dbe3ec;
  219. border-radius: 8px;
  220. box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
  221. transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  222. }
  223. .new-chip__label {
  224. overflow: hidden;
  225. text-overflow: ellipsis;
  226. white-space: nowrap;
  227. }
  228. .new-chip:hover {
  229. color: var(--text);
  230. border-color: #cbd5e1;
  231. background: #fff;
  232. box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  233. }
  234. .new-chip.is-active {
  235. color: var(--primary-dark);
  236. font-weight: 600;
  237. background: #fff;
  238. border-color: #6ee7b7;
  239. box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.12), 0 1px 2px rgba(16, 185, 129, 0.1);
  240. }
  241. .new-chip.is-home.is-active {
  242. background: var(--primary-bg);
  243. border-color: #6ee7b7;
  244. }
  245. .new-x {
  246. appearance: none;
  247. display: inline-flex;
  248. align-items: center;
  249. justify-content: center;
  250. flex-shrink: 0;
  251. width: 18px;
  252. height: 18px;
  253. margin: 0;
  254. padding: 0;
  255. border: 0;
  256. border-radius: 999px;
  257. color: #94a3b8;
  258. background: transparent;
  259. cursor: pointer;
  260. font-size: 14px;
  261. line-height: 1;
  262. opacity: 0;
  263. transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
  264. }
  265. .new-chip:hover .new-x,
  266. .new-chip.is-active .new-x { opacity: 0.85; }
  267. .new-x:hover {
  268. opacity: 1 !important;
  269. color: var(--text);
  270. background: #f1f5f9;
  271. }
  272. .new-more {
  273. display: inline-flex;
  274. align-items: center;
  275. justify-content: center;
  276. flex-shrink: 0;
  277. width: 32px;
  278. height: 32px;
  279. margin: 0;
  280. border: 1px solid #dbe3ec;
  281. border-radius: 8px;
  282. background: #fff;
  283. color: var(--muted);
  284. cursor: pointer;
  285. box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
  286. }
  287. .new-more:hover {
  288. color: var(--primary-dark);
  289. border-color: #a7f3d0;
  290. background: var(--primary-bg);
  291. }
  292. .legend {
  293. margin-top: 18px;
  294. padding: 12px 14px;
  295. background: #fff;
  296. border: 1px solid var(--border);
  297. border-radius: 10px;
  298. font-size: 13px;
  299. color: var(--muted);
  300. }
  301. .legend strong { color: var(--text); }
  302. .legend code {
  303. font-size: 12px;
  304. background: #f1f5f9;
  305. padding: 1px 6px;
  306. border-radius: 4px;
  307. }
  308. </style>
  309. </head>
  310. <body>
  311. <div class="page">
  312. <h1>WorkTab 胶囊 · 上下居中 + 未激活态</h1>
  313. <p class="lead">
  314. 左侧为上一版方案 B(未激活几乎透明);右侧为调整稿:条高固定、胶囊垂直居中,未激活也有白底描边。
  315. </p>
  316. <div class="ok">
  317. <strong>已按右侧 B′ 落地</strong>
  318. <code>web-admin/src/components/core/layouts/art-work-tab/index.vue</code>:
  319. 条带 48px 居中、胶囊 32px、未激活白底描边、激活薄荷绿边。
  320. </div>
  321. <div class="note">
  322. 可点击右侧 Demo 的 Tab 切换激活态;关闭钮为示意。
  323. </div>
  324. <div class="compare">
  325. <!-- 旧 -->
  326. <section>
  327. <div class="card-label">
  328. <h2>上一版 B</h2>
  329. <span>未激活透明,辨识弱</span>
  330. </div>
  331. <div class="frame">
  332. <header class="portal-header">
  333. <div class="brand"><div class="brand-mark">SX</div><span>山峡化工一体化门户</span></div>
  334. <div class="spacer"></div>
  335. <div class="user-chip">管</div>
  336. </header>
  337. <div class="old-strip">
  338. <div class="old-tabs" id="oldTabs"></div>
  339. <button type="button" class="old-more">▾</button>
  340. </div>
  341. <div class="workspace">
  342. <div class="fake-panel">
  343. <h3>对比用</h3>
  344. <p>未激活 Tab 几乎融进灰底,边界不清。</p>
  345. </div>
  346. </div>
  347. </div>
  348. </section>
  349. <!-- 新 -->
  350. <section>
  351. <div class="card-label">
  352. <h2>调整稿 B′(建议落地)</h2>
  353. <span>居中 + 未激活有边</span>
  354. </div>
  355. <div class="frame">
  356. <header class="portal-header">
  357. <div class="brand"><div class="brand-mark">SX</div><span>山峡化工一体化门户</span></div>
  358. <div class="spacer"></div>
  359. <div class="user-chip">管</div>
  360. </header>
  361. <div class="new-strip">
  362. <div class="new-tabs" id="newTabs"></div>
  363. <button type="button" class="new-more" title="更多">▾</button>
  364. </div>
  365. <div class="workspace">
  366. <div class="fake-panel">
  367. <h3 id="pageTitle">首页</h3>
  368. <p id="pageDesc">胶囊在 48px 条带内上下居中;未激活为白底描边胶囊。</p>
  369. </div>
  370. </div>
  371. </div>
  372. </section>
  373. </div>
  374. <div class="legend">
  375. <strong>尺寸关系</strong>:条带 48px → 胶囊 32px → 上下各约 8px 空隙,保证垂直居中。
  376. 未激活:白底 <code>#fff</code> / 边 <code>#dbe3ec</code> / 字 <code>#475569</code>;
  377. 激活:字 <code>#059669</code>、边 <code>#6ee7b7</code>;首页激活额外浅绿底。
  378. </div>
  379. </div>
  380. <script>
  381. var TABS = [
  382. { id: 'home', title: '首页', fixed: true },
  383. { id: 'customer', title: '客户管理', fixed: false },
  384. { id: 'contract', title: '合同管理', fixed: false },
  385. { id: 'product', title: '产品管理', fixed: false },
  386. { id: 'plan', title: '运输计划', fixed: false }
  387. ]
  388. var activeId = 'customer'
  389. function render(containerId, prefix, interactive) {
  390. var el = document.getElementById(containerId)
  391. el.innerHTML = ''
  392. TABS.forEach(function (tab) {
  393. var chip = document.createElement('button')
  394. chip.type = 'button'
  395. chip.className =
  396. prefix + '-chip' +
  397. (tab.id === activeId ? ' is-active' : '') +
  398. (tab.fixed ? ' is-home' : '')
  399. var label = document.createElement('span')
  400. if (prefix === 'new') label.className = 'new-chip__label'
  401. label.textContent = tab.title
  402. chip.appendChild(label)
  403. if (!tab.fixed) {
  404. var x = document.createElement('button')
  405. x.type = 'button'
  406. x.className = prefix + '-x'
  407. x.textContent = '×'
  408. x.setAttribute('aria-label', '关闭')
  409. if (interactive) {
  410. x.addEventListener('click', function (e) {
  411. e.stopPropagation()
  412. if (activeId === tab.id) activeId = 'home'
  413. TABS = TABS.filter(function (t) { return t.id !== tab.id })
  414. paint()
  415. })
  416. }
  417. chip.appendChild(x)
  418. }
  419. if (interactive) {
  420. chip.addEventListener('click', function () {
  421. activeId = tab.id
  422. paint()
  423. })
  424. }
  425. el.appendChild(chip)
  426. })
  427. }
  428. function paint() {
  429. render('oldTabs', 'old', false)
  430. render('newTabs', 'new', true)
  431. var tab = TABS.find(function (t) { return t.id === activeId }) || TABS[0]
  432. document.getElementById('pageTitle').textContent = tab.title
  433. document.getElementById('pageDesc').textContent = tab.fixed
  434. ? '首页启动器占位。注意未激活胶囊也有白底描边。'
  435. : '业务页占位。胶囊相对灰条垂直居中。'
  436. }
  437. paint()
  438. </script>
  439. </body>
  440. </html>