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

65 lines
1.9 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-14 04:25:47 +00:00
<script setup lang="tsx">
import { FeatureComponent, Visibility } from "@/features/feature";
import { GenericMilestone } from "@/features/milestone";
import { coerceComponent, isCoercableComponent } from "@/util/vue";
import { computed, toRefs } from "vue";
import LinkNode from "../system/LinkNode.vue";
2021-06-12 04:38:16 +00:00
2022-01-14 04:25:47 +00:00
const props = toRefs(defineProps<FeatureComponent<GenericMilestone>>());
const component = computed(() => {
const display = props.display.value;
if (display == null) {
return null;
}
if (isCoercableComponent(display)) {
return coerceComponent(display);
}
2022-01-14 04:25:47 +00:00
return (
<span>
<component v-is={coerceComponent(display.requirement, "h3")} />
<div v-if={display.effectDisplay}>
{/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */}
<component v-is={coerceComponent(display.effectDisplay!, "b")} />
</div>
<div v-if={display.optionsDisplay}>
{/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */}
<component v-is={coerceComponent(display.optionsDisplay!, "span")} />
</div>
</span>
);
});
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>