2021-06-11 23:38:16 -05:00
|
|
|
<template>
|
2022-02-27 13:49:34 -06:00
|
|
|
<div
|
|
|
|
v-if="unref(visibility) !== Visibility.None"
|
|
|
|
:style="{ visibility: unref(visibility) === Visibility.Hidden ? 'hidden' : undefined }"
|
|
|
|
>
|
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
|
|
|
<button
|
2022-02-27 13:49:34 -06:00
|
|
|
:style="unref(style)"
|
2022-01-13 22:25:47 -06:00
|
|
|
@click="onClick"
|
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
|
|
|
@mousedown="start"
|
|
|
|
@mouseleave="stop"
|
|
|
|
@mouseup="stop"
|
|
|
|
@touchstart="start"
|
|
|
|
@touchend="stop"
|
|
|
|
@touchcancel="stop"
|
|
|
|
:class="{
|
|
|
|
feature: true,
|
|
|
|
clickable: true,
|
2022-02-27 13:49:34 -06:00
|
|
|
can: unref(canClick),
|
|
|
|
locked: !unref(canClick),
|
2022-01-13 22:25:47 -06:00
|
|
|
small,
|
2022-02-27 13:49:34 -06:00
|
|
|
...unref(classes)
|
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
|
|
|
}"
|
|
|
|
>
|
2022-02-27 13:49:34 -06:00
|
|
|
<component v-if="unref(comp)" :is="unref(comp)" />
|
|
|
|
<MarkNode :mark="unref(mark)" />
|
2022-01-13 22:25:47 -06:00
|
|
|
<LinkNode :id="id" />
|
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
|
|
|
</button>
|
|
|
|
</div>
|
2021-06-11 23:38:16 -05:00
|
|
|
</template>
|
|
|
|
|
2022-01-24 22:25:34 -06:00
|
|
|
<script lang="tsx">
|
2022-03-03 21:39:48 -06:00
|
|
|
import "components/common/features.css";
|
|
|
|
import LinkNode from "components/links/LinkNode.vue";
|
|
|
|
import MarkNode from "components/MarkNode.vue";
|
|
|
|
import { GenericClickable } from "features/clickables/clickable";
|
|
|
|
import { jsx, StyleValue, Visibility } from "features/feature";
|
2022-02-27 13:49:34 -06:00
|
|
|
import {
|
|
|
|
coerceComponent,
|
|
|
|
isCoercableComponent,
|
|
|
|
processedPropType,
|
|
|
|
setupHoldToClick,
|
|
|
|
unwrapRef
|
2022-03-03 21:39:48 -06:00
|
|
|
} from "util/vue";
|
2022-02-27 13:49:34 -06:00
|
|
|
import {
|
|
|
|
Component,
|
|
|
|
defineComponent,
|
|
|
|
PropType,
|
|
|
|
shallowRef,
|
|
|
|
toRefs,
|
|
|
|
unref,
|
|
|
|
UnwrapRef,
|
|
|
|
watchEffect
|
|
|
|
} from "vue";
|
2022-01-13 22:25:47 -06:00
|
|
|
|
2022-01-24 22:25:34 -06:00
|
|
|
export default defineComponent({
|
|
|
|
props: {
|
|
|
|
display: {
|
2022-02-27 13:49:34 -06:00
|
|
|
type: processedPropType<UnwrapRef<GenericClickable["display"]>>(
|
|
|
|
Object,
|
|
|
|
String,
|
|
|
|
Function
|
|
|
|
),
|
2022-01-24 22:25:34 -06:00
|
|
|
required: true
|
|
|
|
},
|
|
|
|
visibility: {
|
2022-02-27 13:49:34 -06:00
|
|
|
type: processedPropType<Visibility>(Number),
|
2022-01-24 22:25:34 -06:00
|
|
|
required: true
|
|
|
|
},
|
2022-02-27 13:49:34 -06:00
|
|
|
style: processedPropType<StyleValue>(Object, String, Array),
|
|
|
|
classes: processedPropType<Record<string, boolean>>(Object),
|
2022-01-24 22:25:34 -06:00
|
|
|
onClick: Function as PropType<VoidFunction>,
|
|
|
|
onHold: Function as PropType<VoidFunction>,
|
|
|
|
canClick: {
|
2022-02-27 13:49:34 -06:00
|
|
|
type: processedPropType<boolean>(Boolean),
|
2022-01-24 22:25:34 -06:00
|
|
|
required: true
|
|
|
|
},
|
|
|
|
small: Boolean,
|
2022-02-27 13:49:34 -06:00
|
|
|
mark: processedPropType<boolean | string>(Boolean, String),
|
2022-01-24 22:25:34 -06:00
|
|
|
id: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
2022-02-27 13:49:34 -06:00
|
|
|
components: {
|
|
|
|
LinkNode,
|
|
|
|
MarkNode
|
|
|
|
},
|
2022-01-24 22:25:34 -06:00
|
|
|
setup(props) {
|
|
|
|
const { display, onClick, onHold } = toRefs(props);
|
2021-06-11 23:38:16 -05:00
|
|
|
|
2022-02-27 13:49:34 -06:00
|
|
|
const comp = shallowRef<Component | string>("");
|
|
|
|
|
|
|
|
watchEffect(() => {
|
|
|
|
const currDisplay = unwrapRef(display);
|
2022-01-24 22:25:34 -06:00
|
|
|
if (currDisplay == null) {
|
2022-02-27 13:49:34 -06:00
|
|
|
comp.value = "";
|
|
|
|
return;
|
2022-01-24 22:25:34 -06:00
|
|
|
}
|
|
|
|
if (isCoercableComponent(currDisplay)) {
|
2022-02-27 13:49:34 -06:00
|
|
|
comp.value = coerceComponent(currDisplay);
|
|
|
|
return;
|
2022-01-24 22:25:34 -06:00
|
|
|
}
|
2022-02-27 13:49:34 -06:00
|
|
|
const Title = coerceComponent(currDisplay.title || "", "h3");
|
|
|
|
const Description = coerceComponent(currDisplay.description, "div");
|
|
|
|
comp.value = coerceComponent(
|
|
|
|
jsx(() => (
|
|
|
|
<span>
|
|
|
|
{currDisplay.title ? (
|
|
|
|
<div>
|
|
|
|
<Title />
|
|
|
|
</div>
|
|
|
|
) : null}
|
|
|
|
<Description />
|
|
|
|
</span>
|
|
|
|
))
|
2022-01-24 22:25:34 -06:00
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
const { start, stop } = setupHoldToClick(onClick, onHold);
|
|
|
|
|
|
|
|
return {
|
|
|
|
start,
|
|
|
|
stop,
|
2022-02-27 13:49:34 -06:00
|
|
|
comp,
|
|
|
|
Visibility,
|
|
|
|
unref
|
2022-01-24 22:25:34 -06:00
|
|
|
};
|
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
|
|
|
}
|
|
|
|
});
|
2021-06-11 23:38:16 -05:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
2021-06-24 22:15:10 -05:00
|
|
|
.clickable {
|
|
|
|
min-height: 120px;
|
|
|
|
width: 120px;
|
|
|
|
font-size: 10px;
|
|
|
|
}
|
2022-02-27 13:49:34 -06:00
|
|
|
|
|
|
|
.clickable.small {
|
|
|
|
min-height: unset;
|
|
|
|
}
|
2021-06-11 23:38:16 -05:00
|
|
|
</style>
|