chromatic-lattice/src/components/features/Milestone.vue
thepaperpilot 0afcd1cd3d First pass at typescript support
Oh man did this end up requiring a *ton* of other work as well.
There's still a few typing issues I still can't quite work out,
and others I'd like to improve when I have time. In fact, this version
doesn't even really work, it has a stack overflow error caused by
a tooltip for some reason have a tree inside it, which in turn has
another tooltip, etc. There's also 17 errors that I *really* feel like
shouldn't be there, but they are, and 113 warnings - mostly using !
to assert that things are non-null. Lots of work left to do, to sum up.

The reason I'm committing this now is because I really need to get to
work on my game jam, and since it won't use a tree or really many of
TMT-X's features, I can get away with using a broken engine :)
2021-08-16 23:30:54 -05:00

76 lines
2.3 KiB
Vue

<template>
<div
v-if="milestone.shown"
:style="style"
:class="{ feature: true, milestone: true, done: milestone.earned }"
>
<div v-if="requirementDisplay"><component :is="requirementDisplay" /></div>
<div v-if="effectDisplay"><component :is="effectDisplay" /></div>
<component v-if="optionsDisplay" :is="optionsDisplay" />
<branch-node :branches="milestone.branches" :id="id" featureType="milestone" />
</div>
</template>
<script lang="ts">
import { layers } from "@/game/layers";
import { Milestone } from "@/typings/features/milestone";
import { coerceComponent, InjectLayerMixin } from "@/util/vue";
import { Component, defineComponent } from "vue";
export default defineComponent({
name: "milestone",
mixins: [InjectLayerMixin],
props: {
id: {
type: [Number, String],
required: true
}
},
computed: {
milestone(): Milestone {
return layers[this.layer].milestones!.data[this.id];
},
style(): Array<Partial<CSSStyleDeclaration> | undefined> {
return [layers[this.layer].componentStyles?.milestone, this.milestone.style];
},
requirementDisplay(): Component | string | null {
if (this.milestone.requirementDisplay) {
return coerceComponent(this.milestone.requirementDisplay, "h3");
}
return null;
},
effectDisplay(): Component | string | null {
if (this.milestone.effectDisplay) {
return coerceComponent(this.milestone.effectDisplay, "b");
}
return null;
},
optionsDisplay(): Component | string | null {
if (this.milestone.optionsDisplay && this.milestone.earned) {
return coerceComponent(this.milestone.optionsDisplay, "div");
}
return null;
}
}
});
</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;
}
</style>