2021-06-12 04:38:16 +00:00
|
|
|
<template>
|
2022-01-14 04:25:47 +00:00
|
|
|
<div
|
2022-02-27 19:49:34 +00:00
|
|
|
v-if="unref(visibility) !== Visibility.None"
|
|
|
|
:style="[
|
|
|
|
{
|
|
|
|
width: unref(width) + 'px',
|
|
|
|
height: unref(height) + 'px',
|
|
|
|
visibility: unref(visibility) === Visibility.Hidden ? 'hidden' : undefined
|
|
|
|
},
|
|
|
|
unref(style) ?? {}
|
|
|
|
]"
|
2022-01-14 04:25:47 +00:00
|
|
|
:class="{
|
|
|
|
bar: true,
|
2022-02-27 19:49:34 +00:00
|
|
|
...unref(classes)
|
2022-01-14 04:25:47 +00:00
|
|
|
}"
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
class="overlayTextContainer border"
|
2022-02-27 19:49:34 +00:00
|
|
|
:style="[
|
|
|
|
{ width: unref(width) + 'px', height: unref(height) + 'px' },
|
|
|
|
unref(borderStyle) ?? {}
|
|
|
|
]"
|
2022-01-14 04:25:47 +00:00
|
|
|
>
|
2022-07-07 15:39:29 +00:00
|
|
|
<span v-if="component" class="overlayText" :style="unref(textStyle)">
|
|
|
|
<component :is="component" />
|
|
|
|
</span>
|
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-17 04:30:54 +00:00
|
|
|
</div>
|
2022-01-14 04:25:47 +00:00
|
|
|
<div
|
|
|
|
class="border"
|
|
|
|
:style="[
|
2022-02-27 19:49:34 +00:00
|
|
|
{ width: unref(width) + 'px', height: unref(height) + 'px' },
|
|
|
|
unref(style) ?? {},
|
|
|
|
unref(baseStyle) ?? {},
|
|
|
|
unref(borderStyle) ?? {}
|
2022-01-14 04:25:47 +00:00
|
|
|
]"
|
|
|
|
>
|
2022-02-27 19:49:34 +00:00
|
|
|
<div class="fill" :style="[barStyle, unref(style) ?? {}, unref(fillStyle) ?? {}]" />
|
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-17 04:30:54 +00:00
|
|
|
</div>
|
2022-02-27 19:49:34 +00:00
|
|
|
<MarkNode :mark="unref(mark)" />
|
2022-03-20 18:57:45 +00:00
|
|
|
<Node :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-17 04:30:54 +00:00
|
|
|
</div>
|
2021-06-12 04:38:16 +00:00
|
|
|
</template>
|
|
|
|
|
2022-01-25 04:25:34 +00:00
|
|
|
<script lang="ts">
|
2022-03-04 03:39:48 +00:00
|
|
|
import MarkNode from "components/MarkNode.vue";
|
2022-06-27 00:17:22 +00:00
|
|
|
import Node from "components/Node.vue";
|
|
|
|
import { CoercableComponent, Visibility } from "features/feature";
|
|
|
|
import type { DecimalSource } from "util/bignum";
|
|
|
|
import Decimal from "util/bignum";
|
2022-05-01 03:08:29 +00:00
|
|
|
import { Direction } from "util/common";
|
2022-06-27 00:17:22 +00:00
|
|
|
import { computeOptionalComponent, processedPropType, unwrapRef } from "util/vue";
|
|
|
|
import type { CSSProperties, StyleValue } from "vue";
|
|
|
|
import { computed, defineComponent, toRefs, unref } from "vue";
|
2021-06-12 04:38:16 +00:00
|
|
|
|
2022-01-25 04:25:34 +00:00
|
|
|
export default defineComponent({
|
|
|
|
props: {
|
|
|
|
progress: {
|
2022-02-27 19:49:34 +00:00
|
|
|
type: processedPropType<DecimalSource>(String, Object, Number),
|
2022-01-25 04:25:34 +00:00
|
|
|
required: true
|
|
|
|
},
|
|
|
|
width: {
|
2022-02-27 19:49:34 +00:00
|
|
|
type: processedPropType<number>(Number),
|
2022-01-25 04:25:34 +00:00
|
|
|
required: true
|
|
|
|
},
|
|
|
|
height: {
|
2022-02-27 19:49:34 +00:00
|
|
|
type: processedPropType<number>(Number),
|
2022-01-25 04:25:34 +00:00
|
|
|
required: true
|
|
|
|
},
|
|
|
|
direction: {
|
2022-02-27 19:49:34 +00:00
|
|
|
type: processedPropType<Direction>(String),
|
2022-01-25 04:25:34 +00:00
|
|
|
required: true
|
|
|
|
},
|
2022-02-27 19:49:34 +00:00
|
|
|
display: processedPropType<CoercableComponent>(Object, String, Function),
|
2022-01-25 04:25:34 +00:00
|
|
|
visibility: {
|
2022-02-27 19:49:34 +00:00
|
|
|
type: processedPropType<Visibility>(Number),
|
2022-01-25 04:25:34 +00:00
|
|
|
required: true
|
|
|
|
},
|
2022-02-27 19:49:34 +00:00
|
|
|
style: processedPropType<StyleValue>(Object, String, Array),
|
|
|
|
classes: processedPropType<Record<string, boolean>>(Object),
|
|
|
|
borderStyle: processedPropType<StyleValue>(Object, String, Array),
|
|
|
|
textStyle: processedPropType<StyleValue>(Object, String, Array),
|
|
|
|
baseStyle: processedPropType<StyleValue>(Object, String, Array),
|
|
|
|
fillStyle: processedPropType<StyleValue>(Object, String, Array),
|
|
|
|
mark: processedPropType<boolean | string>(Boolean, String),
|
2022-01-25 04:25:34 +00:00
|
|
|
id: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
2022-02-27 19:49:34 +00:00
|
|
|
components: {
|
|
|
|
MarkNode,
|
2022-03-20 18:57:45 +00:00
|
|
|
Node
|
2022-02-27 19:49:34 +00:00
|
|
|
},
|
2022-01-25 04:25:34 +00:00
|
|
|
setup(props) {
|
|
|
|
const { progress, width, height, direction, display } = toRefs(props);
|
2022-01-14 04:25:47 +00:00
|
|
|
|
2022-01-25 04:25:34 +00:00
|
|
|
const normalizedProgress = computed(() => {
|
|
|
|
let progressNumber =
|
|
|
|
progress.value instanceof Decimal
|
|
|
|
? progress.value.toNumber()
|
|
|
|
: Number(progress.value);
|
|
|
|
return (1 - Math.min(Math.max(progressNumber, 0), 1)) * 100;
|
|
|
|
});
|
2022-01-14 04:25:47 +00:00
|
|
|
|
2022-01-25 04:25:34 +00:00
|
|
|
const barStyle = computed(() => {
|
|
|
|
const barStyle: Partial<CSSProperties> = {
|
2022-02-27 19:49:34 +00:00
|
|
|
width: unwrapRef(width) + 0.5 + "px",
|
|
|
|
height: unwrapRef(height) + 0.5 + "px"
|
2022-01-25 04:25:34 +00:00
|
|
|
};
|
|
|
|
switch (unref(direction)) {
|
|
|
|
case Direction.Up:
|
|
|
|
barStyle.clipPath = `inset(${normalizedProgress.value}% 0% 0% 0%)`;
|
2022-02-27 19:49:34 +00:00
|
|
|
barStyle.width = unwrapRef(width) + 1 + "px";
|
2022-01-25 04:25:34 +00:00
|
|
|
break;
|
|
|
|
case Direction.Down:
|
|
|
|
barStyle.clipPath = `inset(0% 0% ${normalizedProgress.value}% 0%)`;
|
2022-02-27 19:49:34 +00:00
|
|
|
barStyle.width = unwrapRef(width) + 1 + "px";
|
2022-01-25 04:25:34 +00:00
|
|
|
break;
|
|
|
|
case Direction.Right:
|
|
|
|
barStyle.clipPath = `inset(0% ${normalizedProgress.value}% 0% 0%)`;
|
|
|
|
break;
|
|
|
|
case Direction.Left:
|
|
|
|
barStyle.clipPath = `inset(0% 0% 0% ${normalizedProgress.value} + '%)`;
|
|
|
|
break;
|
|
|
|
case Direction.Default:
|
|
|
|
barStyle.clipPath = "inset(0% 50% 0% 0%)";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return barStyle;
|
|
|
|
});
|
2022-01-14 04:25:47 +00:00
|
|
|
|
2022-02-27 19:49:34 +00:00
|
|
|
const component = computeOptionalComponent(display);
|
2022-01-25 04:25:34 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
normalizedProgress,
|
|
|
|
barStyle,
|
|
|
|
component,
|
2022-02-27 19:49:34 +00:00
|
|
|
unref,
|
2022-01-25 04:25:34 +00:00
|
|
|
Visibility
|
|
|
|
};
|
|
|
|
}
|
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-17 04:30:54 +00:00
|
|
|
});
|
2021-06-12 04:38:16 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.bar {
|
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-17 04:30:54 +00:00
|
|
|
position: relative;
|
|
|
|
display: table;
|
2021-06-12 04:38:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.overlayTextContainer {
|
|
|
|
position: absolute;
|
|
|
|
border-radius: 10px;
|
|
|
|
vertical-align: middle;
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
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-17 04:30:54 +00:00
|
|
|
z-index: 3;
|
2021-06-12 04:38:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.overlayText {
|
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-17 04:30:54 +00:00
|
|
|
z-index: 6;
|
2021-06-12 04:38:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.border {
|
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-17 04:30:54 +00:00
|
|
|
border: 2px solid;
|
2021-06-12 04:38:16 +00:00
|
|
|
border-radius: 10px;
|
2021-09-04 21:51:41 +00:00
|
|
|
border-color: var(--foreground);
|
2021-06-12 04:38:16 +00:00
|
|
|
overflow: hidden;
|
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-17 04:30:54 +00:00
|
|
|
mask-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAA5JREFUeNpiYGBgAAgwAAAEAAGbA+oJAAAAAElFTkSuQmCC);
|
2021-06-12 04:38:16 +00:00
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.fill {
|
|
|
|
position: absolute;
|
2021-09-04 21:51:41 +00:00
|
|
|
background-color: var(--foreground);
|
2021-06-12 04:38:16 +00:00
|
|
|
overflow: hidden;
|
|
|
|
margin-left: -0.5px;
|
|
|
|
transition-duration: 0.2s;
|
|
|
|
z-index: 2;
|
|
|
|
}
|
|
|
|
</style>
|