This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Zaimki/components/Abbreviation.vue

41 lines
956 B
Vue
Raw Normal View History

2022-02-13 06:20:14 -08:00
<template>
<span>
<abbr v-if="abbr" :title="meaning">{{abbr}}</abbr><template v-if="abbr">&nbsp;</template><slot v-bind:abbr="abbr" v-bind:meaning="meaning" v-bind:word="word"></slot>
</span>
</template>
<script>
import { abbreviations } from '../src/data';
export default {
props: {
v: {required: true},
},
data() {
for (let abbr in abbreviations) {
if (!abbreviations.hasOwnProperty(abbr)) { continue; }
if (this.v.startsWith(abbr + ' ')) {
return {
abbr,
meaning: abbreviations[abbr],
word: this.v.substring(abbr.length + 1),
};
}
}
return {
abbr: null,
meaning: null,
word: this.v,
}
},
}
</script>
<style lang="scss" scoped>
@import "assets/variables";
abbr {
text-decoration-color: $text-muted;
}
</style>