style(search): 区分大小写改行内 [Aa] 开关(搜索按钮前),悬浮提示改自绘主题气泡(Tooltip 组件),撤掉行下胶囊

This commit is contained in:
Muse
2026-11-14 16:40:51 +08:00
parent c2f69f9303
commit bd6fcf3d45
3 changed files with 48 additions and 27 deletions

View File

@@ -1,5 +1,6 @@
import { memo, useCallback, useEffect, useRef, useState } from 'react'
import { useDismiss } from '../hooks/useDismiss'
import Tooltip from './Tooltip'
import { listDir, workspaceSearch, type DirEntry, type WorkspaceSearchFile } from '../services/platform'
import { isPathInside, parentDirOf, pathsEqual } from '../utils/text'
import type { OutlineItem } from '../utils/text'
@@ -306,28 +307,30 @@ function WorkspaceSearch({ root, tauriMode, onOpen }: {
onChange={(e) => setQuery(e.target.value)}
onKeyDown={(e) => { if (e.key === 'Enter') void run() }}
/>
<button
className="ws-search-go"
disabled={searching || !query.trim()}
onClick={() => void run()}
title="搜索(Enter)"
aria-label="搜索"
>
{searching ? (
<span className="ws-spin" aria-hidden="true" />
) : (
<svg width="15" height="15" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7" fill="none" stroke="currentColor" strokeWidth="1.8" /><path d="M20.5 20.5 16.7 16.7" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" /></svg>
)}
</button>
</div>
<div className="ws-search-opts">
<button
className={`chip-toggle${caseSensitive ? ' on' : ''}`}
aria-pressed={caseSensitive}
onClick={() => setCaseSensitive((v) => !v)}
>
区分大小写
</button>
<Tooltip label="区分大小写">
<button
className={`ws-search-aa${caseSensitive ? ' on' : ''}`}
aria-pressed={caseSensitive}
aria-label="区分大小写"
onClick={() => setCaseSensitive((v) => !v)}
>
Aa
</button>
</Tooltip>
<Tooltip label="搜索(Enter)">
<button
className="ws-search-go"
disabled={searching || !query.trim()}
onClick={() => void run()}
aria-label="搜索"
>
{searching ? (
<span className="ws-spin" aria-hidden="true" />
) : (
<svg width="15" height="15" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7" fill="none" stroke="currentColor" strokeWidth="1.8" /><path d="M20.5 20.5 16.7 16.7" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" /></svg>
)}
</button>
</Tooltip>
</div>
{error && <div className="sidebar-empty">{error}</div>}
{results && (

View File

@@ -0,0 +1,15 @@
import type { ReactNode } from 'react'
/**
* 自绘悬浮提示:跟随当前主题(界面变量),不用浏览器原生 title 气泡。
* 纯 CSS 悬停/聚焦显示,带一点延迟避免划过时闪烁;气泡本身不拦截鼠标。
* 子元素应自带 aria-label,气泡只作视觉呈现(aria-hidden)。
*/
export default function Tooltip({ label, children }: { label: string; children: ReactNode }) {
return (
<span className="tooltip-wrap">
{children}
<span className="tooltip-bubble" aria-hidden="true">{label}</span>
</span>
)
}

View File

@@ -337,15 +337,18 @@ kbd { background: var(--code-bg); border: 1px solid var(--border); border-radius
.filetree-head.drop-target { background: var(--accent-weak); box-shadow: inset 0 0 0 1px var(--accent); border-radius: 6px; }
.ws-search { display: flex; flex-direction: column; gap: 8px; padding: 10px; min-height: 0; }
.ws-search-box { display: flex; gap: 6px; align-items: stretch; }
.ws-search-go { flex: none; width: 32px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); background: var(--bg); color: var(--text-dim); border-radius: 6px; cursor: pointer; padding: 0; }
.ws-search-go { flex: none; width: 32px; height: 100%; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); background: var(--bg); color: var(--text-dim); border-radius: 6px; cursor: pointer; padding: 0; }
.ws-search-go:hover:not(:disabled) { color: var(--text); border-color: var(--accent); background: var(--hover); }
.ws-search-go:disabled { opacity: 0.45; cursor: default; }
.ws-spin { width: 13px; height: 13px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: ws-spin 0.7s linear infinite; }
@keyframes ws-spin { to { transform: rotate(360deg); } }
.ws-search-opts { display: flex; gap: 6px; }
.chip-toggle { font-size: 12px; font-family: inherit; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border); background: transparent; color: var(--text-dim); cursor: pointer; }
.chip-toggle:hover { color: var(--text); background: var(--hover); }
.chip-toggle.on { background: var(--accent-weak); color: var(--text); border-color: transparent; }
.ws-search-box .ws-search-aa { flex: none; display: inline-flex; align-items: center; justify-content: center; height: 100%; padding: 0 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text-dim); border-radius: 6px; cursor: pointer; font-family: inherit; font-size: 12.5px; font-weight: 600; letter-spacing: 0.2px; }
.ws-search-box .ws-search-aa:hover { color: var(--text); border-color: var(--accent); background: var(--hover); }
.ws-search-box .ws-search-aa.on { background: var(--accent-weak); color: var(--text); border-color: transparent; }
/* 自绘悬浮提示(Tooltip 组件):跟随主题变量,悬停/聚焦延迟浮现 */
.tooltip-wrap { position: relative; display: inline-flex; align-items: stretch; }
.tooltip-wrap .tooltip-bubble { position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%) translateY(2px); background: var(--bg-editor); color: var(--text); border: 1px solid var(--border); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18); font-size: 12px; font-weight: 400; line-height: 1.4; padding: 4px 8px; border-radius: 6px; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity 0.15s ease, transform 0.15s ease; z-index: 80; }
.tooltip-wrap:hover .tooltip-bubble, .tooltip-wrap:focus-within .tooltip-bubble { opacity: 1; transform: translateX(-50%) translateY(0); transition-delay: 0.35s; }
/* 自绘下拉(Dropdown 组件):按钮对齐 .input,展开层沿用应用菜单语言 */
.dropdown { position: relative; }
.dropdown-button { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 6px; padding: 5px 9px; font-size: 13px; font-family: inherit; cursor: pointer; text-align: left; }