Profectus-Demo/src/components/features/Achievement.vue

76 lines
2 KiB
Vue
Raw Normal View History

2021-06-12 04:38:16 +00:00
<template>
2022-01-14 04:25:47 +00:00
<Tooltip
v-if="visibility !== Visibility.None"
v-show="visibility === Visibility.Visible"
:display="tooltip"
>
<div
2022-01-14 04:25:47 +00:00
:style="[{ backgroundImage: (earned && image && `url(${image})`) || '' }, style ?? []]"
:class="{
feature: true,
achievement: true,
2022-01-14 04:25:47 +00:00
locked: !earned,
bought: earned,
...classes
}"
>
2022-01-14 04:25:47 +00:00
<component v-if="component" :is="component" />
<MarkNode :mark="mark" />
<LinkNode :id="id" />
</div>
2022-01-14 04:25:47 +00:00
</Tooltip>
2021-06-12 04:38:16 +00:00
</template>
2022-01-25 04:25:34 +00:00
<script lang="ts">
import { CoercableComponent, Visibility } from "@/features/feature";
2022-01-14 04:25:47 +00:00
import { coerceComponent } from "@/util/vue";
2022-01-25 04:25:34 +00:00
import { computed, defineComponent, PropType, StyleValue, toRefs } from "vue";
2022-01-14 04:25:47 +00:00
import LinkNode from "../system/LinkNode.vue";
import MarkNode from "./MarkNode.vue";
2021-06-12 04:38:16 +00:00
2022-01-25 04:25:34 +00:00
export default defineComponent({
props: {
visibility: {
type: Object as PropType<Visibility>,
required: true
},
display: [Object, String] as PropType<CoercableComponent>,
tooltip: [Object, String] as PropType<CoercableComponent>,
earned: {
type: Boolean,
required: true
},
image: String,
style: Object as PropType<StyleValue>,
classes: Object as PropType<Record<string, boolean>>,
mark: [Boolean, String],
id: {
type: String,
required: true
}
},
setup(props) {
const { display } = toRefs(props);
2022-01-14 04:25:47 +00:00
2022-01-25 04:25:34 +00:00
return {
component: computed(() => {
return display.value && coerceComponent(display.value);
}),
LinkNode,
MarkNode,
Visibility
};
}
});
2021-06-12 04:38:16 +00:00
</script>
<style scoped>
.achievement {
height: 90px;
width: 90px;
font-size: 10px;
color: white;
text-shadow: 0 0 2px #000000;
}
</style>