First commit
This commit is contained in:
1094
frontend/app/components/CardGraphEditor.vue
Normal file
1094
frontend/app/components/CardGraphEditor.vue
Normal file
File diff suppressed because it is too large
Load Diff
77
frontend/app/components/CardHover.vue
Normal file
77
frontend/app/components/CardHover.vue
Normal file
@@ -0,0 +1,77 @@
|
||||
<script setup lang="ts">
|
||||
const props = defineProps<{ oracleId: string; name: string }>()
|
||||
const { public: { apiBase } } = useRuntimeConfig()
|
||||
|
||||
const PREVIEW_WIDTH = 244
|
||||
const PREVIEW_HEIGHT = 340
|
||||
|
||||
const visible = ref(false)
|
||||
const failed = ref(false)
|
||||
const left = ref(0)
|
||||
const top = ref(0)
|
||||
|
||||
const src = computed(() => `${apiBase}/cards/${encodeURIComponent(props.oracleId)}/image`)
|
||||
|
||||
function follow(event: MouseEvent) {
|
||||
left.value = Math.max(8, Math.min(
|
||||
event.clientX + 20,
|
||||
window.innerWidth - PREVIEW_WIDTH - 8,
|
||||
))
|
||||
top.value = Math.max(8, Math.min(
|
||||
event.clientY - PREVIEW_HEIGHT / 2,
|
||||
window.innerHeight - PREVIEW_HEIGHT - 8,
|
||||
))
|
||||
}
|
||||
|
||||
function enter(event: MouseEvent) {
|
||||
failed.value = false
|
||||
follow(event)
|
||||
visible.value = true
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<span
|
||||
class="card-hover"
|
||||
@mouseenter="enter"
|
||||
@mousemove="follow"
|
||||
@mouseleave="visible = false"
|
||||
@pointerdown="visible = false"
|
||||
>
|
||||
<slot />
|
||||
<Teleport to="body">
|
||||
<img
|
||||
v-if="visible && !failed"
|
||||
class="card-art"
|
||||
:src="src"
|
||||
:alt="`${name} card art`"
|
||||
:style="{ left: `${left}px`, top: `${top}px` }"
|
||||
@error="failed = true"
|
||||
>
|
||||
</Teleport>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.card-hover {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.card-art {
|
||||
position: fixed;
|
||||
z-index: 100;
|
||||
width: 244px;
|
||||
height: auto;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
|
||||
pointer-events: none;
|
||||
animation: card-art-in 140ms ease-out;
|
||||
}
|
||||
|
||||
@keyframes card-art-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: scale(0.96);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
98
frontend/app/components/GameCard.vue
Normal file
98
frontend/app/components/GameCard.vue
Normal file
@@ -0,0 +1,98 @@
|
||||
<script setup lang="ts">
|
||||
const props = defineProps<{
|
||||
oracleId: string
|
||||
name: string
|
||||
tapped?: boolean
|
||||
}>()
|
||||
|
||||
const { public: { apiBase } } = useRuntimeConfig()
|
||||
|
||||
const failed = ref(false)
|
||||
const src = computed(() => `${apiBase}/cards/${encodeURIComponent(props.oracleId)}/image`)
|
||||
const token = computed(() => props.oracleId.startsWith('token:'))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="game-card" :class="{ tapped, token }">
|
||||
<div class="card-face">
|
||||
<img
|
||||
v-if="!failed && !token"
|
||||
:src="src"
|
||||
:alt="name"
|
||||
loading="lazy"
|
||||
draggable="false"
|
||||
@error="failed = true"
|
||||
>
|
||||
<div v-else class="card-fallback">
|
||||
<span class="fallback-name">{{ name }}</span>
|
||||
<span v-if="token" class="fallback-kind">Token</span>
|
||||
</div>
|
||||
</div>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.game-card {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
aspect-ratio: 488 / 680;
|
||||
}
|
||||
|
||||
.game-card.tapped {
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.card-face {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
transform-origin: center;
|
||||
transition: transform 150ms ease;
|
||||
}
|
||||
|
||||
.game-card.tapped .card-face {
|
||||
transform: rotate(90deg) scale(0.7);
|
||||
}
|
||||
|
||||
img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 6px;
|
||||
object-fit: cover;
|
||||
background: #0b0d12;
|
||||
box-shadow: 0 3px 10px rgb(0 0 0 / 45%);
|
||||
-webkit-user-drag: none;
|
||||
}
|
||||
|
||||
.card-fallback {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.35rem;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 0.6rem;
|
||||
border: 1px solid #5b563f;
|
||||
border-radius: 6px;
|
||||
background:
|
||||
radial-gradient(circle at 50% 30%, rgb(232 192 125 / 14%), transparent 70%),
|
||||
#1d211b;
|
||||
box-shadow: 0 3px 10px rgb(0 0 0 / 45%);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.fallback-name {
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
line-height: 1.25;
|
||||
}
|
||||
|
||||
.fallback-kind {
|
||||
font-size: 0.6rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.08em;
|
||||
color: var(--muted);
|
||||
}
|
||||
</style>
|
||||
54
frontend/app/components/ManaCost.vue
Normal file
54
frontend/app/components/ManaCost.vue
Normal file
@@ -0,0 +1,54 @@
|
||||
<script setup lang="ts">
|
||||
const props = defineProps<{ cost?: string }>()
|
||||
|
||||
const groups = computed(() => (props.cost ?? '')
|
||||
.split('//')
|
||||
.map(group => group.match(/\{([^}]+)\}/g)?.map(token => token.slice(1, -1)) ?? [])
|
||||
.filter(group => group.length > 0))
|
||||
|
||||
/** mana-font names a few symbols differently from Scryfall's code. */
|
||||
const ALIASES: Record<string, string> = { T: 'tap', Q: 'untap', '∞': 'infinity' }
|
||||
|
||||
function classOf(symbol: string): string {
|
||||
return ALIASES[symbol.toUpperCase()] ?? symbol.replaceAll('/', '').toLowerCase()
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<span
|
||||
v-if="groups.length"
|
||||
class="mana-cost"
|
||||
role="img"
|
||||
:aria-label="`Mana cost ${cost}`"
|
||||
>
|
||||
<template v-for="(group, groupIndex) in groups" :key="groupIndex">
|
||||
<span v-if="groupIndex" class="mana-separator" aria-hidden="true">//</span>
|
||||
<i
|
||||
v-for="(symbol, index) in group"
|
||||
:key="`${symbol}-${index}`"
|
||||
class="ms ms-cost mana-symbol"
|
||||
:class="`ms-${classOf(symbol)}`"
|
||||
:title="`{${symbol}}`"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</template>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.mana-cost {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.mana-symbol {
|
||||
font-size: 0.72rem;
|
||||
}
|
||||
|
||||
.mana-separator {
|
||||
color: var(--muted);
|
||||
font-size: 0.7rem;
|
||||
}
|
||||
</style>
|
||||
199
frontend/app/components/PlaymatPicker.vue
Normal file
199
frontend/app/components/PlaymatPicker.vue
Normal file
@@ -0,0 +1,199 @@
|
||||
<script setup lang="ts">
|
||||
import type { PlaymatSelection } from '~/utils/playmat'
|
||||
import { resizeImage } from '~/utils/image'
|
||||
|
||||
interface CardSummary {
|
||||
oracle_id: string
|
||||
name: string
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
current?: { kind: 'card'; oracleId: string } | { kind: 'upload'; url: string } | null
|
||||
busy?: boolean
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{ select: [selection: PlaymatSelection] }>()
|
||||
const { public: { apiBase } } = useRuntimeConfig()
|
||||
|
||||
const query = ref('')
|
||||
const results = ref<CardSummary[]>([])
|
||||
const searching = ref(false)
|
||||
const localError = ref('')
|
||||
let searchTimer: ReturnType<typeof setTimeout> | undefined
|
||||
|
||||
const previewUrl = computed(() => {
|
||||
const current = props.current
|
||||
if (!current) return undefined
|
||||
return current.kind === 'card'
|
||||
? `${apiBase}/cards/${encodeURIComponent(current.oracleId)}/art`
|
||||
: current.url
|
||||
})
|
||||
|
||||
async function search() {
|
||||
const term = query.value.trim()
|
||||
if (term.length < 2) {
|
||||
results.value = []
|
||||
searching.value = false
|
||||
return
|
||||
}
|
||||
searching.value = true
|
||||
try {
|
||||
const data = await $fetch<{ cards: CardSummary[] }>(`${apiBase}/cards`, {
|
||||
query: { q: term, limit: 24 },
|
||||
})
|
||||
if (query.value.trim() === term) results.value = data.cards
|
||||
} catch {
|
||||
if (query.value.trim() === term) results.value = []
|
||||
} finally {
|
||||
if (query.value.trim() === term) searching.value = false
|
||||
}
|
||||
}
|
||||
|
||||
watch(query, () => {
|
||||
clearTimeout(searchTimer)
|
||||
searchTimer = setTimeout(search, 300)
|
||||
})
|
||||
|
||||
onUnmounted(() => clearTimeout(searchTimer))
|
||||
|
||||
function choose(card: CardSummary) {
|
||||
results.value = []
|
||||
query.value = ''
|
||||
emit('select', { kind: 'card', oracleId: card.oracle_id })
|
||||
}
|
||||
|
||||
/** The API caps uploaded JPEG playmats at 3 MB, so shrink large images first. */
|
||||
async function upload(event: Event) {
|
||||
const input = event.target as HTMLInputElement
|
||||
const file = input.files?.[0]
|
||||
input.value = ''
|
||||
if (!file) return
|
||||
localError.value = ''
|
||||
if (!file.type.startsWith('image/')) {
|
||||
localError.value = 'Choose an image file.'
|
||||
return
|
||||
}
|
||||
try {
|
||||
const data = await resizeImage(file, 1920)
|
||||
if (data.length > 4_000_000) {
|
||||
localError.value = 'That image is too large. Try a smaller one.'
|
||||
return
|
||||
}
|
||||
emit('select', { kind: 'upload', data })
|
||||
} catch {
|
||||
localError.value = 'Could not read that image.'
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="playmat-picker">
|
||||
<div
|
||||
class="preview"
|
||||
role="img"
|
||||
:aria-label="previewUrl ? 'Current playmat' : 'No playmat selected'"
|
||||
:style="previewUrl ? { backgroundImage: `url('${previewUrl}')` } : undefined"
|
||||
>
|
||||
<span v-if="!previewUrl" class="muted">No playmat</span>
|
||||
</div>
|
||||
<input
|
||||
v-model="query"
|
||||
type="search"
|
||||
placeholder="Search Magic art…"
|
||||
aria-label="Search Magic art"
|
||||
>
|
||||
<p v-if="busy || searching" class="muted">Working…</p>
|
||||
<p v-else-if="query.trim().length >= 2 && !results.length" class="muted">No cards found.</p>
|
||||
<div v-if="results.length" class="results">
|
||||
<button
|
||||
v-for="card in results"
|
||||
:key="card.oracle_id"
|
||||
type="button"
|
||||
:disabled="busy"
|
||||
:title="`Use ${card.name} as your playmat`"
|
||||
@click="choose(card)"
|
||||
>
|
||||
<img :src="`${apiBase}/cards/${card.oracle_id}/art`" :alt="card.name" loading="lazy">
|
||||
<span>{{ card.name }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<label class="field">
|
||||
<span class="muted">Upload an image</span>
|
||||
<input type="file" accept="image/*" :disabled="busy" @change="upload">
|
||||
</label>
|
||||
<p v-if="localError" class="error">{{ localError }}</p>
|
||||
<button
|
||||
type="button"
|
||||
class="remove"
|
||||
:disabled="busy || !current"
|
||||
@click="emit('select', { kind: 'none' })"
|
||||
>Remove playmat</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.playmat-picker {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.6rem;
|
||||
}
|
||||
|
||||
.preview {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
aspect-ratio: 16 / 7;
|
||||
max-height: 14rem;
|
||||
border: 1px dashed var(--line);
|
||||
border-radius: 6px;
|
||||
background: var(--panel-2) center / cover no-repeat;
|
||||
}
|
||||
|
||||
.field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.3rem;
|
||||
}
|
||||
|
||||
.field input[type="file"] {
|
||||
padding: 0.3rem;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.results {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 0.4rem;
|
||||
max-height: 18rem;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.results button {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.2rem;
|
||||
padding: 0.25rem;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.results img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
aspect-ratio: 626 / 457;
|
||||
border-radius: 4px;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.results span {
|
||||
overflow: hidden;
|
||||
font-size: 0.72rem;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.remove {
|
||||
align-self: flex-start;
|
||||
padding: 0.2rem 0.45rem;
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
</style>
|
||||
212
frontend/app/components/PseudoGuide.vue
Normal file
212
frontend/app/components/PseudoGuide.vue
Normal file
@@ -0,0 +1,212 @@
|
||||
<template>
|
||||
<section class="pseudo-guide">
|
||||
<header class="guide-head">
|
||||
<h2>Card pseudocode guide</h2>
|
||||
<p class="muted">
|
||||
The editor and the compiler use the same two-way format. The
|
||||
<strong>Visual</strong> tab is a node canvas: drag sockets to connect an ability to its
|
||||
effects, and drag green value nodes (players, targets, selectors, costs) into argument
|
||||
sockets. Selector <strong>OR</strong>/<strong>AND</strong> nodes can combine two selector
|
||||
slots. It writes the same source as the text editor. Use <strong>Draft with AI</strong> for
|
||||
a first pass, then review and save.
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<article>
|
||||
<h3>Shape</h3>
|
||||
<p>
|
||||
One ability per block. The header starts at column 0 and ends with a colon; effects are
|
||||
indented two spaces, one call per line. A leading <code># Card [status]</code> line is
|
||||
optional and ignored. Multi-face cards use <code>## Face Name [status]</code> sections in
|
||||
card order. Use <code>(no abilities)</code> for an empty face.
|
||||
</p>
|
||||
<pre># Soul Warden [supported]
|
||||
on enters(each other creature):
|
||||
gain_life(you, 1)
|
||||
|
||||
# Llanowar Elves [supported]
|
||||
activate {T}:
|
||||
add_mana(you, {G})</pre>
|
||||
</article>
|
||||
|
||||
<article>
|
||||
<h3>Ability blocks</h3>
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th>Header</th><th>Example</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr><td><code>on <trigger>:</code></td><td><code>on dies(this):</code></td></tr>
|
||||
<tr><td><code>activate <cost>:</code></td><td><code>activate {2}, {T}:</code></td></tr>
|
||||
<tr><td><code>static:</code></td><td><code>static:</code></td></tr>
|
||||
<tr><td><code>spell:</code></td><td>An instant or sorcery effect line.</td></tr>
|
||||
<tr><td><code>keyword <name></code></td><td><code>keyword Flying</code></td></tr>
|
||||
<tr><td><code>keywords <a>, <b></code></td><td><code>keywords Flying, vigilance</code></td></tr>
|
||||
<tr><td><code>additional cost: <cost></code></td><td><code>additional cost: pay 2 life</code></td></tr>
|
||||
<tr><td><code>if <condition>:</code></td><td>Nested effects, indented below.</td></tr>
|
||||
<tr><td><code>choose <n>:</code></td><td>Numbered modes <code>1.</code>, <code>2.</code></td></tr>
|
||||
<tr><td><code>schedule(next_upkeep):</code></td><td>Delayed effects.</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</article>
|
||||
|
||||
<article>
|
||||
<h3>Effect calls</h3>
|
||||
<p>Effects are lowercase calls. Separate several on one line with <code>;</code>.</p>
|
||||
<pre>damage(target creature, 3)
|
||||
draw(you, 2)
|
||||
gain_life(you, 1)
|
||||
create_token(you, 1, 1/1 red goblin creature)
|
||||
put_counters(target creature, +1/+1, 2)
|
||||
destroy(target creature)
|
||||
exile(target artifact you control)
|
||||
add_mana(you, {G}{G})
|
||||
search(you, creature, 1, to hand, shuffle)
|
||||
scry(you, 2)
|
||||
pump(each creature you control, 1/1, until end of turn)</pre>
|
||||
</article>
|
||||
|
||||
<article>
|
||||
<h3>Targets, values and costs</h3>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>Targets</th>
|
||||
<td><code>this</code>, <code>the triggering object</code>, <code>target creature</code>, <code>each opponent</code>, <code>up to 2 target creatures</code>, <code>any target</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Selectors</th>
|
||||
<td><code>other tapped creature you control</code>, <code>red instant from a graveyard</code>, <code>creature with power 4 or greater</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Values</th>
|
||||
<td><code>2</code>, <code>X</code>, <code>count(creature you control)</code>, <code>its power</code>, <code>that much</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Costs</th>
|
||||
<td><code>{2}{U}</code>, <code>{T}</code>, <code>pay 3 life</code>, <code>discard 1 card(s)</code>, <code>sacrifice this</code>, <code>remove 1 +1/+1 counter(s) from this</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Durations</th>
|
||||
<td><code>until end of turn</code>, <code>until your next turn</code>, <code>until the end of your next turn</code>, <code>for as long as this remains on the battlefield</code></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</article>
|
||||
|
||||
<article>
|
||||
<h3>Triggers, conditions and modes</h3>
|
||||
<pre>on attacks(this):
|
||||
create_token(you, 1, tapped 1/1 red goblin creature)
|
||||
|
||||
on upkeep(you):
|
||||
if you control at least 3 artifacts:
|
||||
draw(you, 1)
|
||||
|
||||
spell:
|
||||
choose 1:
|
||||
1. draw(you, 2)
|
||||
2. gain_life(you, 3)
|
||||
|
||||
static:
|
||||
grant(each creature you control, Flying)</pre>
|
||||
<p class="muted">
|
||||
Common triggers: <code>enters</code>, <code>dies</code>, <code>attacks</code>,
|
||||
<code>upkeep</code>, <code>end_step</code>, <code>cast</code>,
|
||||
<code>deals_damage</code>. Always check the generated line after saving.
|
||||
</p>
|
||||
</article>
|
||||
|
||||
<article>
|
||||
<h3>When the syntax cannot express it</h3>
|
||||
<p>
|
||||
Never guess a wrong effect. Use the preserved form and leave the line unsupported:
|
||||
</p>
|
||||
<pre>unsupported (modal bullet outside a choose block): Choose one — ...</pre>
|
||||
<p class="muted">
|
||||
The full reference lives in <code>backend/docs/card-effects.md</code>.
|
||||
</p>
|
||||
</article>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.pseudo-guide {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 8px;
|
||||
padding: 1rem 1.25rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.25rem;
|
||||
}
|
||||
|
||||
.guide-head {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
h3 {
|
||||
margin-bottom: 0.4rem;
|
||||
}
|
||||
|
||||
p {
|
||||
line-height: 1.5;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
||||
font-size: 0.85em;
|
||||
background: #11151d;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 4px;
|
||||
padding: 0.05rem 0.3rem;
|
||||
}
|
||||
|
||||
pre {
|
||||
margin: 0.5rem 0 0;
|
||||
padding: 0.65rem 0.8rem;
|
||||
background: #11151d;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 6px;
|
||||
overflow-x: auto;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
||||
font-size: 0.82rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
th,
|
||||
td {
|
||||
border-bottom: 1px solid var(--line);
|
||||
padding: 0.35rem 0.5rem;
|
||||
text-align: left;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
th {
|
||||
white-space: nowrap;
|
||||
color: var(--muted);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
tbody th {
|
||||
width: 7rem;
|
||||
}
|
||||
|
||||
@media (max-width: 800px) {
|
||||
tbody th {
|
||||
width: auto;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
27
frontend/app/components/SymbolText.vue
Normal file
27
frontend/app/components/SymbolText.vue
Normal file
@@ -0,0 +1,27 @@
|
||||
<script setup lang="ts">
|
||||
const props = defineProps<{ text?: string }>()
|
||||
|
||||
/** Runs of {symbols} render through ManaCost; everything else stays text. */
|
||||
const parts = computed(() => (props.text ?? '')
|
||||
.split(/((?:\{[^}]+\})+)/)
|
||||
.filter(Boolean))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<span class="symbol-text">
|
||||
<template v-for="(part, index) in parts" :key="index">
|
||||
<ManaCost v-if="part.startsWith('{')" :cost="part" />
|
||||
<template v-else>{{ part }}</template>
|
||||
</template>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.symbol-text {
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.symbol-text :deep(.mana-cost) {
|
||||
vertical-align: -0.15em;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user