2020-10-16 11:17:50 -07:00
|
|
|
<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">
|
2021-04-21 11:06:17 -07:00
|
|
|
<img :src="img" :alt="name" class="flag-mini rounded"/>
|
2021-04-12 07:44:33 -07:00
|
|
|
<Spelling escape :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">
|
2021-04-21 11:06:17 -07:00
|
|
|
<img :src="img" :alt="name" class="flag-mini rounded"/>
|
2021-04-12 07:44:33 -07:00
|
|
|
<Spelling escape :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">
|
2021-04-21 11:06:17 -07:00
|
|
|
<img :src="img" :alt="name" 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>
|
2020-10-16 11:17:50 -07:00
|
|
|
</span>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
name: { required: true },
|
2020-12-08 15:04:42 -08:00
|
|
|
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() {
|
2021-08-08 10:36:12 -07:00
|
|
|
if (!this.config.nouns.terms.enabled || !(this.config.nouns.terms.published || this.$isGranted('terms'))) {
|
2020-12-18 09:22:35 -08:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2020-12-21 08:35:58 -08:00
|
|
|
for (let term of this.terms || []) {
|
2021-08-08 10:36:12 -07:00
|
|
|
if (term.key && term.key.toLowerCase().includes(this.alt.toLowerCase())) {
|
2021-08-08 10:29:31 -07:00
|
|
|
return term.key;
|
|
|
|
}
|
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
|
|
|
},
|
2020-10-16 11:17:50 -07:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-04-01 09:35:39 -07:00
|
|
|
.flag-mini {
|
2020-10-16 11:17:50 -07:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-10-16 11:17:50 -07:00
|
|
|
</style>
|