Files
aigc-home/calliope-web/src/lib/components/generate/ContextBar.svelte
T

76 lines
2.0 KiB
Svelte

<script lang="ts">
import { resolve } from '$app/paths';
import Icon from '$lib/components/ui/Icon.svelte';
import { t } from '$lib/i18n.svelte';
import { backHref, type DeskContext } from './context';
/**
* 上下文条 (spec-v2 §3.3): the desk was opened from a creation stage.
* Says where from. With a full source identity (HEL-684) results can
* be flowed back per take from the result card; otherwise the old
* note stands — results stay in the desk feed, nothing is written back.
*/
interface Props {
ctx: DeskContext;
projectTitle: string;
onDismiss: () => void;
}
let { ctx, projectTitle, onDismiss }: Props = $props();
const stageName = $derived(t(`workbench.stage.${ctx.stage}`));
const canFlowBack = $derived(!!ctx.sourceKind && !!ctx.sourceId);
</script>
<div class="context-bar" role="status">
<Icon name="link" size={14} />
<span class="from">
<b>{t('desk.ctxFrom', { project: projectTitle })}</b>{#if ctx.label}&nbsp;· {ctx.label}{/if}
</span>
<span class="note">
{canFlowBack ? t('desk.ctxBackfill', { stage: stageName }) : t('desk.ctxNoBackfill', { stage: stageName })}
</span>
<a class="a-btn ghost xs back" href={resolve(backHref(ctx))}>{t('desk.ctxBack', { stage: stageName })}</a>
<button type="button" class="a-btn ghost xs" aria-label={t('desk.ctxDismiss')} onclick={onDismiss}>
<Icon name="close" size={12} />
</button>
</div>
<style>
.context-bar {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: var(--sp-2) var(--sp-4);
margin: var(--sp-4) var(--sp-7) 0;
padding: var(--sp-3) var(--sp-5);
border-radius: var(--r-md);
background: var(--run-soft);
color: var(--text);
font-size: var(--fs-aux);
}
.context-bar > :global(svg) {
color: var(--run);
}
.from b {
color: var(--run);
font-weight: 600;
}
.note {
color: var(--text-2);
}
.back {
margin-left: auto;
}
@media (max-width: 1179px) {
.context-bar {
margin: var(--sp-4) var(--sp-6) 0;
}
}
@media (max-width: 760px) {
.context-bar {
margin: var(--sp-3) var(--sp-5) 0;
}
}
</style>