28 lines
631 B
Vue
28 lines
631 B
Vue
<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>
|