Skip to content

Commit c6060b3

Browse files
committed
fix(web): polish collapsible defaults and markdown hint affordance
Default-collapse mode, profile, and settings panels; add inline i-hint tooltips for markdown-only other-settings labels with bracket notes; normalize settings text hierarchy and tighten label-to-hint spacing for clearer visual priority.
1 parent 2a82740 commit c6060b3

3 files changed

Lines changed: 55 additions & 5 deletions

File tree

index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ <h1>排版器</h1>
2323
</div>
2424
</header>
2525

26-
<details id="mode-panel" class="panel collapse-panel" open>
26+
<details id="mode-panel" class="panel collapse-panel">
2727
<summary class="collapse-summary">
2828
<div class="collapse-head">
2929
<h2 class="panel-title">模式</h2>
@@ -47,7 +47,7 @@ <h2 class="panel-title">模式</h2>
4747
</div>
4848
</details>
4949

50-
<details id="profile-panel" class="panel collapse-panel" style="display: none" open>
50+
<details id="profile-panel" class="panel collapse-panel" style="display: none">
5151
<summary class="collapse-summary">
5252
<div class="collapse-head">
5353
<h2 class="panel-title">配置文件</h2>
@@ -66,7 +66,7 @@ <h2 class="panel-title">配置文件</h2>
6666
</details>
6767

6868
<section class="panel">
69-
<details open>
69+
<details>
7070
<summary>设置</summary>
7171
<div class="settings">
7272
<div>

src/web/app/ui.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,19 @@ function renderCks(defs: ReadonlyArray<SettingDef>, cfg: Option, onCheck: (key:
2727
onCheck(def.key, ck.checked);
2828
});
2929

30-
label.append(ck, document.createTextNode(def.label));
30+
const parsed = parseInlineHint(def.label);
31+
const useInlineHint = def.containerId === "other-settings" && def.mdOnly && parsed !== null;
32+
const text = useInlineHint ? parsed.main : def.label;
33+
34+
label.append(ck, document.createTextNode(text));
35+
if (useInlineHint) {
36+
const hint = document.createElement("span");
37+
hint.className = "inline-help";
38+
hint.textContent = "i";
39+
hint.title = parsed.hint;
40+
hint.setAttribute("aria-label", parsed.hint);
41+
label.appendChild(hint);
42+
}
3143
boxWrap.appendChild(label);
3244
}
3345
}
@@ -132,4 +144,19 @@ function mustGet<T extends HTMLElement>(id: string): T {
132144
return node as T;
133145
}
134146

147+
function parseInlineHint(label: string): { main: string; hint: string } | null {
148+
const m = label.match(/^(.*?)[(]([^)]+)[)]\s*$/);
149+
if (!m) {
150+
return null;
151+
}
152+
153+
const main = m[1].trimEnd();
154+
const hint = m[2].trim();
155+
if (!main || !hint) {
156+
return null;
157+
}
158+
159+
return { main, hint };
160+
}
161+
135162
export { renderCks, syncCfgUi, syncModeRadios, syncModeUi, syncBrkInput, syncProfileUi };

src/web/style.css

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,12 @@ details[open] > summary::before {
201201
grid-template-columns: 1fr;
202202
gap: 12px;
203203
margin-top: 12px;
204+
font-size: 14px;
204205
}
205206

206207
.settings h2 {
207208
font-size: 15px;
209+
font-weight: 600;
208210
margin: 0 0 8px;
209211
}
210212

@@ -217,10 +219,31 @@ details[open] > summary::before {
217219
.check-grid label {
218220
display: inline-flex;
219221
align-items: center;
220-
gap: 8px;
222+
gap: 4px;
221223
color: var(--text);
222224
}
223225

226+
.check-grid label .inline-help {
227+
display: inline-flex;
228+
align-items: center;
229+
justify-content: center;
230+
width: 16px;
231+
height: 16px;
232+
border: 1px solid var(--line);
233+
border-radius: 999px;
234+
background: #fff;
235+
color: var(--muted);
236+
font-size: 11px;
237+
font-weight: 700;
238+
line-height: 1;
239+
cursor: help;
240+
}
241+
242+
.check-grid label .inline-help:hover {
243+
border-color: #9ca9bd;
244+
color: #3f5068;
245+
}
246+
224247
.line-gap-row {
225248
display: flex;
226249
align-items: center;

0 commit comments

Comments
 (0)