Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions client/src/core/components/ResizingTextArea.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<script setup lang="ts">
import { nextTick, onMounted, useTemplateRef, watch } from "vue";

import { getTarget, getValue } from "../utils";

const { visible = true, disabled = false } = defineProps<{ visible?: boolean; disabled?: boolean }>();
const textArea = useTemplateRef("textarea");
const emit = defineEmits<(e: "change", s: string) => void>();
const text = defineModel<string>({ required: true });

onMounted(async () => {
await nextTick(() => {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
if (visible ?? true) resizeTextArea(textArea.value!);
});
});

watch([() => visible, () => text.value], async () => {
if (visible) {
// vue-tsc and eslint disagree on this assertion
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
await nextTick(() => resizeTextArea(textArea.value!));
}
});

function resizeTextArea(element: HTMLElement): void {
element.style.height = "auto";
element.style.height = `${element.scrollHeight}px`;
}
</script>

<template>
<div class="grow-wrapper">
<textarea
ref="textarea"
v-model="text"
type="text"
:disabled="disabled"
rows="1"
@input="resizeTextArea(getTarget($event))"
@change="emit('change', getValue($event))"
@keyup.enter="getTarget($event).blur()"
@keydown.enter.prevent
/>
</div>
</template>

<style scoped lang="scss">
.grow-wrapper {
display: flex;
flex-grow: 1;
width: 100%;
> textarea {
flex-grow: 1;
width: 100%;
min-height: 1.5em;
height: auto;
border: none;
resize: none;
font-family: inherit;
font-size: 11pt;
overflow: hidden;
white-space: pre-wrap;
word-wrap: break-word;
background: rgb(1, 1, 1, 0);
border-radius: 0.25em;
text-align: right;
padding: 0;
margin: 0;
}
}
</style>
39 changes: 27 additions & 12 deletions client/src/game/ui/initiative/Initiative.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { type DraggableEvent, VueDraggable } from "vue-draggable-plus";
import { useI18n } from "vue-i18n";

import Modal from "../../../core/components/modals/Modal.vue";
import ResizingTextArea from "../../../core/components/ResizingTextArea.vue";
import RollingCounter from "../../../core/components/RollingCounter.vue";
import { baseAdjust } from "../../../core/http";
import type { GlobalId } from "../../../core/id";
Expand Down Expand Up @@ -525,16 +526,11 @@ function n(e: any): number {
:key="`${actor.globalId}-${e}`"
class="initiative-effect-info"
>
<input
<ResizingTextArea
v-model="effect.name"
type="text"
style="width: 100px"
:class="{ disabled: !owns(actor.globalId) }"
:disabled="!owns(actor.globalId)"
@change="
setEffectName(actor.globalId, n(e), getValue($event))
"
@keyup.enter="getTarget($event).blur()"
:visible="initiativeStore.state.showInitiative"
@change="setEffectName(actor.globalId, n(e), $event)"
/>
<input
v-if="effect.turns !== null"
Expand Down Expand Up @@ -983,7 +979,7 @@ function n(e: any): number {
display: flex;
flex-direction: column;
width: -moz-fit-content;
width: 11.1em;
width: 15em;
margin-right: 5px;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
Expand All @@ -1008,23 +1004,42 @@ function n(e: any): number {
box-shadow: -2px 5px 6px -6px rgba(0, 0, 0, 0.75);
scrollbar-color: #e1eae5 #82c8a0;
}
> .initiative-effect-info:not(:nth-last-child(1 of .initiative-effect-info)) {
z-index: 1;
&::before {
opacity: 1;
}
}
}

.initiative-effect-info {
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: center;
padding-left: 5px;
position: relative;
z-index: 1;
&::before {
position: absolute;
content: "";
border-bottom: solid 1px rgb(0, 0, 0, 0.25);
top: 0;
right: 0;
bottom: 0;
left: 0;
mask-image: linear-gradient(to right, transparent 0%, #000000ff 15%, #000000ff 95%, transparent 100%);
z-index: -1;
opacity: 0;
transition: all 0.3s ease;
}

> * {
border: none;
background-color: inherit;
text-align: right;
margin: 0 3px;

&:first-child {
margin-left: 0;
}
&:last-child {
margin-right: 0;
}
Expand Down
Loading