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/Flag.vue

77 lines
2.2 KiB
Vue
Raw Normal View History

<template>
2021-04-01 09:35:39 -07:00
<span class="flag-wrapper">
<a v-if="link" :href="`/${config.nouns.route}/${config.nouns.terms.route}#${link.toLowerCase()}`" :title="alt">
<img :src="img" alt="" class="flag-mini rounded"/>
2021-04-05 08:03:13 -07:00
<Spelling :text="name"/><sup v-if="custom" class="text-muted"><small><Icon v="user"/></small></sup>
2021-04-01 09:35:39 -07:00
</a>
<span v-else :title="alt">
<img :src="img" alt="" class="flag-mini rounded"/>
2021-04-05 08:03:13 -07:00
<Spelling :text="name"/><sup v-if="custom" class="text-muted"><small><Icon v="user"/></small></sup>
2021-04-01 09:35:39 -07:00
</span>
<span class="flag-preview bg-white rouded p-2 border">
<img :src="img" alt="" class="rounded"/>
2021-04-05 08:03:13 -07:00
<span v-if="custom" class="alert alert-warning small d-inline-block mt-2 mb-0 p-2">
<Icon v="user"/>
<T>profile.flagsCustomWarning</T>
</span>
2021-04-01 09:35:39 -07:00
</span>
</span>
</template>
<script>
export default {
props: {
name: { required: true },
alt: { required: true },
img: { required: true },
2020-12-21 08:35:58 -08:00
terms: { },
2021-04-05 08:03:13 -07:00
custom: { type: Boolean },
2020-12-18 09:22:35 -08:00
},
computed: {
link() {
if (!this.config.nouns.terms.enabled) {
return null;
}
2020-12-21 08:35:58 -08:00
for (let term of this.terms || []) {
2020-12-18 09:22:35 -08:00
if (term.term.toLowerCase().includes(this.name.toLowerCase())) {
return this.name;
}
if (term.original.toLowerCase().includes(this.alt.toLowerCase())) {
return this.alt;
}
}
return null;
},
2020-12-08 14:14:40 -08:00
},
}
</script>
<style lang="scss" scoped>
2021-04-01 09:35:39 -07:00
.flag-mini {
height: 1rem;
}
2021-04-01 09:35:39 -07:00
.flag-wrapper {
position: relative;
.flag-preview {
position: absolute;
top: 1.5em;
left: 0;
z-index: 999;
display: none;
2021-04-05 08:03:13 -07:00
img {
max-height: 128px;
}
2021-04-01 09:35:39 -07:00
}
&:hover {
.flag-preview {
display: block;
}
}
}
</style>