fix: complete HEL-806 audit evidence and shared visual corrections
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -8,18 +8,11 @@
|
||||
type Toast,
|
||||
} from '$lib/toast';
|
||||
import Icon from '$lib/components/ui/Icon.svelte';
|
||||
import type { IconName } from '$lib/components/ui/icons';
|
||||
import { t } from '$lib/i18n.svelte';
|
||||
|
||||
let items = $state<Toast[]>([]);
|
||||
|
||||
onMount(() => subscribeToasts((next) => (items = next)));
|
||||
|
||||
const kindIcon: Record<Toast['kind'], IconName> = {
|
||||
success: 'check',
|
||||
error: 'alert',
|
||||
info: 'info',
|
||||
};
|
||||
</script>
|
||||
|
||||
{#if items.length}
|
||||
@@ -27,6 +20,7 @@
|
||||
{#each items as toast (toast.id)}
|
||||
<div
|
||||
class="toast {toast.kind}"
|
||||
class:leaving={toast.leaving}
|
||||
role="status"
|
||||
onmouseenter={() => pauseToast(toast.id)}
|
||||
onmouseleave={() => resumeToast(toast.id)}
|
||||
@@ -35,15 +29,18 @@
|
||||
>
|
||||
<span class="badge" aria-hidden="true">
|
||||
<span class="dot"></span>
|
||||
<Icon name={kindIcon[toast.kind]} size={15} />
|
||||
</span>
|
||||
<span class="msg">{toast.message}</span>
|
||||
{#if toast.action}
|
||||
<button type="button" class="action" onclick={() => (toast.action?.run(), dismissToast(toast.id))}>
|
||||
{toast.action.label}
|
||||
</button>
|
||||
{/if}
|
||||
<button
|
||||
<span class="msg">{toast.message}</span>
|
||||
{#if toast.action}
|
||||
<button
|
||||
type="button"
|
||||
class="action"
|
||||
onclick={() => (toast.action?.run(), dismissToast(toast.id))}
|
||||
>
|
||||
{toast.action.label}
|
||||
</button>
|
||||
{/if}
|
||||
<button
|
||||
type="button"
|
||||
class="dismiss"
|
||||
aria-label={t('toast.dismiss')}
|
||||
@@ -57,35 +54,45 @@
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
/* §四.5 Toast:右下角堆叠,220ms 上移入场;成功绿点 / 失败红点。 */
|
||||
/* Shared host; visual values come from the approved sample tokens. */
|
||||
.toast-host {
|
||||
position: fixed;
|
||||
right: 24px;
|
||||
bottom: var(--toast-bottom, 24px);
|
||||
right: var(--toast-right);
|
||||
bottom: var(--toast-bottom);
|
||||
/* Above every overlay, incl. the 10000 lightbox, so feedback stays visible. */
|
||||
z-index: 10001;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
max-width: min(400px, calc(100vw - 32px));
|
||||
max-width: min(var(--toast-max-width), calc(100vw - 32px));
|
||||
pointer-events: none;
|
||||
}
|
||||
.toast {
|
||||
box-sizing: border-box;
|
||||
font-size: var(--toast-font);
|
||||
line-height: var(--toast-line-height);
|
||||
pointer-events: auto;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 10px;
|
||||
padding: 12px 14px;
|
||||
border-radius: var(--r-lg);
|
||||
background: var(--float-bg);
|
||||
box-shadow: var(--shadow-float);
|
||||
animation: toast-in var(--d-enter) var(--ease-out);
|
||||
min-width: var(--toast-min-width);
|
||||
max-width: var(--toast-max-width);
|
||||
padding: var(--toast-padding);
|
||||
border-radius: var(--toast-radius);
|
||||
background: var(--toast-bg);
|
||||
border: 1px solid var(--toast-border);
|
||||
box-shadow: var(--toast-shadow);
|
||||
animation: toast-in var(--toast-enter) var(--toast-ease);
|
||||
transition: opacity var(--toast-exit);
|
||||
}
|
||||
.toast.leaving {
|
||||
opacity: 0;
|
||||
}
|
||||
.badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin-top: 1px;
|
||||
margin-top: var(--toast-dot-top);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.dot {
|
||||
@@ -93,6 +100,7 @@
|
||||
height: 7px;
|
||||
border-radius: 50%;
|
||||
background: currentColor;
|
||||
box-shadow: 0 0 8px currentColor;
|
||||
}
|
||||
.toast.success .badge {
|
||||
color: var(--ok);
|
||||
@@ -105,10 +113,10 @@
|
||||
}
|
||||
.msg {
|
||||
flex: 1;
|
||||
font-size: var(--fs-body);
|
||||
line-height: 1.4;
|
||||
font-size: var(--toast-font);
|
||||
line-height: var(--toast-line-height);
|
||||
color: var(--text-primary);
|
||||
font-weight: 500;
|
||||
font-weight: 400;
|
||||
}
|
||||
/* §四.5: Toast 动作(如撤销)为金色文字 */
|
||||
.action {
|
||||
@@ -158,7 +166,8 @@
|
||||
@keyframes toast-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(8px);
|
||||
transform: translateY(var(--toast-enter-y))
|
||||
scale(var(--toast-enter-scale));
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
|
||||
@@ -232,8 +232,8 @@
|
||||
class:a-result-develop={arriving}
|
||||
use:finishAnimations
|
||||
onanimationend={() => (arriving = false)}
|
||||
style:width={fitted > 0 ? `${naturalWidth * fitted}px` : '100%'}
|
||||
style:height={fitted > 0 ? `${naturalHeight * fitted}px` : '100%'}
|
||||
style:width={fitted > 0 ? `${Math.floor(naturalWidth * fitted)}px` : '100%'}
|
||||
style:height={fitted > 0 ? `${Math.floor(naturalHeight * fitted)}px` : '100%'}
|
||||
>
|
||||
{#if st.tone === 'ok' && !fileGone}<span class="a-fix"
|
||||
>{t('jobst.done')}</span
|
||||
@@ -275,8 +275,8 @@
|
||||
class:a-result-develop={arriving}
|
||||
use:finishAnimations
|
||||
onanimationend={() => (arriving = false)}
|
||||
style:width={fitted > 0 ? `${naturalWidth * fitted}px` : '100%'}
|
||||
style:height={fitted > 0 ? `${naturalHeight * fitted}px` : '100%'}
|
||||
style:width={fitted > 0 ? `${Math.floor(naturalWidth * fitted)}px` : '100%'}
|
||||
style:height={fitted > 0 ? `${Math.floor(naturalHeight * fitted)}px` : '100%'}
|
||||
>
|
||||
{#if st.tone === 'ok' && !fileGone}<span class="a-fix"
|
||||
>{t('jobst.done')}</span
|
||||
@@ -579,7 +579,7 @@
|
||||
.artboard {
|
||||
position: relative;
|
||||
display: grid;
|
||||
grid-template-rows: 0 minmax(0, 1fr) 40px;
|
||||
grid-template-rows: 0 minmax(0, 1fr) var(--desk-action-height);
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
border: 0;
|
||||
@@ -688,6 +688,7 @@
|
||||
min-height: 0;
|
||||
}
|
||||
.print {
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
display: grid;
|
||||
grid-template: minmax(0, 1fr) / minmax(0, 1fr);
|
||||
|
||||
@@ -1221,8 +1221,8 @@
|
||||
>
|
||||
</div>{/if}
|
||||
<div class="studio-layout">
|
||||
<section class="viewer" aria-label="查看生成结果">
|
||||
<div class="preview-area" style:background="var(--desk-stage-background)">
|
||||
<section class="viewer" aria-label="查看生成结果" style:background="var(--desk-stage-background)">
|
||||
<div class="preview-area">
|
||||
{#if selectedJob}<Artboard
|
||||
main
|
||||
comparePath={allJobs.find(
|
||||
@@ -1607,7 +1607,7 @@
|
||||
.studio-layout {
|
||||
display: grid;
|
||||
grid-template-rows: minmax(0, 1fr) auto;
|
||||
gap: 12px;
|
||||
gap: var(--desk-layout-gap);
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
min-width: 0;
|
||||
@@ -1619,11 +1619,17 @@
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
.viewer {
|
||||
padding: var(--desk-stage-padding);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.studio-form {
|
||||
min-height: 0;
|
||||
min-width: 0;
|
||||
}
|
||||
.desk-welcome {
|
||||
box-sizing: border-box;
|
||||
padding-bottom: var(--desk-action-height);
|
||||
display: flex;
|
||||
height: 100%;
|
||||
align-items: center;
|
||||
@@ -1634,6 +1640,7 @@
|
||||
color: var(--tx-3);
|
||||
}
|
||||
.desk-emblem {
|
||||
box-sizing: border-box;
|
||||
width: var(--desk-empty-ring);
|
||||
height: var(--desk-empty-ring);
|
||||
border-radius: 50%;
|
||||
@@ -1693,12 +1700,6 @@
|
||||
.picker-empty {
|
||||
color: var(--text-3);
|
||||
}
|
||||
@media (max-height: 740px) {
|
||||
.studio-layout {
|
||||
grid-template-rows: minmax(0, 1fr) auto;
|
||||
gap: 10px;
|
||||
}
|
||||
}
|
||||
@media (max-width: 1100px) {
|
||||
.refract-studio {
|
||||
padding-left: 12px;
|
||||
|
||||
@@ -13,11 +13,13 @@ export type Toast = {
|
||||
/** Auto-dismiss delay in ms. 0 = sticky until dismissed. */
|
||||
duration: number;
|
||||
action?: ToastAction;
|
||||
leaving?: boolean;
|
||||
};
|
||||
|
||||
type Listener = (toasts: Toast[]) => void;
|
||||
|
||||
const DEFAULT_DURATION = 3200;
|
||||
const EXIT_DURATION = 300;
|
||||
|
||||
let seq = 0;
|
||||
let toasts: Toast[] = [];
|
||||
@@ -27,6 +29,7 @@ type TimerState = {
|
||||
remaining: number;
|
||||
startedAt: number;
|
||||
handle: ReturnType<typeof setTimeout>;
|
||||
paused?: boolean;
|
||||
};
|
||||
|
||||
const timers = new Map<number, TimerState>();
|
||||
@@ -56,7 +59,18 @@ function schedule(id: number, delay: number) {
|
||||
timers.set(id, {
|
||||
remaining: delay,
|
||||
startedAt: Date.now(),
|
||||
handle: setTimeout(() => dismissToast(id), delay),
|
||||
handle: setTimeout(() => expireToast(id), delay),
|
||||
});
|
||||
}
|
||||
|
||||
function expireToast(id: number) {
|
||||
timers.delete(id);
|
||||
toasts = toasts.map((t) => (t.id === id ? { ...t, leaving: true } : t));
|
||||
emit();
|
||||
timers.set(id, {
|
||||
remaining: 0,
|
||||
startedAt: Date.now(),
|
||||
handle: setTimeout(() => dismissToast(id), EXIT_DURATION),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -76,24 +90,27 @@ export function showToast(
|
||||
/** Pause auto-dismiss (e.g. while the pointer or focus is on the toast). */
|
||||
export function pauseToast(id: number) {
|
||||
const timer = timers.get(id);
|
||||
if (!timer) return;
|
||||
if (!timer || timer.paused || toasts.find((t) => t.id === id)?.leaving)
|
||||
return;
|
||||
clearTimeout(timer.handle);
|
||||
timer.remaining = Math.max(
|
||||
0,
|
||||
timer.remaining - (Date.now() - timer.startedAt),
|
||||
);
|
||||
timer.startedAt = Date.now();
|
||||
timer.paused = true;
|
||||
}
|
||||
|
||||
/** Resume auto-dismiss after a pause. */
|
||||
export function resumeToast(id: number) {
|
||||
const timer = timers.get(id);
|
||||
if (!timer) return;
|
||||
if (!timer?.paused) return;
|
||||
clearTimeout(timer.handle);
|
||||
const delay = Math.max(0, timer.remaining);
|
||||
timer.remaining = delay;
|
||||
timer.startedAt = Date.now();
|
||||
timer.handle = setTimeout(() => dismissToast(id), delay);
|
||||
timer.paused = false;
|
||||
timer.handle = setTimeout(() => expireToast(id), delay);
|
||||
}
|
||||
|
||||
export const toast = {
|
||||
|
||||
Reference in New Issue
Block a user