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

80 lines
2.2 KiB
Vue
Raw Normal View History

2021-06-12 04:38:16 +00:00
<template>
<div
v-if="unref(visibility) !== Visibility.None"
:style="[
{
visibility: unref(visibility) === Visibility.Hidden ? 'hidden' : undefined,
backgroundImage: (earned && image && `url(${image})`) || ''
},
unref(style) ?? []
]"
:class="{
feature: true,
achievement: true,
locked: !unref(earned),
bought: unref(earned),
...unref(classes)
}"
2022-01-14 04:25:47 +00:00
>
<component v-if="component" :is="component" />
<MarkNode :mark="unref(mark)" />
<LinkNode :id="id" />
</div>
2021-06-12 04:38:16 +00:00
</template>
2022-01-25 04:25:34 +00:00
<script lang="ts">
2022-03-04 03:39:48 +00:00
import { CoercableComponent, Visibility } from "features/feature";
import { computeOptionalComponent, processedPropType } from "util/vue";
import { defineComponent, StyleValue, toRefs, unref } from "vue";
2022-03-04 03:39:48 +00:00
import Tooltip from "components/Tooltip.vue";
import LinkNode from "components/links/LinkNode.vue";
import MarkNode from "components/MarkNode.vue";
import "components/common/features.css";
2021-06-12 04:38:16 +00:00
2022-01-25 04:25:34 +00:00
export default defineComponent({
props: {
visibility: {
type: processedPropType<Visibility>(Number),
2022-01-25 04:25:34 +00:00
required: true
},
display: processedPropType<CoercableComponent>(Object, String, Function),
2022-01-25 04:25:34 +00:00
earned: {
type: processedPropType<boolean>(Boolean),
2022-01-25 04:25:34 +00:00
required: true
},
image: processedPropType<string>(String),
style: processedPropType<StyleValue>(String, Object, Array),
classes: processedPropType<Record<string, boolean>>(Object),
mark: processedPropType<boolean | string>(Boolean, String),
2022-01-25 04:25:34 +00:00
id: {
type: String,
required: true
}
},
components: {
LinkNode,
MarkNode,
Tooltip
},
2022-01-25 04:25:34 +00:00
setup(props) {
const { display } = toRefs(props);
2022-01-14 04:25:47 +00:00
2022-01-25 04:25:34 +00:00
return {
component: computeOptionalComponent(display),
unref,
2022-01-25 04:25:34 +00:00
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>