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

95 lines
2.8 KiB
Vue
Raw Normal View History

2021-06-12 04:38:16 +00:00
<template>
<div
2022-01-14 04:25:47 +00:00
v-if="visibility !== Visibility.None"
v-show="visibility === Visibility.Visible"
:style="style"
2022-01-14 04:25:47 +00:00
:class="{ feature: true, milestone: true, done: earned, ...classes }"
>
2022-01-14 04:25:47 +00:00
<component v-if="component" :is="component" />
<LinkNode :id="id" />
</div>
2021-06-12 04:38:16 +00:00
</template>
2022-01-25 04:25:34 +00:00
<script lang="tsx">
import { StyleValue, Visibility } from "@/features/feature";
2022-01-14 04:25:47 +00:00
import { GenericMilestone } from "@/features/milestone";
import { coerceComponent, isCoercableComponent } from "@/util/vue";
2022-01-25 04:25:34 +00:00
import { computed, defineComponent, PropType, toRefs, UnwrapRef } from "vue";
2022-01-14 04:25:47 +00:00
import LinkNode from "../system/LinkNode.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: {
type: Object as PropType<UnwrapRef<GenericMilestone["display"]>>,
required: true
},
style: Object as PropType<StyleValue>,
classes: Object as PropType<Record<string, boolean>>,
earned: {
type: Boolean,
required: true
},
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
const component = computed(() => {
const currDisplay = display.value;
if (currDisplay == null) {
return null;
}
if (isCoercableComponent(currDisplay)) {
return coerceComponent(currDisplay);
}
return (
<span>
<component v-is={coerceComponent(currDisplay.requirement, "h3")} />
<div v-if={currDisplay.effectDisplay}>
{/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */}
<component v-is={coerceComponent(currDisplay.effectDisplay!, "b")} />
</div>
<div v-if={currDisplay.optionsDisplay}>
{/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */}
<component v-is={coerceComponent(currDisplay.optionsDisplay!, "span")} />
</div>
</span>
);
});
return {
component,
LinkNode,
Visibility
};
}
});
2021-06-12 04:38:16 +00:00
</script>
<style scoped>
.milestone {
width: calc(100% - 10px);
min-width: 120px;
padding-left: 5px;
padding-right: 5px;
min-height: 75px;
background-color: var(--locked);
border-width: 4px;
border-radius: 5px;
color: rgba(0, 0, 0, 0.5);
margin: 0;
}
.milestone.done {
background-color: var(--bought);
cursor: default;
2021-06-12 04:38:16 +00:00
}
</style>