Files
aigen/components/PermanenceRefStrip.vue
T

82 lines
2.6 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div>
<div v-if="label" class="mb-1.5 flex items-baseline justify-between gap-2">
<p class="text-[11px] font-medium uppercase tracking-wide text-zinc-500">{{ label }}</p>
<p v-if="hint" class="text-[11px] text-zinc-600">{{ hint }}</p>
</div>
<div class="flex flex-wrap items-start gap-1.5">
<div
v-for="(item, index) in refs"
:key="item.stillId + '-' + index"
class="flex w-14 flex-col items-center gap-0.5"
>
<span class="relative h-12 w-12 overflow-hidden rounded-lg bg-zinc-900">
<span v-if="hidden" class="sensitive-glow block h-full w-full" />
<img
v-else
:src="`/api/library/stills/${item.stillId}?thumb=1`"
alt=""
loading="lazy"
decoding="async"
class="h-full w-full object-cover"
>
<button
v-if="!disabled"
type="button"
class="absolute right-0 top-0 rounded-bl-md bg-zinc-950/80 px-1 text-[10px] leading-4 text-zinc-300 hover:text-red-200"
title="Remove"
@click.stop="emit('remove', index)"
>
×
</button>
</span>
<select
class="w-full truncate rounded border border-white/10 bg-zinc-950 px-0.5 py-0 text-[10px] text-zinc-400"
:disabled="disabled"
:value="item.label"
@change="emit('updateLabel', index, ($event.target as HTMLSelectElement).value)"
>
<option v-for="option in labelOptions(item.label)" :key="option" :value="option">{{ option }}</option>
</select>
</div>
<button
v-if="!disabled && refs.length < max"
type="button"
class="flex h-12 w-12 flex-col items-center justify-center rounded-lg border border-dashed border-white/15 text-[10px] text-zinc-500 hover:border-amber-300/40 hover:text-amber-100"
:title="addTitle"
@click="emit('add')"
>
+ Ref
</button>
</div>
</div>
</template>
<script setup lang="ts">
import { PERMANENCE_REF_LABELS, type PermanenceRef } from '~/utils/globalLocks'
const props = withDefaults(defineProps<{
refs: PermanenceRef[]
label?: string
hint?: string
hidden?: boolean
disabled?: boolean
max?: number
addTitle?: string
}>(), {
max: 6,
addTitle: 'Attach a permanence still'
})
defineEmits<{
add: []
remove: [index: number]
updateLabel: [index: number, label: string]
}>()
function labelOptions(current: string) {
if (PERMANENCE_REF_LABELS.includes(current as typeof PERMANENCE_REF_LABELS[number])) return [...PERMANENCE_REF_LABELS]
return [...PERMANENCE_REF_LABELS, current]
}
</script>