Skip to content

armgit / peach

Public Imported from GitHub
0

Peach: Local-first video metadata scraper and media manager.

fix(web): 共用组件在极端内容下不再撑破、裁字或误刷选区

longmeidao6725059ac3db
diff --git a/frontend/e2e/card-layout.test.ts b/frontend/e2e/card-layout.test.ts
index 99b984449..b886d4ae5 100644
--- a/frontend/e2e/card-layout.test.ts
+++ b/frontend/e2e/card-layout.test.ts
@@ -110,4 +110,19 @@ describe('混排作品的画面框',()=>{
}finally{await context.close()}
});
}
+ it('Shift 连选几张卡不把中间的文字刷成选区',async()=>{
+ const context=await browser.newContext({viewport:{width:1280,height:900}});
+ try{
+ const page=await context.newPage();
+ await openHome(page,'big');
+ const titles=page.locator('#grid [data-media-grid] > [data-media-card] [data-media-title]');
+ await titles.nth(0).click({modifiers:['Control']});
+ assert.equal(await titles.nth(0).evaluate(node=>getComputedStyle(node.closest('[data-media-card]')!).userSelect),'none');
+ /* 多选态的 `user-select: none` 之外,Shift 按下那一下本身也不起选区:撤掉前者再点,两道各验一次。 */
+ await page.addStyleTag({content:'.peach-react [data-media-card]{user-select:text !important}'});
+ await titles.nth(3).click({modifiers:['Shift']});
+ await page.locator('#grid [data-media-card][data-selected]').nth(3).waitFor();
+ assert.equal(await page.evaluate(()=>String(getSelection())),'');
+ }finally{await context.close()}
+ });
});
diff --git a/frontend/e2e/design-manage.test.ts b/frontend/e2e/design-manage.test.ts
index 28575f63e..32fb54aea 100644
--- a/frontend/e2e/design-manage.test.ts
+++ b/frontend/e2e/design-manage.test.ts
@@ -344,6 +344,35 @@ describe('设计决定:数据管理、索引页与资料页头', () => {
} finally { await opened.close(); }
});
+ it('输入框失败态只把框线换成 danger 色:填充照静止态,原因用说明文字的灰', { timeout: 60_000 }, async () => {
+ const opened = await openPlaylistsPage(browser);
+ const { page } = opened;
+ try {
+ const form = page.locator('[data-playlist-create]');
+ const resting = await form.locator('[data-input-size] > div[data-rac]').evaluate((node) => getComputedStyle(node).backgroundColor);
+ await form.getByRole('button', { name: '新建' }).click();
+ await form.locator('[data-input-size] > div[data-rac][data-invalid]').waitFor();
+ const looks = await form.locator('[data-input-size]').evaluate((root) => {
+ const probe = (token: string) => {
+ const swatch = document.createElement('i');
+ swatch.style.color = `var(${token})`;
+ root.append(swatch);
+ const color = getComputedStyle(swatch).color;
+ swatch.remove();
+ return color;
+ };
+ const group = getComputedStyle(root.querySelector(':scope > div[data-rac]')!);
+ return {
+ fill: group.backgroundColor, outline: group.outlineColor, width: group.outlineWidth,
+ reason: getComputedStyle(root.querySelector(':scope > [slot="errorMessage"]')!).color,
+ danger: probe('--color-border-error-default'), secondary: probe('--color-text-secondary'),
+ };
+ });
+ assert.deepEqual([looks.fill, looks.outline, looks.width, looks.reason],
+ [resting, looks.danger, '1px', looks.secondary]);
+ } finally { await opened.close(); }
+ });
+
it('短菜单共享悬停面,弹窗关闭释放焦点与遮罩', { timeout: 60_000 }, async () => {
const opened = await openPlaylistsPage(browser);
const { page } = opened;
diff --git a/frontend/src/react/activity/cloud-download-dialog.tsx b/frontend/src/react/activity/cloud-download-dialog.tsx
index 9a84b8979..fc935ef98 100644
--- a/frontend/src/react/activity/cloud-download-dialog.tsx
+++ b/frontend/src/react/activity/cloud-download-dialog.tsx
@@ -68,7 +68,7 @@ function Body({ prefill, close, receipt, provider }: {
return (
<div className="flex min-h-0 flex-col">
{header}
- <div className="flex flex-col gap-4 p-5">
+ <div className="flex min-h-0 flex-col gap-4 overflow-y-auto p-5">
{query.error ? <Note tone="error">{errorMessage(query.error)}</Note> : null}
{data && !data.available ? <Note tone="neutral">云下载只在账本写入端可用。</Note> : null}
{data?.available && !configured.length
diff --git a/frontend/src/react/base.css b/frontend/src/react/base.css
index 0d1d47c64..ad2a05843 100644
--- a/frontend/src/react/base.css
+++ b/frontend/src/react/base.css
@@ -171,12 +171,40 @@
* 悬停与聚焦仍归组件自己那圈 ring,所以这条只认没有这两个状态的那一刻;用 outline 而不是
* ring,是因为 ring 的 box-shadow 归组件,改写它就会连带盖掉那两个状态。
* 外壳是 TextField 下那个 React Aria Group(`data-rac`);它没有 aria-label 时 role 落成
- * presentation,所以不能按 role 认。 */
-.peach-react [data-input-size] > div[data-rac]:not([data-hovered]):not([data-focus-within]) {
+ * presentation,所以不能按 role 认。失败态的框线归下一条,这里让开。 */
+.peach-react [data-input-size] > div[data-rac]:not([data-hovered]):not([data-focus-within]):not([data-invalid]) {
outline: 1px solid var(--color-border-button-default);
outline-offset: -1px;
}
+/* 输入框的失败态:填充照静止态,只把框线换成 danger 色,聚焦时那圈 ring 也是 danger 色。
+ * BoardUI 默认整块铺粉底、下面的原因写红字;Peach 的失败态统一按 Vercel Fieldset 只让框线变色,
+ * 原因照常写在框下,用说明文字的颜色。上游副本不改(`boardui/ORIGIN.md`),在这里统一压过去。 */
+.peach-react [data-input-size] > div[data-rac][data-invalid] {
+ background-color: var(--color-background-tertiary-default);
+ color: var(--color-foreground-icon-tertiary);
+ outline: 1px solid var(--color-border-error-default);
+ outline-offset: -1px;
+}
+
+.peach-react [data-input-size] > div[data-rac][data-invalid][data-focus-within] {
+ --tw-ring-color: var(--color-border-error-default);
+}
+
+.peach-react [data-input-size] > [slot="errorMessage"] {
+ color: var(--color-text-secondary);
+}
+
+.peach-react [data-input-size] input[aria-invalid="true"]::placeholder {
+ color: var(--color-text-tertiary);
+}
+
+/* 框下的说明与原因常是服务端原话:长路径和无空格的串就地折行,不撑宽卡片。 */
+.peach-react [data-input-size] > [slot="errorMessage"],
+.peach-react [data-input-size] > [slot="description"] {
+ overflow-wrap: anywhere;
+}
+
/* 横着滚的那几条不画滚动条:拖得动、也能滚轮横滚,一条系统灰柱子横在图表或分段控件
* 底下,只会让那一块看着比实际矮一截。遗留层的 `.tier`、`.tagbar`、`.srow` 就是这个
* 做法(`web/css/01-base.css`),这里只是把同一条搬进岛内。
diff --git a/frontend/src/react/batch-dock/batch-dock-island.tsx b/frontend/src/react/batch-dock/batch-dock-island.tsx
index b5ec461bb..ed0055ae4 100644
--- a/frontend/src/react/batch-dock/batch-dock-island.tsx
+++ b/frontend/src/react/batch-dock/batch-dock-island.tsx
@@ -50,7 +50,7 @@ export function BatchDockSurface() {
function BatchDock({ host: at, props: view }: { host: BatchDockHost; props: BatchDockProps }) {
return (
<div className="peach-react" data-batch-scope="" data-context={view.context}>
- <SelectionDock label="所选项目操作" visible={view.count > 0} count={`已选 ${view.count} 项`}>
+ <SelectionDock label="所选项目操作" visible={view.count > 0} count={`已选 ${view.count.toLocaleString()} 项`}>
{batchActions(view.context, view.junkDismissed).map((action) => (
<button key={`${action.group}:${action.operation}`} type="button" data-batch-group={action.group}
data-batch-action={action.operation} data-danger={action.danger ? '' : undefined}
diff --git a/frontend/src/react/components/board-tabs.tsx b/frontend/src/react/components/board-tabs.tsx
index d06a262c1..fd114e0f7 100644
--- a/frontend/src/react/components/board-tabs.tsx
+++ b/frontend/src/react/components/board-tabs.tsx
@@ -54,6 +54,10 @@ export function BoardTabs<V extends string>(
if (!selected || !selected.offsetWidth) return;
host.style.setProperty('--tab-x', `${selected.offsetLeft}px`);
host.style.setProperty('--tab-width', `${selected.offsetWidth}px`);
+ /* 窄屏这一排横着滚:选中那一枚落在可见区外时把这一排挪到它露全,只动这一排,不动页面。 */
+ const left = selected.offsetLeft, right = left + selected.offsetWidth;
+ if (left < host.scrollLeft) host.scrollLeft = left;
+ else if (right > host.scrollLeft + host.clientWidth) host.scrollLeft = right - host.clientWidth;
};
measure();
const frame = requestAnimationFrame(() => indicator.current?.setAttribute('data-ready', ''));
diff --git a/frontend/src/react/components/loading-dots.tsx b/frontend/src/react/components/loading-dots.tsx
index d801166c8..8a7d5ccf9 100644
--- a/frontend/src/react/components/loading-dots.tsx
+++ b/frontend/src/react/components/loading-dots.tsx
@@ -8,7 +8,7 @@
export function LoadingDots({ label, inline = false }: { label: string; inline?: boolean }) {
const dots = (
- <span aria-hidden className="inline-flex items-center gap-1">
+ <span aria-hidden className="inline-flex shrink-0 items-center gap-1">
<i className="dot-wave-0 size-1 rounded-full bg-current" />
<i className="dot-wave-1 size-1 rounded-full bg-current" />
<i className="dot-wave-2 size-1 rounded-full bg-current" />
@@ -16,9 +16,9 @@ export function LoadingDots({ label, inline = false }: { label: string; inline?:
);
if (inline) return <span role="status" className="inline-flex items-center gap-2">{dots}{label}</span>;
return (
- <p role="status" className="flex items-center gap-2 text-caption-1-regular text-text-secondary">
+ <p role="status" className="flex min-w-0 items-center gap-2 text-caption-1-regular text-text-secondary">
{dots}
- {label}
+ <span className="min-w-0 wrap-anywhere">{label}</span>
</p>
);
}
diff --git a/frontend/src/react/components/media-card.css b/frontend/src/react/components/media-card.css
index 39fe860fa..d6b0f0d4f 100644
--- a/frontend/src/react/components/media-card.css
+++ b/frontend/src/react/components/media-card.css
@@ -56,7 +56,7 @@ body[data-density="dense"] .peach-react [data-media-card][data-variant="short"]
box-shadow: 0 0 0 8px var(--hover);
}
.peach-react [data-media-card]:not([data-variant="resource"], [data-variant="junk"]):hover [data-media-pic] { filter: saturate(.9) brightness(.94); }
-.peach-react [data-select-mode] [data-media-card] { cursor: default; }
+.peach-react [data-select-mode] [data-media-card] { cursor: default; user-select: none; }
.peach-react [data-select-mode] :is([data-media-open], [data-media-preview], [data-media-later], [data-media-seek]),
.peach-react [data-select-mode] :is([data-media-later], [data-media-seek]) button { pointer-events: none !important; }
@media (hover: hover) and (pointer: fine) {
@@ -489,6 +489,8 @@ body[data-surface="/trash"] .peach-react [data-media-card] [data-media-title] {
transition: transform var(--lift-motion, var(--board-motion));
}
.peach-react [data-media-avatars] > * + * { margin-left: -22px; }
+/* 没有图的一枚只有居中的首字母,叠到 -22px 时字被左边那枚盖掉大半:这一枚只让出 8px,字整个露出来。 */
+.peach-react [data-media-avatars] > * + :not(:has(img)) { margin-left: -8px; }
.peach-react [data-media-avatars] > :nth-child(1) { z-index: 5; }
.peach-react [data-media-avatars] > :nth-child(2) { z-index: 4; }
.peach-react [data-media-avatars] > :nth-child(3) { z-index: 3; }
diff --git a/frontend/src/react/components/media-card.tsx b/frontend/src/react/components/media-card.tsx
index 9949d1292..f5f05bf21 100644
--- a/frontend/src/react/components/media-card.tsx
+++ b/frontend/src/react/components/media-card.tsx
@@ -28,6 +28,7 @@ import { spinnerHtml } from '@peach/legacy/ui';
import type { MediaCardActions, MediaCardHelpers, MediaCardLayout, MediaItem } from '../catalog-grid/types';
import { ArtSlot } from './art-slot';
+import { suppressShiftTextSelection } from './row-click';
/** 竖屏一律同一个比例,不按每条视频的实际宽高:竖屏条与竖屏网格才高低一致。 */
const PORTRAIT_RATIO = 9 / 16;
@@ -234,7 +235,7 @@ function VideoCard({ item, variant, layout, selected, selectMode, seekSeconds, h
<article ref={attach} data-media-card="" data-id={item.id} data-variant={variant}
data-part-seed={parts ? parts.seed_id : undefined} data-stacked={stacked ? '' : undefined}
data-pending-delete={item.disposal === 'trash' ? '' : undefined} data-selected={selected ? '' : undefined}
- onClick={click}>
+ onClick={click} onMouseDown={suppressShiftTextSelection}>
<button type="button" data-media-open="" data-open=""
aria-label={`打开 ${shownName}${parts ? '分卷' : editions ? '版本' : '详情'}`} />
{stacked ? <div data-media-stack="">{pic}</div> : pic}
@@ -297,7 +298,7 @@ function ResourceCard({ item, selected, selectMode, helpers, actions, onOpen }:
return (
<article ref={card} data-media-card="" data-id={item.id} data-variant="resource" data-medium={item.medium || 'other'}
data-pending-delete={item.disposal === 'trash' ? '' : undefined} data-selected={selected ? '' : undefined}
- onClick={click}>
+ onClick={click} onMouseDown={suppressShiftTextSelection}>
<div data-media-pic="" style={{ '--card-ratio': String(16 / 9) } as CSSProperties}>
<span data-media-glyph=""><Icon name={glyph} /><b>{label}</b></span>
{image
diff --git a/frontend/src/react/components/mix-card.tsx b/frontend/src/react/components/mix-card.tsx
index 25679adaf..588031ae2 100644
--- a/frontend/src/react/components/mix-card.tsx
+++ b/frontend/src/react/components/mix-card.tsx
@@ -148,7 +148,7 @@ export function MixCard({
<span data-mix-badge=""
className="absolute right-2.25 bottom-2.25 z-6 flex min-h-7 items-center gap-1.5 rounded-2lg px-2.25 py-1 text-caption-1-semibold text-text-white">
<PLAY aria-hidden className="size-3.75" />
- {badge ?? `${count} 个视频`}
+ {badge ?? `${count.toLocaleString()} 个视频`}
</span>
</div>
</div>
diff --git a/frontend/src/react/components/modal-frame.tsx b/frontend/src/react/components/modal-frame.tsx
index bef3fcb00..38f38096a 100644
--- a/frontend/src/react/components/modal-frame.tsx
+++ b/frontend/src/react/components/modal-frame.tsx
@@ -32,7 +32,9 @@ export function ModalFrame({ isOpen, onOpenChange, width, label, children }: {
data-modal-motion="" data-motion-instant={isFocusVisible || undefined}
className="fixed inset-0 z-dialog flex items-center justify-center bg-scrim p-4">
<Modal data-modal-surface="" className={`flex max-h-full w-full ${WIDTH[width]} flex-col overflow-hidden rounded-2-5xl border border-separator-border bg-background-full shadow-dropdown`}>
- <Dialog aria-label={label} className="flex min-h-0 flex-col outline-none">{children}</Dialog>
+ {/* 调用方自己的正文滚动区收得下时这一层不滚;矮视口里连页头加按钮都放不下,就整块滚,
+ 关闭键总够得着。 */}
+ <Dialog aria-label={label} className="flex min-h-0 flex-col overflow-y-auto overscroll-contain outline-none">{children}</Dialog>
</Modal>
</ModalOverlay>
);
diff --git a/frontend/src/react/components/progress.tsx b/frontend/src/react/components/progress.tsx
index d9c579db0..c1ddc5acd 100644
--- a/frontend/src/react/components/progress.tsx
+++ b/frontend/src/react/components/progress.tsx
@@ -13,9 +13,11 @@ const STOP_WIDTH = 0.4;
export function Progress({ label, value, max = 100, stops = [] }: { label: string; value: number; max?: number; stops?: number[] }) {
const total = max > 0 ? max : 1;
- const share = (at: number) => (Math.min(Math.max(at, 0), total) / total) * SCALE;
+ const clamp = (at: number) => Math.min(Math.max(Number.isFinite(at) ? at : 0, 0), total);
+ const share = (at: number) => (clamp(at) / total) * SCALE;
+ /* 读屏值同画面一样夹在 [0, max]:超额完成读成「150 / 100」会被当成算错。 */
return (
- <svg role="progressbar" aria-label={label} aria-valuemin={0} aria-valuemax={max} aria-valuenow={value}
+ <svg role="progressbar" aria-label={label} aria-valuemin={0} aria-valuemax={total} aria-valuenow={clamp(value)}
viewBox={`0 0 ${SCALE} 1`} preserveAspectRatio="none" className="h-1.5 w-full overflow-hidden rounded-full">
<rect width={SCALE} height={1} className="fill-background-tertiary-default" />
<rect width={share(value)} height={1} className="fill-border-focus-ring" />
diff --git a/frontend/src/react/components/row-click.ts b/frontend/src/react/components/row-click.ts
index a041479ed..afc49c795 100644
--- a/frontend/src/react/components/row-click.ts
+++ b/frontend/src/react/components/row-click.ts
@@ -3,7 +3,7 @@
* 勾选框本来就在行首,但它只有 16px,一整行的其余部分点了没反应的话,选几条就要瞄几次。
* 判「空白」看的是点到的元素往上找有没有可交互的祖先,找到行为止:行外面的祖先不算,
* 否则整张表包在一个 `label` 里时每一下都成了「点在控件上」。 */
-import type { SyntheticEvent } from 'react';
+import type { MouseEvent, SyntheticEvent } from 'react';
const INTERACTIVE = [
'a', 'button', 'input', 'select', 'textarea', 'label',
@@ -17,3 +17,9 @@ export function clickedBlank(event: SyntheticEvent | Event, row: Element): boole
const control = target.closest(INTERACTIVE);
return !control || !row.contains(control) || control === row;
}
+
+/** 卡片网格的 `onMouseDown`:按着 Shift 点卡是范围多选,这一下不让浏览器把两次点击之间的
+ * 文字一并刷成选区。只拦按下,`click` 照常冒上来交给选择逻辑。 */
+export function suppressShiftTextSelection(event: MouseEvent): void {
+ if (event.shiftKey) event.preventDefault();
+}
diff --git a/frontend/src/react/components/segmented.tsx b/frontend/src/react/components/segmented.tsx
index 59b0d6e1f..882c3d6de 100644
--- a/frontend/src/react/components/segmented.tsx
+++ b/frontend/src/react/components/segmented.tsx
@@ -18,7 +18,8 @@ export const SEGMENTED_TRACK = 'inline-flex w-max max-w-full items-center gap-0.
/* 深色下选中面用 `background-primary-hover`:深色的 `background-primary-default` 与轨道
* (`background-tertiary-default`)是同一档 neutral-800,画上去看不见。 */
-export const SEGMENT = 'flex min-h-7 flex-none cursor-pointer items-center gap-1.5 rounded-md px-2.5 py-1'
+/* 手机宽度每格左右各收 2px:四个中文页签在 320 宽的轨道里刚好排下,不被轨道裁掉末字。 */
+export const SEGMENT = 'flex min-h-7 flex-none cursor-pointer items-center gap-1.5 rounded-md px-2.5 py-1 max-sm:px-2'
+ ' text-body-medium whitespace-nowrap text-text-secondary outline-none transition-colors'
+ ' hover:text-text-primary focus-visible:ring-2 focus-visible:ring-border-focus-ring'
+ ' data-focus-visible:ring-2 data-focus-visible:ring-border-focus-ring'
@@ -26,7 +27,7 @@ export const SEGMENT = 'flex min-h-7 flex-none cursor-pointer items-center gap-1
+ ' dark:data-selected:bg-background-primary-hover';
/** `aria-selected` 而不是 `data-selected` 的宿主(自己写的 `<button role="tab">`)用这一串。 */
-export const SEGMENT_ARIA = 'flex min-h-7 flex-none cursor-pointer items-center gap-1.5 rounded-md px-2.5 py-1'
+export const SEGMENT_ARIA = 'flex min-h-7 flex-none cursor-pointer items-center gap-1.5 rounded-md px-2.5 py-1 max-sm:px-2'
+ ' text-body-medium whitespace-nowrap text-text-secondary outline-none transition-colors'
+ ' hover:text-text-primary focus-visible:ring-2 focus-visible:ring-border-focus-ring'
+ ' aria-selected:bg-background-primary-default aria-selected:text-text-primary aria-selected:shadow-card'
diff --git a/frontend/src/react/components/stat-card.tsx b/frontend/src/react/components/stat-card.tsx
index 11f570fd3..25aac9573 100644
--- a/frontend/src/react/components/stat-card.tsx
+++ b/frontend/src/react/components/stat-card.tsx
@@ -82,7 +82,8 @@ export function StatCard(
) : null}
<span className="min-w-0 truncate">{label}</span>
</span>
- <b className="px-4 pt-3 pb-4 text-title-1-medium tabular-nums text-text-primary max-sm:px-3 max-sm:pb-3">
+ {/* 窄屏两张一排时卡只有一百四十来像素,读数降一档字号;九位数再放不下就折行,不截掉开头几位。 */}
+ <b className="px-4 pt-3 pb-4 text-title-1-medium tabular-nums text-text-primary wrap-anywhere max-sm:px-3 max-sm:pb-3 max-sm:text-title-3-medium">
{figure}
</b>
{/* 脚注压在卡底:卡片被邻居撑高时空出来的那块留给读数上方,脚注不跟着飘。 */}
diff --git a/frontend/src/react/components/task-progress.tsx b/frontend/src/react/components/task-progress.tsx
index 543ff53df..2d466a696 100644
--- a/frontend/src/react/components/task-progress.tsx
+++ b/frontend/src/react/components/task-progress.tsx
@@ -12,7 +12,7 @@ export function TaskProgress({ label, value = 0, total, embedded = false }: {
})}>
{total && total > 0 ? <>
<Progress label={label} value={value} max={total} />
- <p className="text-caption-1-regular text-text-secondary">{label}</p>
+ <p className="text-caption-1-regular text-text-secondary wrap-anywhere">{label}</p>
</> : <LoadingDots label={label} />}
</div>
);
diff --git a/frontend/src/react/follow-feed/follow-card.tsx b/frontend/src/react/follow-feed/follow-card.tsx
index c04edf842..d99157fbf 100644
--- a/frontend/src/react/follow-feed/follow-card.tsx
+++ b/frontend/src/react/follow-feed/follow-card.tsx
@@ -15,6 +15,7 @@ import { memo, useCallback, useRef, useState, type MouseEvent } from 'react';
import { esc, fmtDur, icon } from '@peach/legacy/core';
import { tagLabel } from '@peach/legacy/tags';
+import { suppressShiftTextSelection } from '../components/row-click';
import { MIX_FLIP_FACES, useStackFlip } from '../components/use-stack-flip';
import {
followStack, itemForMedia, videoItems, type FollowContext, type FollowFeedActions,
@@ -135,7 +136,7 @@ function FollowCardView(props: FollowCardProps) {
return (
<article ref={attach} data-media-card="" data-follow-item={item.id} data-status={item.status}
data-follow-image={imageView ? '' : undefined} data-collection={stack.isMix ? '' : undefined}
- data-selected={selected ? '' : undefined} onClick={click}
+ data-selected={selected ? '' : undefined} onClick={click} onMouseDown={suppressShiftTextSelection}
onMouseEnter={flip.onPointerEnter} onMouseLeave={flip.onPointerLeave}>
<div data-follow-visual="" data-mix-stack={stack.isMix ? '' : undefined}>
<button type="button" data-follow-open="" aria-label={`打开 ${item.title} 详情`} />
diff --git a/frontend/src/react/junk-queue/junk-card.tsx b/frontend/src/react/junk-queue/junk-card.tsx
index 87e3cee27..1dc99a5c1 100644
--- a/frontend/src/react/junk-queue/junk-card.tsx
+++ b/frontend/src/react/junk-queue/junk-card.tsx
@@ -16,6 +16,7 @@ import {
junkDecision, junkKindMeta,
type JunkItem, type JunkOperation, type JunkQueueActions, type JunkQueueHelpers, type JunkView,
} from './junk-queue';
+import { suppressShiftTextSelection } from '../components/row-click';
/** 雪碧图里的一枚字形,写法同遗留层 `icon()`:尺寸与描边由样式表按位置给。 */
function Icon({ name }: { name: string }) {
@@ -89,7 +90,7 @@ function JunkCardView({ item, view, selected, selectMode, helpers, actions }: Ju
return (
<article ref={card} data-media-card="" data-variant="junk" data-junk-card="" data-id={item.id} data-junk-kind={kind}
- data-selected={selected ? '' : undefined} onClick={clickCard}>
+ data-selected={selected ? '' : undefined} onClick={clickCard} onMouseDown={suppressShiftTextSelection}>
<div data-media-pic="" style={{ '--card-ratio': String(16 / 9) } as CSSProperties}>
<span data-media-glyph=""><Icon name={glyph} /><b>{label}</b></span>
{preview
diff --git a/frontend/src/react/pages/auth-card.tsx b/frontend/src/react/pages/auth-card.tsx
index 58bbf075a..64fce839e 100644
--- a/frontend/src/react/pages/auth-card.tsx
+++ b/frontend/src/react/pages/auth-card.tsx
@@ -20,7 +20,7 @@ export function AuthCard({ title, lede, busy = false, children }: {
<header className="flex flex-col gap-1">
<img src="/peach-logo.png" alt="" width={40} height={40} className="mb-4 size-10" />
<h1 id="auth-card-title" className="text-title-2-medium text-text-primary">{title}</h1>
- {lede ? <p className="text-body-2-regular text-text-secondary">{lede}</p> : null}
+ {lede ? <p className="whitespace-pre-line text-body-2-regular text-text-secondary wrap-anywhere">{lede}</p> : null}
</header>
{children}
</section>
diff --git a/frontend/src/react/styles.css b/frontend/src/react/styles.css
index 6fa2031c7..d2685bf26 100644
--- a/frontend/src/react/styles.css
+++ b/frontend/src/react/styles.css
@@ -476,6 +476,8 @@
transition: transform var(--lift-motion, var(--board-motion));
}
.peach-react [data-mix-avatars] > * + * { margin-left: -22px; }
+/* 没有图的一枚只有居中的首字母,叠到 -22px 时字被左边那枚盖掉大半:这一枚只让出 8px,字整个露出来。 */
+.peach-react [data-mix-avatars] > * + :not(:has(img)) { margin-left: -8px; }
.peach-react [data-mix-avatars] > :nth-child(1) { z-index: 5; }
.peach-react [data-mix-avatars] > :nth-child(2) { z-index: 4; }
.peach-react [data-mix-avatars] > :nth-child(3) { z-index: 3; }
diff --git a/frontend/test/react/batch-dock.test.tsx b/frontend/test/react/batch-dock.test.tsx
index c171f3fba..f0544d216 100644
--- a/frontend/test/react/batch-dock.test.tsx
+++ b/frontend/test/react/batch-dock.test.tsx
@@ -140,6 +140,12 @@ describe('浮条', () => {
expect(root.querySelector('[data-batch-scope]')!.getAttribute('data-context')).toBe('junk');
});
+ it('上千项的计数带千分位', async () => {
+ const { root, render } = await setup();
+ await render({ count: 12345, context: 'catalog', junkDismissed: false });
+ expect(root.querySelector('[data-selection-dock] [role="status"]')!.textContent).toBe('已选 12,345 项');
+ });
+
it('危险键挂 data-danger 读全站那份红,每颗键带自己的 sprite 字形', async () => {
const { root, render } = await setup();
await render({ count: 2, context: 'catalog', junkDismissed: false });
diff --git a/frontend/test/react/playlists.test.tsx b/frontend/test/react/playlists.test.tsx
index cfabbcbe2..1fc3361f5 100644
--- a/frontend/test/react/playlists.test.tsx
+++ b/frontend/test/react/playlists.test.tsx
@@ -109,6 +109,11 @@ describe('首屏', () => {
});
describe('卡片', () => {
+ it('上千条的徽标带千分位', async () => {
+ const host = await open([row(1, { item_count: 98765 })]);
+ expect(card(host, 1).querySelector('[data-mix-badge]')?.textContent).toBe('98,765 个视频');
+ });
+
it('来源、条数与封面按行画;点封面从续播点接着播', async () => {
const given = props();
const host = await open([row(1, { source_kind: 'mix', current_asset_id: 12, item_count: 3 }), row(2)], given);
diff --git a/frontend/test/react/progress.test.tsx b/frontend/test/react/progress.test.tsx
new file mode 100644
index 000000000..e34984134
--- /dev/null
+++ b/frontend/test/react/progress.test.tsx
@@ -0,0 +1,28 @@
+/* 进度条的读屏值与填充宽度都夹在 [0, max]:超额、负数和坏值不画出界,也不读成算错的数。 */
+import { expect, it } from 'vitest';
+
+import { Progress } from '../../src/react/components/progress';
+import { mountRoot } from './render';
+
+const fillOf = (bar: Element) => Number(bar.querySelectorAll('rect')[1]?.getAttribute('width'));
+
+it('超额完成按满格读,负数与坏值按零读', async () => {
+ const { host } = await mountRoot(
+ <>
+ <Progress label="超额" value={150} max={100} />
+ <Progress label="负数" value={-5} max={100} />
+ <Progress label="坏值" value={Number.NaN} max={100} />
+ <Progress label="正常" value={25} max={50} />
+ </>,
+ );
+ const bars = [...host.querySelectorAll('[role="progressbar"]')];
+ expect(bars.map((bar) => bar.getAttribute('aria-valuenow'))).toEqual(['100', '0', '0', '25']);
+ expect(bars.map(fillOf)).toEqual([100, 0, 0, 50]);
+});
+
+it('总量为零时不除零,满格读作 1', async () => {
+ const { host } = await mountRoot(<Progress label="空" value={3} max={0} />);
+ const bar = host.querySelector('[role="progressbar"]')!;
+ expect(bar.getAttribute('aria-valuemax')).toBe('1');
+ expect(bar.getAttribute('aria-valuenow')).toBe('1');
+});
diff --git a/web/dist/peach-pages.js b/web/dist/peach-pages.js
index fcd9ba104..bb97cb923 100644
--- a/web/dist/peach-pages.js
+++ b/web/dist/peach-pages.js
@@ -11026,7 +11026,7 @@ function xt({ title: e, lede: t, busy: n = !1, children: r }) {
children: e
}),
t ? /* @__PURE__ */ (0, B.jsx)("p", {
- className: "text-body-2-regular text-text-secondary",
+ className: "whitespace-pre-line text-body-2-regular text-text-secondary wrap-anywhere",
children: t
}) : null
]
@@ -20248,7 +20248,7 @@ function Xm(e) {
ref: t
});
}
-var Zm = "inline-flex w-max max-w-full items-center gap-0.5 overflow-x-auto overscroll-x-contain rounded-2lg bg-background-tertiary-default p-1", Qm = "flex min-h-7 flex-none cursor-pointer items-center gap-1.5 rounded-md px-2.5 py-1 text-body-medium whitespace-nowrap text-text-secondary outline-none transition-colors hover:text-text-primary focus-visible:ring-2 focus-visible:ring-border-focus-ring data-focus-visible:ring-2 data-focus-visible:ring-border-focus-ring data-selected:bg-background-primary-default data-selected:text-text-primary data-selected:shadow-card dark:data-selected:bg-background-primary-hover";
+var Zm = "inline-flex w-max max-w-full items-center gap-0.5 overflow-x-auto overscroll-x-contain rounded-2lg bg-background-tertiary-default p-1", Qm = "flex min-h-7 flex-none cursor-pointer items-center gap-1.5 rounded-md px-2.5 py-1 max-sm:px-2 text-body-medium whitespace-nowrap text-text-secondary outline-none transition-colors hover:text-text-primary focus-visible:ring-2 focus-visible:ring-border-focus-ring data-focus-visible:ring-2 data-focus-visible:ring-border-focus-ring data-selected:bg-background-primary-default data-selected:text-text-primary data-selected:shadow-card dark:data-selected:bg-background-primary-hover";
//#endregion
//#region src/react/settings/busy-props.ts
function $m(e) {