Newer
Older

Дмитрий Малюгин
committed
<script setup lang="ts">
import { useElementSize, useTextareaAutosize } from '@vueuse/core';
import type { IText } from '@/app/interfaces/entities';
import { editEntity } from '@/app/helpers';

Дмитрий Малюгин
committed
interface Props {
entityData: IText;
}
const props = defineProps<Props>();
const entityData = ref(props.entityData);
const container = ref();

Дмитрий Малюгин
committed
const editTitle = () => {
editEntity({ ...entityData.value, title: entityData.value.title });

Дмитрий Малюгин
committed
};
const editText = () => {
editEntity({ ...entityData.value, text: entityData.value.text });
const { textarea, triggerResize } = useTextareaAutosize({ styleProp: 'minHeight' });
const { height: containerHeight } = useElementSize(container);

Дмитрий Малюгин
committed
</script>
<template>
<section
ref="container"
'entityContainer relative flex px-16',
{
'justify-start': entityData.entity_position === 'left',
'justify-center': entityData.entity_position === 'center',
'justify-end': entityData.entity_position === 'right'
}
]"
>
:class="[
{
'w-1/2': entityData.paragraph_size === 'half',
'w-full': entityData.paragraph_size === 'full'
}
]"
<EntityTitle
v-model:title="entityData.title"
:entityData="entityData"
@editTitle="editTitle"
/>
<div class="relative leading-none">
<textarea
ref="textarea"
v-model="entityData.text"
class="w-full indent-5 leading-normal resize-none outline-0"
:style="`font-size: ${entityData.font_size}px;`"
placeholder="Enter text..."
<div v-if="containerHeight < 145" class="aggregate transition-all h-0"></div>
</section>

Дмитрий Малюгин
committed
</template>
.entityContainer .speedDial {

Дмитрий Малюгин
committed
opacity: 0;
}
.entityContainer:hover .speedDial {

Дмитрий Малюгин
committed
opacity: 100;
}
.entityContainer:hover .aggregate {
height: 100px;
transition: all 0.2s ease-in-out;
}
input::placeholder {
font-weight: 400;
}