Files
aigc-home/calliope-web/src/lib/components/video/ClipSourceModal.svelte
T
施工员andmultica-agent bc24370233 feat(style): 全站无彩灰阶收尾——清理 legacy 别名与硬编码色漂移 (HEL-685 S6)
- app.css 删除 8 个无引用 legacy 别名,新增 --id-1..5 身份灰阶实色阶
- 画布去紫罗兰二级 palette(tokens.css 删除,改用全站 token)
- 画布/镜头台/智能体/omni/视频组件硬编码色全部归位 token
- agentPalette 彩色身份色改为显影灰阶 --id 阶;修复 3 处相纸白底白字不可读
- WorkflowLibrary 试运行抽屉焦点还原(异步禁用触发键丢焦)修复
- e2e: fpages/import 色值断言对齐现行 token;新增 hel685 走查脚本
  (1440/1024/390 截图 + 控制台错误 + 减动效 + 键盘焦点 + 对比度探针);
  pagination 空库自举;fpages 增加逐页控制台错误检查

Co-authored-by: multica-agent <github@multica.ai>
2026-10-11 17:26:12 +08:00

304 lines
6.4 KiB
Svelte

<script lang="ts">
/**
* Video source picker for continue scenes — Auto (previous clip),
* Upload file, or any other scene's clip in the project timeline.
* Replaces the cramped native select.
*/
import { assetUrl } from '$lib/api';
import Button from '$lib/components/ui/Button.svelte';
import Icon from '$lib/components/ui/Icon.svelte';
import Modal from '$lib/components/ui/Modal.svelte';
import { t } from '$lib/i18n.svelte';
interface ClipSourceOption {
/** Source key — a clip/scene path, or the 'auto' / 'upload' sentinels. */
id: string;
label: string;
/** Clip path — renders a video thumbnail when present. */
path?: string;
}
interface Props {
open?: boolean;
/** Current source: 'auto' | 'upload' | a scene id from options. */
value?: string;
options?: ClipSourceOption[];
/** Picking Auto or a project clip. */
onselect: (source: string) => void;
/** Picking Upload file — caller opens the file dialog and applies the result. */
onupload: () => void;
}
let { open = $bindable(false), value = 'auto', options = [], onselect, onupload }: Props =
$props();
function hideBroken(e: Event) {
const el = e.currentTarget as HTMLElement | null;
if (el) el.style.display = 'none';
}
function pick(source: string) {
onselect(source);
open = false;
}
function pickUpload() {
onupload();
open = false;
}
</script>
<Modal bind:open title={t('clipSource.title')} size="xl">
<div class="sources">
<button
type="button"
class="source-card"
class:selected={value === 'auto'}
onclick={() => pick('auto')}
>
<span class="source-icon"><Icon name="sparkle" size={18} /></span>
<span class="source-text">
<span class="source-name">{t('clipSource.autoName')}</span>
<span class="source-desc">{t('clipSource.autoDesc')}</span>
</span>
{#if value === 'auto'}
<span class="check"><Icon name="check" size={12} /></span>
{/if}
</button>
<button
type="button"
class="source-card"
class:selected={value === 'upload'}
onclick={pickUpload}
>
<span class="source-icon"><Icon name="upload" size={18} /></span>
<span class="source-text">
<span class="source-name">{t('clipSource.uploadName')}</span>
<span class="source-desc">{t('clipSource.uploadDesc')}</span>
</span>
{#if value === 'upload'}
<span class="check"><Icon name="check" size={12} /></span>
{/if}
</button>
</div>
{#if options.length > 0}
<p class="section-label">{t('clipSource.projectClips')} <span class="count">{options.length}</span></p>
<div class="grid-wrap">
<div class="grid">
{#each options as opt (opt.id)}
{@const isSelected = value === opt.id}
<button
type="button"
class="clip-card"
class:selected={isSelected}
onclick={() => pick(opt.id)}
title={opt.label}
>
<div class="thumb">
{#if opt.path}
<!-- svelte-ignore a11y_media_has_caption -->
<video
src={assetUrl(opt.path)}
muted
playsinline
preload="metadata"
onerror={hideBroken}
></video>
{:else}
<Icon name="film" size={22} />
{/if}
{#if isSelected}
<span class="check"><Icon name="check" size={12} /></span>
{/if}
</div>
<span class="name">{opt.label}</span>
</button>
{/each}
</div>
</div>
{:else}
<p class="empty">{t('clipSource.noClips')}</p>
{/if}
{#snippet footer()}
<Button variant="ghost" onclick={() => (open = false)}>{t('common.cancelButton')}</Button>
{/snippet}
</Modal>
<style>
.sources {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 12px;
}
.source-card {
position: relative;
display: flex;
align-items: center;
gap: 12px;
padding: 14px 16px;
text-align: left;
font: inherit;
font-size: 14px;
color: var(--text-secondary);
background: var(--bg-elevated);
border: 1.5px solid var(--border);
border-radius: var(--radius-md);
cursor: pointer;
}
.source-card:hover {
border-color: var(--text-muted);
}
.source-card:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
.source-card.selected {
border-color: var(--accent);
box-shadow: 0 0 0 3px var(--accent-glow);
}
.source-icon {
flex-shrink: 0;
color: var(--text-muted);
}
.source-card.selected .source-icon {
color: var(--accent);
}
.source-text {
display: flex;
flex-direction: column;
gap: 2px;
min-width: 0;
}
.source-name {
font-size: 14px;
font-weight: 600;
color: var(--text-primary);
}
.source-desc {
font-size: 12.5px;
line-height: 1.4;
color: var(--text-muted);
}
.section-label {
margin: 16px 0 8px;
font-size: 12px;
font-weight: 600;
color: var(--text-secondary);
}
.count {
margin-left: 4px;
font-weight: 500;
color: var(--text-muted);
font-variant-numeric: tabular-nums;
}
.grid-wrap {
overflow-y: auto;
overscroll-behavior: contain;
max-height: min(52vh, 560px);
}
.grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 12px;
}
.clip-card {
display: flex;
flex-direction: column;
gap: 6px;
padding: 0;
border: none;
background: transparent;
color: inherit;
font: inherit;
text-align: left;
cursor: pointer;
}
.thumb {
position: relative;
aspect-ratio: 16 / 9;
border-radius: var(--radius-md);
border: 1.5px solid var(--border);
background: var(--bg-elevated);
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
color: var(--text-muted);
}
.clip-card:hover .thumb {
border-color: var(--text-muted);
}
.clip-card.selected .thumb {
border-color: var(--accent);
box-shadow: 0 0 0 3px var(--accent-glow);
}
.clip-card:focus-visible .thumb {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
.thumb video {
width: 100%;
height: 100%;
object-fit: cover;
}
.check {
position: absolute;
top: 6px;
right: 6px;
width: 20px;
height: 20px;
border-radius: 9999px;
background: var(--accent);
color: var(--accent-ink);
display: flex;
align-items: center;
justify-content: center;
}
.name {
font-size: 13px;
color: var(--text-secondary);
line-height: 1.35;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
padding: 0 2px;
}
.clip-card.selected .name {
color: var(--text-primary);
font-weight: 600;
}
.empty {
margin: 32px 8px;
text-align: center;
color: var(--text-muted);
font-size: 13px;
line-height: 1.45;
}
</style>