1086 lines
28 KiB
Vue
1086 lines
28 KiB
Vue
<script setup lang="ts">
|
|
import {
|
|
canBeCommander,
|
|
deckCardFromApi,
|
|
deckValidation,
|
|
deleteDeck,
|
|
exportDeckText,
|
|
loadDecks,
|
|
loadSharedDeck,
|
|
newDeckId,
|
|
saveDeck,
|
|
shareDeck,
|
|
type ApiCard,
|
|
type DeckCard,
|
|
type SavedDeck,
|
|
} from '~/utils/decks'
|
|
import { CARD_BACK_COLORS, cardBackVars } from '~/utils/cardBack'
|
|
import { resizeImage } from '~/utils/image'
|
|
|
|
interface DraftDeck {
|
|
id: string
|
|
name: string
|
|
commander: DeckCard | null
|
|
cards: DeckCard[]
|
|
cardBack?: string
|
|
}
|
|
|
|
definePageMeta({ middleware: 'auth' })
|
|
|
|
const { public: { apiBase } } = useRuntimeConfig()
|
|
const route = useRoute()
|
|
const router = useRouter()
|
|
const BASIC_NAMES = ['Plains', 'Island', 'Swamp', 'Mountain', 'Forest']
|
|
|
|
const decks = ref<SavedDeck[]>([])
|
|
const draft = ref<DraftDeck | null>(null)
|
|
const search = ref('')
|
|
const results = ref<ApiCard[]>([])
|
|
const searching = ref(false)
|
|
const searchOpen = ref(false)
|
|
const error = ref('')
|
|
const notice = ref('')
|
|
const importOpen = ref(false)
|
|
const importName = ref('')
|
|
const importText = ref('')
|
|
const importErrors = ref<string[]>([])
|
|
const importing = ref(false)
|
|
const basics = ref<Record<string, ApiCard>>({})
|
|
const showExport = ref(false)
|
|
const shareLink = ref('')
|
|
const shareCopied = ref(false)
|
|
|
|
const count = computed(() => 1 + (draft.value?.cards.length ?? 0))
|
|
const grouped = computed(() => {
|
|
const groups = new Map<string, { card: DeckCard; count: number }>()
|
|
for (const card of draft.value?.cards ?? []) {
|
|
const entry = groups.get(card.oracleId)
|
|
if (entry) entry.count++
|
|
else groups.set(card.oracleId, { card, count: 1 })
|
|
}
|
|
return [...groups.values()]
|
|
})
|
|
const CARD_TYPES = [
|
|
{ label: 'Lands', type: 'Land' },
|
|
{ label: 'Creatures', type: 'Creature' },
|
|
{ label: 'Battles', type: 'Battle' },
|
|
{ label: 'Enchantments', type: 'Enchantment' },
|
|
{ label: 'Instants', type: 'Instant' },
|
|
{ label: 'Sorceries', type: 'Sorcery' },
|
|
{ label: 'Planeswalkers', type: 'Planeswalker' },
|
|
{ label: 'Artifacts', type: 'Artifact' },
|
|
]
|
|
function cardType(typeLine: string): string {
|
|
const main = typeLine.split(/[—–-]/)[0]
|
|
const has = (type: string) => new RegExp(`\\b${type}\\b`, 'i').test(main)
|
|
// Non-land types win so Dryad Arbor and artifact creatures sort by their main type.
|
|
return CARD_TYPES.find(({ type }) => type !== 'Land' && has(type))?.label
|
|
?? CARD_TYPES.find(({ type }) => has(type))?.label
|
|
?? 'Other'
|
|
}
|
|
const deckColumns = computed(() => {
|
|
const columns = new Map<string, { entries: typeof grouped.value; total: number }>()
|
|
for (const { label } of CARD_TYPES) columns.set(label, { entries: [], total: 0 })
|
|
columns.set('Other', { entries: [], total: 0 })
|
|
for (const entry of grouped.value) {
|
|
const column = columns.get(cardType(entry.card.typeLine))!
|
|
column.entries.push(entry)
|
|
column.total += entry.count
|
|
}
|
|
return [...columns.entries()].filter(([, column]) => column.entries.length)
|
|
})
|
|
const validation = computed(() => {
|
|
if (!draft.value) return []
|
|
if (!draft.value.commander) return ['Choose a commander.']
|
|
return deckValidation(toSaved(draft.value, true))
|
|
})
|
|
const exportText = computed(() => {
|
|
if (!draft.value?.commander) return ''
|
|
return exportDeckText(toSaved(draft.value, true))
|
|
})
|
|
const draftCardBackStyle = computed(() => cardBackVars(draft.value?.cardBack))
|
|
|
|
function commanderImage(deck: SavedDeck): string {
|
|
return deck.commander.imageUri
|
|
|| `${apiBase}/cards/${encodeURIComponent(deck.commander.oracleId)}/image`
|
|
}
|
|
|
|
function toSaved(deck: DraftDeck, requireCommander = false): SavedDeck {
|
|
if (!deck.commander && requireCommander) throw new Error('No commander')
|
|
return {
|
|
id: deck.id,
|
|
name: deck.name.trim() || 'Untitled deck',
|
|
commander: deck.commander!,
|
|
cards: [...deck.cards],
|
|
cardBack: deck.cardBack,
|
|
updatedAt: Date.now(),
|
|
}
|
|
}
|
|
|
|
async function reloadDecks() {
|
|
decks.value = (await loadDecks(apiBase)).sort((a, b) => b.updatedAt - a.updatedAt)
|
|
}
|
|
|
|
async function share(deck: SavedDeck) {
|
|
error.value = ''
|
|
try {
|
|
const token = await shareDeck(apiBase, deck.id)
|
|
shareLink.value = `${window.location.origin}/decks?share=${token}`
|
|
shareCopied.value = false
|
|
} catch (caught) {
|
|
error.value = errorMessage(caught)
|
|
}
|
|
}
|
|
|
|
async function copyShareLink() {
|
|
try {
|
|
await navigator.clipboard.writeText(shareLink.value)
|
|
shareCopied.value = true
|
|
} catch {
|
|
shareCopied.value = false
|
|
}
|
|
}
|
|
|
|
function closeShare() {
|
|
shareLink.value = ''
|
|
}
|
|
|
|
function selectDeck(deck: SavedDeck) {
|
|
draft.value = {
|
|
id: deck.id,
|
|
name: deck.name,
|
|
commander: { ...deck.commander },
|
|
cards: deck.cards.map(card => ({ ...card })),
|
|
cardBack: deck.cardBack ?? undefined,
|
|
}
|
|
showExport.value = false
|
|
error.value = ''
|
|
notice.value = ''
|
|
}
|
|
|
|
function createDeck() {
|
|
draft.value = { id: newDeckId(), name: 'New deck', commander: null, cards: [] }
|
|
showExport.value = false
|
|
error.value = ''
|
|
notice.value = ''
|
|
}
|
|
|
|
function closeEditor() {
|
|
draft.value = null
|
|
error.value = ''
|
|
notice.value = ''
|
|
importErrors.value = []
|
|
}
|
|
|
|
async function save() {
|
|
if (!draft.value) return
|
|
if (!draft.value.commander) {
|
|
error.value = 'Choose a commander before saving.'
|
|
return
|
|
}
|
|
if (!draft.value.name.trim()) {
|
|
error.value = 'Give the deck a name.'
|
|
return
|
|
}
|
|
error.value = ''
|
|
try {
|
|
await saveDeck(apiBase, toSaved(draft.value))
|
|
await reloadDecks()
|
|
notice.value = 'Deck saved.'
|
|
} catch (caught) {
|
|
error.value = errorMessage(caught)
|
|
}
|
|
}
|
|
|
|
async function removeDeck() {
|
|
if (!draft.value || !window.confirm(`Delete "${draft.value.name}"?`)) return
|
|
error.value = ''
|
|
try {
|
|
await deleteDeck(apiBase, draft.value.id)
|
|
await reloadDecks()
|
|
draft.value = null
|
|
notice.value = 'Deck deleted.'
|
|
} catch (caught) {
|
|
error.value = errorMessage(caught)
|
|
}
|
|
}
|
|
|
|
function setCommander(card: ApiCard) {
|
|
if (!draft.value) return
|
|
const mapped = deckCardFromApi(card)
|
|
if (!canBeCommander(mapped)) {
|
|
error.value = `${card.name} cannot be a commander.`
|
|
return
|
|
}
|
|
draft.value.commander = mapped
|
|
draft.value.cards = draft.value.cards.filter(entry => entry.oracleId !== mapped.oracleId)
|
|
error.value = ''
|
|
}
|
|
|
|
function addCard(card: ApiCard) {
|
|
if (!draft.value) return
|
|
const mapped = deckCardFromApi(card)
|
|
if (draft.value.commander?.oracleId === mapped.oracleId) {
|
|
error.value = `${card.name} is already the commander.`
|
|
return
|
|
}
|
|
draft.value.cards.push(mapped)
|
|
error.value = ''
|
|
}
|
|
|
|
function addBasic(name: string, amount: number) {
|
|
const card = basics.value[name]
|
|
if (!card || !draft.value) return
|
|
for (let index = 0; index < amount; index++) addCard(card)
|
|
}
|
|
|
|
async function runSearch() {
|
|
const query = search.value.trim()
|
|
if (!query) return
|
|
searching.value = true
|
|
error.value = ''
|
|
try {
|
|
const data = await $fetch<{ cards: ApiCard[] }>(`${apiBase}/cards`, {
|
|
query: { q: query, limit: 20, status: 'all' },
|
|
})
|
|
if (query === search.value.trim()) results.value = data.cards
|
|
} catch (caught) {
|
|
error.value = errorMessage(caught)
|
|
} finally {
|
|
searching.value = false
|
|
}
|
|
}
|
|
|
|
let searchTimer: ReturnType<typeof setTimeout> | undefined
|
|
watch(search, () => {
|
|
clearTimeout(searchTimer)
|
|
searchOpen.value = true
|
|
if (!search.value.trim()) {
|
|
results.value = []
|
|
return
|
|
}
|
|
searchTimer = setTimeout(runSearch, 250)
|
|
})
|
|
|
|
function onSearchBlur(event: FocusEvent) {
|
|
const box = event.currentTarget as HTMLElement
|
|
if (!box.contains(event.relatedTarget as Node | null)) searchOpen.value = false
|
|
}
|
|
|
|
function submitSearch() {
|
|
clearTimeout(searchTimer)
|
|
runSearch()
|
|
}
|
|
|
|
function openImport() {
|
|
importName.value = ''
|
|
importText.value = ''
|
|
importErrors.value = []
|
|
importOpen.value = true
|
|
}
|
|
|
|
function closeImport() {
|
|
if (!importing.value) importOpen.value = false
|
|
}
|
|
|
|
async function importDeck() {
|
|
if (!importName.value.trim() || !importText.value.trim()) return
|
|
importing.value = true
|
|
importErrors.value = []
|
|
try {
|
|
const data = await $fetch<{ commander?: ApiCard; cards: ApiCard[]; errors: string[] }>(
|
|
`${apiBase}/decks/import`,
|
|
{ method: 'POST', body: { text: importText.value } },
|
|
)
|
|
draft.value = {
|
|
id: newDeckId(),
|
|
name: importName.value.trim(),
|
|
commander: data.commander ? deckCardFromApi(data.commander) : null,
|
|
cards: data.cards.map(deckCardFromApi),
|
|
}
|
|
importOpen.value = false
|
|
showExport.value = false
|
|
error.value = ''
|
|
importErrors.value = data.errors
|
|
notice.value = 'Decklist imported. Review it and save.'
|
|
} catch (caught) {
|
|
importErrors.value = [errorMessage(caught)]
|
|
} finally {
|
|
importing.value = false
|
|
}
|
|
}
|
|
|
|
async function uploadCardBack(event: Event) {
|
|
const input = event.target as HTMLInputElement
|
|
const file = input.files?.[0]
|
|
input.value = ''
|
|
if (!file || !draft.value) return
|
|
if (!file.type.startsWith('image/')) {
|
|
error.value = 'Choose an image file.'
|
|
return
|
|
}
|
|
try {
|
|
draft.value.cardBack = await resizeImage(file, 700)
|
|
error.value = ''
|
|
} catch {
|
|
error.value = 'Could not read that image.'
|
|
}
|
|
}
|
|
|
|
async function copyExport() {
|
|
try {
|
|
await navigator.clipboard.writeText(exportText.value)
|
|
notice.value = 'Decklist copied.'
|
|
} catch {
|
|
notice.value = 'Copy failed; select the text manually.'
|
|
}
|
|
}
|
|
|
|
function errorMessage(caught: unknown): string {
|
|
const data = (caught as { data?: { error?: string } })?.data
|
|
return data?.error ?? (caught instanceof Error ? caught.message : String(caught))
|
|
}
|
|
|
|
onMounted(async () => {
|
|
await reloadDecks()
|
|
|
|
const sharedToken = route.query.share
|
|
if (typeof sharedToken === 'string' && sharedToken) {
|
|
try {
|
|
const deck = await loadSharedDeck(apiBase, sharedToken)
|
|
draft.value = {
|
|
id: newDeckId(),
|
|
name: deck.name,
|
|
commander: { ...deck.commander },
|
|
cards: deck.cards.map(card => ({ ...card })),
|
|
cardBack: deck.cardBack ?? undefined,
|
|
}
|
|
notice.value = 'Shared deck loaded. Save it to add it to your account.'
|
|
} catch (caught) {
|
|
error.value = errorMessage(caught)
|
|
}
|
|
// Drop the token from the URL so a reload does not import the deck again.
|
|
const query = { ...route.query }
|
|
delete query.share
|
|
await router.replace({ query })
|
|
}
|
|
|
|
try {
|
|
const data = await $fetch<{ cards: (ApiCard | null)[] }>(`${apiBase}/cards/resolve`, {
|
|
method: 'POST',
|
|
body: { names: BASIC_NAMES },
|
|
})
|
|
for (const card of data.cards) {
|
|
if (card && BASIC_NAMES.includes(card.name)) basics.value[card.name] = card
|
|
}
|
|
} catch {
|
|
// Basic-land shortcuts are a convenience; the deck builder still works without them.
|
|
}
|
|
})
|
|
</script>
|
|
|
|
<template>
|
|
<main class="fill-page">
|
|
<template v-if="draft">
|
|
<section class="detail-panel editor-panel">
|
|
<div class="detail-head">
|
|
<button type="button" class="mini" @click="closeEditor">← Decks</button>
|
|
<input v-model="draft.name" aria-label="Deck name" maxlength="60">
|
|
<span class="tag" :class="count === 100 ? 'good' : 'bad'">{{ count }}/100</span>
|
|
</div>
|
|
|
|
<p v-if="draft.commander" class="commander-line">
|
|
<span class="tag good">Commander</span>
|
|
<strong>{{ draft.commander.name }}</strong>
|
|
<ManaCost :cost="draft.commander.manaCost" />
|
|
<span
|
|
v-if="draft.commander.implementation && draft.commander.implementation.status !== 'supported'"
|
|
class="warn"
|
|
title="Not fully implemented"
|
|
>!</span>
|
|
<span class="muted">{{ draft.commander.typeLine }}</span>
|
|
<span class="badges">
|
|
<span v-for="color in draft.commander.colorIdentity" :key="color" class="tag">
|
|
<ManaCost :cost="`{${color}}`" />
|
|
</span>
|
|
</span>
|
|
</p>
|
|
<p v-else class="warn">Search for a legendary creature and set it as the commander.</p>
|
|
|
|
<div class="back-editor">
|
|
<span
|
|
class="back-preview"
|
|
role="img"
|
|
:aria-label="draft.cardBack ? 'Deck card back' : 'Default card back'"
|
|
:style="draftCardBackStyle"
|
|
>
|
|
<span v-if="!draft.cardBack" class="muted">Default</span>
|
|
</span>
|
|
<div class="back-options">
|
|
<span class="muted">Card back</span>
|
|
<div class="back-colors">
|
|
<button
|
|
v-for="color in CARD_BACK_COLORS"
|
|
:key="color"
|
|
type="button"
|
|
class="back-color"
|
|
:class="{ active: draft.cardBack === color }"
|
|
:style="{ background: color }"
|
|
:aria-label="`Card back ${color}`"
|
|
:aria-pressed="draft.cardBack === color"
|
|
@click="draft.cardBack = color"
|
|
/>
|
|
</div>
|
|
<div class="row wrap">
|
|
<label class="mini upload-label">
|
|
Upload
|
|
<input class="hidden-file" type="file" accept="image/*" @change="uploadCardBack">
|
|
</label>
|
|
<button type="button" class="mini" :disabled="!draft.cardBack" @click="draft.cardBack = undefined">
|
|
Reset
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<p v-if="error" class="error">{{ error }}</p>
|
|
<p v-else-if="notice" class="ok">{{ notice }}</p>
|
|
<ul class="errors">
|
|
<li v-for="message in importErrors" :key="message" class="error">{{ message }}</li>
|
|
<li v-for="message in validation" :key="message" class="error">{{ message }}</li>
|
|
</ul>
|
|
|
|
<div class="builder">
|
|
<section class="search-column">
|
|
<form class="search" @submit.prevent="submitSearch">
|
|
<div class="search-box" @focusin="searchOpen = true" @focusout="onSearchBlur">
|
|
<input
|
|
v-model="search"
|
|
type="search"
|
|
placeholder="Search cards to add…"
|
|
autocomplete="off"
|
|
>
|
|
<ul v-if="searchOpen && search.trim()" class="dropdown">
|
|
<li v-for="card in results" :key="card.oracle_id">
|
|
<CardHover :oracle-id="card.oracle_id" :name="card.name">
|
|
<div class="result-row">
|
|
<div class="result-info">
|
|
<span class="result-name">
|
|
<span class="card-name">{{ card.name }}</span>
|
|
<ManaCost :cost="card.mana_cost" />
|
|
</span>
|
|
<span class="muted">{{ card.type_line }}</span>
|
|
</div>
|
|
<div class="badges">
|
|
<button
|
|
v-if="canBeCommander(deckCardFromApi(card))"
|
|
type="button"
|
|
class="mini"
|
|
@click="setCommander(card)"
|
|
>Commander</button>
|
|
<button type="button" class="mini" @click="addCard(card)">Add</button>
|
|
</div>
|
|
</div>
|
|
</CardHover>
|
|
</li>
|
|
<li v-if="!results.length" class="muted">
|
|
{{ searching ? 'Searching…' : 'No cards match.' }}
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<button type="submit" :disabled="searching">{{ searching ? '…' : 'Search' }}</button>
|
|
</form>
|
|
|
|
<div class="basic-row">
|
|
<span class="muted">Basics:</span>
|
|
<template v-for="name in BASIC_NAMES" :key="name">
|
|
<button v-if="basics[name]" type="button" class="mini" @click="addBasic(name, 1)">
|
|
+1 {{ name }}
|
|
</button>
|
|
<button v-if="basics[name]" type="button" class="mini" @click="addBasic(name, 10)">
|
|
+10
|
|
</button>
|
|
</template>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="deck-section">
|
|
<div class="row">
|
|
<h3 class="grow">Deck</h3>
|
|
<span class="muted">{{ draft.cards.length }} cards</span>
|
|
</div>
|
|
<p v-if="!grouped.length" class="muted">The deck is empty. Add cards from search or use +10 basics.</p>
|
|
<div class="columns-scroll">
|
|
<div class="columns">
|
|
<section v-for="[type, column] in deckColumns" :key="type" class="type-column">
|
|
<h4>{{ type }} <span class="muted">{{ column.total }}</span></h4>
|
|
<ul class="list results">
|
|
<li v-for="entry in column.entries" :key="entry.card.oracleId">
|
|
<CardHover :oracle-id="entry.card.oracleId" :name="entry.card.name">
|
|
<div class="deck-row">
|
|
<span class="count">{{ entry.count }}</span>
|
|
<span class="card-name grow">{{ entry.card.name }}</span>
|
|
<ManaCost :cost="entry.card.manaCost" />
|
|
<span
|
|
v-if="entry.card.implementation && entry.card.implementation.status !== 'supported'"
|
|
class="warn"
|
|
title="Not fully implemented"
|
|
>!</span>
|
|
</div>
|
|
</CardHover>
|
|
</li>
|
|
</ul>
|
|
</section>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
|
|
<div class="actions">
|
|
<button type="button" class="primary" @click="save">Save deck</button>
|
|
<button type="button" :disabled="!draft.commander" @click="showExport = !showExport">
|
|
{{ showExport ? 'Hide export' : 'Export' }}
|
|
</button>
|
|
<button type="button" class="danger" :disabled="!decks.some(deck => deck.id === draft?.id)" @click="removeDeck">
|
|
Delete
|
|
</button>
|
|
<span v-if="validation.length" class="muted">Saved decks can be incomplete; games need 100 legal cards.</span>
|
|
</div>
|
|
|
|
<div v-if="showExport" class="panel">
|
|
<div class="row">
|
|
<h3 class="grow">Plain-text decklist</h3>
|
|
<button type="button" class="mini" @click="copyExport">Copy</button>
|
|
</div>
|
|
<textarea :value="exportText" readonly class="export-box" />
|
|
</div>
|
|
</section>
|
|
</template>
|
|
|
|
<template v-else>
|
|
<header class="row wrap">
|
|
<div class="grow">
|
|
<h1>Commander decks</h1>
|
|
<p class="muted">
|
|
Decks are saved to your account. Build one by hand or import a Moxfield,
|
|
Archidekt, or Arena text export.
|
|
</p>
|
|
</div>
|
|
<button type="button" class="primary" @click="createDeck">New deck</button>
|
|
</header>
|
|
|
|
<section class="decks-panel">
|
|
<p v-if="error" class="error">{{ error }}</p>
|
|
<p v-if="!decks.length" class="muted">No saved decks yet.</p>
|
|
<div class="deck-grid">
|
|
<button type="button" class="deck-tile import-tile" @click="openImport">
|
|
<span class="plus" aria-hidden="true">+</span>
|
|
<span class="deck-name">Import deck</span>
|
|
</button>
|
|
<div v-for="deck in decks" :key="deck.id" class="deck-cell">
|
|
<button type="button" class="deck-tile" @click="selectDeck(deck)">
|
|
<span class="deck-stack">
|
|
<img :src="commanderImage(deck)" :alt="`${deck.commander.name} card`" loading="lazy">
|
|
</span>
|
|
<span class="deck-name">{{ deck.name }}</span>
|
|
<span class="deck-meta">
|
|
<span class="tag" :class="deck.cards.length + 1 === 100 ? 'good' : 'bad'">
|
|
{{ deck.cards.length + 1 }}/100
|
|
</span>
|
|
<span class="muted deck-commander">{{ deck.commander.name }}</span>
|
|
</span>
|
|
</button>
|
|
<button
|
|
type="button"
|
|
class="mini share-button"
|
|
:aria-label="`Share ${deck.name}`"
|
|
@click="share(deck)"
|
|
>Share</button>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<div v-if="shareLink" class="modal-backdrop" @click.self="closeShare">
|
|
<div class="modal">
|
|
<h2>Share deck</h2>
|
|
<p class="muted">Anyone with this link can view and import a copy of the deck.</p>
|
|
<input :value="shareLink" readonly aria-label="Share link">
|
|
<div class="row wrap modal-actions">
|
|
<button type="button" @click="closeShare">Done</button>
|
|
<button type="button" class="primary" @click="copyShareLink">
|
|
{{ shareCopied ? 'Copied' : 'Copy link' }}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div v-if="importOpen" class="modal-backdrop" @click.self="closeImport">
|
|
<form class="modal" @submit.prevent="importDeck">
|
|
<h2>Import deck</h2>
|
|
<label class="field">
|
|
<span class="muted">Deck name</span>
|
|
<input v-model="importName" maxlength="60" placeholder="My deck" required>
|
|
</label>
|
|
<label class="field grow">
|
|
<span class="muted">Decklist</span>
|
|
<textarea
|
|
v-model="importText"
|
|
class="import-box"
|
|
placeholder="Commander 1 Atraxa, Praetors' Voice Deck 1 Sol Ring 10 Forest"
|
|
required
|
|
/>
|
|
</label>
|
|
<p v-for="message in importErrors" :key="message" class="error">{{ message }}</p>
|
|
<div class="row wrap modal-actions">
|
|
<button type="button" @click="closeImport">Cancel</button>
|
|
<button
|
|
type="submit"
|
|
class="primary"
|
|
:disabled="importing || !importName.trim() || !importText.trim()"
|
|
>
|
|
{{ importing ? 'Importing…' : 'Import' }}
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</template>
|
|
</main>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.detail-head {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.75rem;
|
|
}
|
|
|
|
.detail-head input {
|
|
font-size: 1.1rem;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.editor-panel {
|
|
flex: 1;
|
|
min-height: 0;
|
|
}
|
|
|
|
.decks-panel {
|
|
flex: 1;
|
|
min-height: 0;
|
|
overflow-y: auto;
|
|
padding-right: 0.25rem;
|
|
}
|
|
|
|
.deck-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
|
|
gap: 1rem;
|
|
}
|
|
|
|
.deck-cell {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 0.4rem;
|
|
min-width: 0;
|
|
}
|
|
|
|
.deck-cell .deck-tile {
|
|
flex: 1;
|
|
}
|
|
|
|
.share-button {
|
|
align-self: flex-end;
|
|
}
|
|
|
|
.deck-tile {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 0.45rem;
|
|
min-width: 0;
|
|
padding: 0.6rem;
|
|
background: var(--panel);
|
|
border: 1px solid var(--line);
|
|
border-radius: 10px;
|
|
text-align: left;
|
|
}
|
|
|
|
.deck-tile:hover {
|
|
border-color: var(--accent);
|
|
}
|
|
|
|
.deck-stack {
|
|
position: relative;
|
|
display: block;
|
|
aspect-ratio: 488 / 680;
|
|
margin: 0 0.4rem 0.5rem;
|
|
}
|
|
|
|
.deck-stack::before,
|
|
.deck-stack::after {
|
|
content: '';
|
|
position: absolute;
|
|
inset: 0;
|
|
border: 1px solid var(--line);
|
|
border-radius: 8px;
|
|
background: var(--panel-2);
|
|
}
|
|
|
|
.deck-stack::before {
|
|
transform: translate(7px, 7px);
|
|
}
|
|
|
|
.deck-stack::after {
|
|
transform: translate(3px, 3px);
|
|
}
|
|
|
|
.deck-stack img {
|
|
position: relative;
|
|
z-index: 1;
|
|
display: block;
|
|
width: 100%;
|
|
height: 100%;
|
|
object-fit: cover;
|
|
border: 1px solid var(--line);
|
|
border-radius: 8px;
|
|
background: var(--panel-2);
|
|
}
|
|
|
|
.deck-name {
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.deck-meta {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.4rem;
|
|
min-width: 0;
|
|
}
|
|
|
|
.deck-commander {
|
|
min-width: 0;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
font-size: 0.8rem;
|
|
}
|
|
|
|
.import-tile {
|
|
align-items: center;
|
|
justify-content: center;
|
|
min-height: 15rem;
|
|
border-style: dashed;
|
|
color: var(--muted);
|
|
}
|
|
|
|
.import-tile:hover {
|
|
color: var(--text);
|
|
}
|
|
|
|
.plus {
|
|
font-size: 2.5rem;
|
|
line-height: 1;
|
|
}
|
|
|
|
.modal-backdrop {
|
|
position: fixed;
|
|
inset: 0;
|
|
z-index: 50;
|
|
display: grid;
|
|
place-items: center;
|
|
padding: 1rem;
|
|
background: rgb(0 0 0 / 55%);
|
|
}
|
|
|
|
.modal {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 0.75rem;
|
|
width: min(32rem, 100%);
|
|
max-height: calc(100vh - 2rem);
|
|
overflow-y: auto;
|
|
padding: 1.25rem;
|
|
background: var(--panel);
|
|
border: 1px solid var(--line);
|
|
border-radius: 10px;
|
|
}
|
|
|
|
.modal .field {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 0.35rem;
|
|
}
|
|
|
|
.modal .import-box {
|
|
flex: 1;
|
|
min-height: 10rem;
|
|
}
|
|
|
|
.modal-actions {
|
|
justify-content: flex-end;
|
|
}
|
|
|
|
.back-editor {
|
|
display: flex;
|
|
align-items: center;
|
|
flex-wrap: wrap;
|
|
gap: 0.75rem;
|
|
}
|
|
|
|
.back-preview {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
flex: 0 0 auto;
|
|
width: 3.4rem;
|
|
aspect-ratio: 488 / 680;
|
|
border: 1px solid var(--line);
|
|
border-radius: 5px;
|
|
background-color: var(--card-back-color, #26304a);
|
|
background-image: var(--card-back-image, none);
|
|
background-position: center;
|
|
background-size: cover;
|
|
}
|
|
|
|
.back-options {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 0.35rem;
|
|
}
|
|
|
|
.back-colors {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: 0.3rem;
|
|
}
|
|
|
|
.back-color {
|
|
width: 1.6rem;
|
|
aspect-ratio: 488 / 680;
|
|
padding: 0;
|
|
border: 1px solid var(--line);
|
|
border-radius: 3px;
|
|
}
|
|
|
|
.back-color.active {
|
|
outline: 2px solid var(--accent);
|
|
outline-offset: 1px;
|
|
}
|
|
|
|
.upload-label {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
cursor: pointer;
|
|
padding: 0.3rem 0.5rem;
|
|
border: 1px solid var(--line);
|
|
border-radius: 6px;
|
|
}
|
|
|
|
.upload-label:hover {
|
|
border-color: var(--accent);
|
|
}
|
|
|
|
.hidden-file {
|
|
display: none;
|
|
}
|
|
|
|
.commander-line {
|
|
display: flex;
|
|
align-items: center;
|
|
flex-wrap: wrap;
|
|
gap: 0.5rem;
|
|
font-size: 0.9rem;
|
|
}
|
|
|
|
.errors {
|
|
list-style: none;
|
|
margin: 0;
|
|
padding: 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 0.2rem;
|
|
}
|
|
|
|
.builder {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 1rem;
|
|
min-height: 0;
|
|
flex: 1;
|
|
}
|
|
|
|
/* Let the grid/flex chain shrink to the viewport; card names are nowrap. */
|
|
.detail-panel,
|
|
.builder,
|
|
.deck-section,
|
|
.columns-scroll,
|
|
.columns {
|
|
min-width: 0;
|
|
}
|
|
|
|
.search-column,
|
|
.deck-section {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 0.5rem;
|
|
min-height: 0;
|
|
}
|
|
|
|
.search-column {
|
|
flex: 0 0 auto;
|
|
}
|
|
|
|
.deck-section {
|
|
flex: 1;
|
|
}
|
|
|
|
.search-box {
|
|
position: relative;
|
|
flex: 1;
|
|
min-width: 0;
|
|
}
|
|
|
|
.search-box input {
|
|
width: 100%;
|
|
}
|
|
|
|
.dropdown {
|
|
position: absolute;
|
|
top: calc(100% + 0.25rem);
|
|
left: 0;
|
|
right: 0;
|
|
z-index: 20;
|
|
max-height: 22rem;
|
|
overflow-y: auto;
|
|
list-style: none;
|
|
margin: 0;
|
|
padding: 0.25rem;
|
|
background: var(--panel);
|
|
border: 1px solid var(--line);
|
|
border-radius: 6px;
|
|
box-shadow: 0 12px 32px rgb(0 0 0 / 45%);
|
|
}
|
|
|
|
.columns-scroll {
|
|
flex: 1;
|
|
min-height: 0;
|
|
overflow-y: auto;
|
|
overflow-x: hidden;
|
|
}
|
|
|
|
.columns {
|
|
column-count: 4;
|
|
column-gap: 0.75rem;
|
|
max-width: 100%;
|
|
}
|
|
|
|
.type-column {
|
|
break-inside: avoid;
|
|
margin-bottom: 0.75rem;
|
|
min-width: 0;
|
|
overflow: hidden;
|
|
background: var(--panel-2);
|
|
border: 1px solid var(--line);
|
|
border-radius: 6px;
|
|
padding: 0.4rem;
|
|
}
|
|
|
|
.type-column h4 {
|
|
margin: 0 0 0.3rem;
|
|
padding: 0 0.2rem;
|
|
font-size: 0.85rem;
|
|
}
|
|
|
|
.type-column .results {
|
|
border: 0;
|
|
padding: 0;
|
|
overflow-x: hidden;
|
|
}
|
|
|
|
@media (max-width: 1100px) {
|
|
.columns {
|
|
column-count: 2;
|
|
}
|
|
}
|
|
|
|
@media (max-width: 600px) {
|
|
.columns {
|
|
column-count: 1;
|
|
}
|
|
}
|
|
|
|
.results {
|
|
border: 1px solid var(--line);
|
|
border-radius: 6px;
|
|
padding: 0.25rem;
|
|
}
|
|
|
|
.result-row,
|
|
.deck-row {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
padding: 0.3rem 0.4rem;
|
|
border-bottom: 1px solid var(--line);
|
|
min-width: 0;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.results > li:last-child .result-row,
|
|
.results > li:last-child .deck-row {
|
|
border-bottom: 0;
|
|
}
|
|
|
|
.result-info {
|
|
display: flex;
|
|
flex-direction: column;
|
|
min-width: 0;
|
|
flex: 1;
|
|
}
|
|
|
|
.result-name {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.4rem;
|
|
min-width: 0;
|
|
}
|
|
|
|
.result-name .card-name {
|
|
min-width: 0;
|
|
}
|
|
|
|
.result-info .muted {
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.mini {
|
|
font-size: 0.75rem;
|
|
padding: 0.2rem 0.45rem;
|
|
}
|
|
|
|
.count {
|
|
min-width: 1.6rem;
|
|
text-align: right;
|
|
color: var(--muted);
|
|
}
|
|
|
|
.basic-row {
|
|
display: flex;
|
|
align-items: center;
|
|
flex-wrap: wrap;
|
|
gap: 0.35rem;
|
|
}
|
|
|
|
.import-box {
|
|
min-height: 8rem;
|
|
}
|
|
|
|
.export-box {
|
|
min-height: 10rem;
|
|
}
|
|
</style>
|