2021-05-22 15:29:06 -05:00
|
|
|
<template>
|
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
|
|
|
<div class="field">
|
|
|
|
<span class="field-title" v-if="title">{{ title }}</span>
|
|
|
|
<vue-select
|
|
|
|
:options="options"
|
|
|
|
:model-value="value"
|
|
|
|
@update:modelValue="setSelected"
|
|
|
|
label-by="label"
|
|
|
|
:value-by="getValue"
|
|
|
|
:placeholder="placeholder"
|
|
|
|
:close-on-select="closeOnSelect"
|
|
|
|
/>
|
|
|
|
</div>
|
2021-05-22 15:29:06 -05:00
|
|
|
</template>
|
|
|
|
|
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
|
|
|
<script lang="ts">
|
|
|
|
import { defineComponent } from "vue";
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
name: "Select",
|
|
|
|
props: {
|
|
|
|
title: String,
|
|
|
|
options: Array, // https://vue-select.org/guide/options.html#options-prop
|
|
|
|
value: [String, Object],
|
|
|
|
default: [String, Object],
|
|
|
|
placeholder: String,
|
|
|
|
closeOnSelect: Boolean
|
|
|
|
},
|
|
|
|
emits: ["change"],
|
|
|
|
methods: {
|
|
|
|
setSelected(value: any) {
|
|
|
|
value = value || this.default;
|
|
|
|
this.$emit("change", value);
|
|
|
|
},
|
|
|
|
getValue(item?: { value: any }) {
|
|
|
|
return item?.value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2021-05-22 15:29:06 -05:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
2021-07-24 17:08:52 -05:00
|
|
|
.vue-select {
|
2021-05-22 15:29:06 -05:00
|
|
|
width: 50%;
|
2021-09-04 16:51:41 -05:00
|
|
|
border-radius: var(--border-radius);
|
2021-05-22 15:29:06 -05:00
|
|
|
}
|
|
|
|
|
2021-07-24 17:08:52 -05:00
|
|
|
.field-buttons .vue-select {
|
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
|
|
|
width: unset;
|
2021-05-22 15:29:06 -05:00
|
|
|
}
|
|
|
|
|
2021-07-24 17:08:52 -05:00
|
|
|
.vue-select,
|
|
|
|
.vue-dropdown {
|
2021-09-04 16:51:41 -05:00
|
|
|
border-color: var(--outline);
|
2021-05-22 15:29:06 -05:00
|
|
|
}
|
|
|
|
|
2021-07-24 17:08:52 -05:00
|
|
|
.vue-dropdown {
|
2021-09-04 16:51:41 -05:00
|
|
|
background: var(--raised-background);
|
2021-05-22 15:29:06 -05:00
|
|
|
}
|
|
|
|
|
2021-07-24 17:08:52 -05:00
|
|
|
.vue-dropdown-item {
|
2021-09-04 16:51:41 -05:00
|
|
|
color: var(--feature-foreground);
|
|
|
|
}
|
|
|
|
|
|
|
|
.vue-dropdown-item,
|
|
|
|
.vue-dropdown-item * {
|
|
|
|
transition-duration: 0s;
|
2021-05-22 15:29:06 -05:00
|
|
|
}
|
|
|
|
|
2021-07-24 17:08:52 -05:00
|
|
|
.vue-dropdown-item.highlighted {
|
2021-09-04 16:51:41 -05:00
|
|
|
background-color: var(--highlighted);
|
2021-05-22 15:29:06 -05:00
|
|
|
}
|
2021-06-20 23:29:55 -05:00
|
|
|
|
2021-07-24 17:08:52 -05:00
|
|
|
.vue-dropdown-item.selected,
|
|
|
|
.vue-dropdown-item.highlighted.selected {
|
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
|
|
|
background-color: var(--bought);
|
2021-06-20 23:29:55 -05:00
|
|
|
}
|
2021-09-04 16:51:41 -05:00
|
|
|
|
|
|
|
.vue-input input::placeholder {
|
|
|
|
color: var(--link);
|
|
|
|
}
|
2021-05-22 15:29:06 -05:00
|
|
|
</style>
|