133 lines
4.1 KiB
Vue
133 lines
4.1 KiB
Vue
<script setup lang="ts">
|
|
import type { University } from "~/types";
|
|
|
|
/**
|
|
* Карточка учебного заведения на странице «Вузы».
|
|
* Вступительный текст виден всегда, остальное содержимое скрыто до
|
|
* нажатия на полосу «Узнать подробнее». Клик вне карточки закрывает её —
|
|
* поведение перенесено из inline-скрипта vus.html.
|
|
*/
|
|
const props = defineProps<{ university: University }>();
|
|
|
|
const container = ref<HTMLElement | null>(null);
|
|
const open = ref(false);
|
|
|
|
const toggle = () => {
|
|
open.value = !open.value;
|
|
};
|
|
|
|
const handleOutsideClick = (event: MouseEvent) => {
|
|
if (!open.value) return;
|
|
const target = event.target as Node | null;
|
|
if (container.value && target && !container.value.contains(target)) {
|
|
open.value = false;
|
|
}
|
|
};
|
|
|
|
onMounted(() => {
|
|
document.addEventListener("click", handleOutsideClick);
|
|
});
|
|
|
|
onBeforeUnmount(() => {
|
|
document.removeEventListener("click", handleOutsideClick);
|
|
});
|
|
|
|
/** Класс обтекания изображения: float-start / float-end. */
|
|
const imageClass = (float?: "start" | "end") => (float ? `float-${float}` : "");
|
|
</script>
|
|
|
|
<template>
|
|
<div
|
|
:id="props.university.id"
|
|
ref="container"
|
|
class="container fon-vus image-container position-relative mb-3 hidden-on-scroll reveal"
|
|
:class="props.university.delay"
|
|
>
|
|
<div class="container-p-3">
|
|
<h2 class="text-center">{{ props.university.name }}</h2>
|
|
|
|
<!-- Первое изображение и вступительный текст всегда видимы -->
|
|
<div class="text-center mb-3">
|
|
<img
|
|
:src="`/assets/img/${props.university.heroImage}`"
|
|
class="img-fluid container_vizit_img"
|
|
:alt="props.university.heroImageAlt"
|
|
loading="lazy"
|
|
/>
|
|
</div>
|
|
<p
|
|
v-for="(paragraph, index) in props.university.intro"
|
|
:key="`intro-${index}`"
|
|
v-html="paragraph"
|
|
/>
|
|
|
|
<!-- Скрываемая до раскрытия часть -->
|
|
<div :id="props.university.contentId" :class="{ show: open }">
|
|
<template
|
|
v-for="(block, blockIndex) in props.university.blocks"
|
|
:key="`block-${blockIndex}`"
|
|
>
|
|
<div v-if="block.image" class="mb-3">
|
|
<img
|
|
:src="`/assets/img/${block.image}`"
|
|
:class="['img-fluid', 'container_img', imageClass(block.float)]"
|
|
:alt="block.imageAlt"
|
|
loading="lazy"
|
|
/>
|
|
<p
|
|
v-for="(paragraph, index) in block.paragraphs"
|
|
:key="`image-${blockIndex}-${index}`"
|
|
>
|
|
{{ paragraph }}
|
|
</p>
|
|
</div>
|
|
<template v-else>
|
|
<p
|
|
v-for="(paragraph, index) in block.paragraphs"
|
|
:key="`text-${blockIndex}-${index}`"
|
|
>
|
|
{{ paragraph }}
|
|
</p>
|
|
</template>
|
|
</template>
|
|
|
|
<p v-html="props.university.programsTitle" />
|
|
|
|
<SpecialtyTable
|
|
v-for="(table, tableIndex) in props.university.tables"
|
|
:key="`table-${tableIndex}`"
|
|
:table="table"
|
|
/>
|
|
|
|
<template v-if="props.university.extra">
|
|
<b>{{ props.university.extra.intro }}</b>
|
|
<template
|
|
v-for="(list, listIndex) in props.university.extra.lists"
|
|
:key="`list-${listIndex}`"
|
|
>
|
|
<b v-if="list.title">{{ list.title }}</b>
|
|
<ul>
|
|
<li
|
|
v-for="(item, itemIndex) in list.items"
|
|
:key="`item-${listIndex}-${itemIndex}`"
|
|
v-html="nl2br(item)"
|
|
/>
|
|
</ul>
|
|
</template>
|
|
</template>
|
|
</div>
|
|
</div>
|
|
|
|
<div
|
|
class="more-info-overlay d-flex align-items-center justify-content-center"
|
|
:data-open="String(open)"
|
|
role="button"
|
|
tabindex="0"
|
|
@click.stop="toggle"
|
|
@keydown.enter.prevent="toggle"
|
|
>
|
|
{{ open ? "Скрыть" : "Узнать подробнее" }}
|
|
</div>
|
|
</div>
|
|
</template>
|