First commit

This commit is contained in:
2026-10-27 12:42:57 +01:00
commit 7dd9f4b14d
74 changed files with 33018 additions and 0 deletions

View 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>