fix(webui): align provider parameter row typography

This commit is contained in:
chengyongru authored and chengyongru committed 2026-10-19 21:30:37 +08:00
1 parent 125d9221d0
commit 1f8e49c70a
2 files changed
+33 -4

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
import { expect, test } from "@playwright/test";
for (const locale of ["en", "zh-CN"]) {
for (const width of [390, 1280]) {
test(`request parameter text aligns in ${locale} at ${width}px`, async ({ page }) => {
await page.setViewportSize({ width, height: 900 });
await page.addInitScript((language) => localStorage.setItem("nanobot.locale", language), locale);
await page.goto("/gallery.html#component=webui%2Fsrc%2Fcomponents%2Fsettings%2Fmodels%2FProviderParameterFields.tsx");
const preview = page.getByRole("region", { name: "Component preview" });
const rows = preview.getByRole("button");
await expect(rows).toHaveCount(3);
for (const row of await rows.all()) {
const text = await row.locator(":scope > span").evaluateAll((elements) => elements.map((element) => {
const style = getComputedStyle(element);
const bounds = element.getBoundingClientRect();
return { fontSize: style.fontSize, lineHeight: style.lineHeight, top: bounds.top, height: bounds.height };
}));
expect(text).toHaveLength(3);
for (const item of text.slice(1)) {
expect(item.fontSize).toBe(text[0].fontSize);
expect(item.lineHeight).toBe(text[0].lineHeight);
expect(item.top).toBeCloseTo(text[0].top, 2);
expect(item.height).toBeCloseTo(text[0].height, 2);
}
}
});
}
}
@@ -71,10 +71,10 @@ export function ProviderParameterFields({ fields, form, onChange, onSave, inheri
}
}}
trigger={
<button type="button" className="settings-hover flex min-h-12 w-full items-center gap-3 border-b border-border/60 px-3 py-3 text-left last:border-b-0">
<span className="min-w-0 flex-1 text-[13px] font-medium">{title}</span>
<span className="min-w-0 text-right text-[12px] text-muted-foreground">{parameterSummary(form[item.formKey], inherit, t)}</span>
<span className="shrink-0 text-[13px] text-muted-foreground">{t("settings.actions.edit")}</span>
<button type="button" className="settings-hover flex min-h-12 w-full items-center gap-3 border-b border-border/60 px-3 py-3 text-left text-[13px] leading-5 last:border-b-0">
<span className="min-w-0 flex-1 font-medium">{title}</span>
<span className="min-w-0 text-right text-muted-foreground">{parameterSummary(form[item.formKey], inherit, t)}</span>
<span className="shrink-0 text-muted-foreground">{t("settings.actions.edit")}</span>
</button>
}
/>