| 1 |
<script lang="ts" setup> |
| 2 |
import Card from "@/components/Card.vue"; |
| 3 |
import Toggle from "@/components/Toggle.vue"; |
| 4 |
import CopyField from "@/components/CopyField.vue"; |
| 5 |
import { SectionItem } from "@/types"; |
| 6 |
import Button from "@/components/Button/Button.vue"; |
| 7 |
import SkeletonLoader from "@/components/Loaders/SkeletonLoader.vue"; |
| 8 |
|
| 9 |
type Props = { |
| 10 |
title: string; |
| 11 |
isLoading?: boolean; |
| 12 |
sectionItems: SectionItem[]; |
| 13 |
}; |
| 14 |
|
| 15 |
type Emits = { |
| 16 |
"save-section": [value: boolean, item: SectionItem]; |
| 17 |
}; |
| 18 |
|
| 19 |
const props = defineProps<Props>(); |
| 20 |
const emit = defineEmits<Emits>(); |
| 21 |
</script> |
| 22 |
|
| 23 |
<template> |
| 24 |
<div class="home-section"> |
| 25 |
<Card v-if="isLoading"> |
| 26 |
<SkeletonLoader class="h-mb-24" width="50%" :height="24" rounded /> |
| 27 |
<SkeletonLoader |
| 28 |
v-for="(item, index) in sectionItems" |
| 29 |
:class="{ 'h-mb-24': index !== sectionItems.length - 1 }" |
| 30 |
width="100%" |
| 31 |
:height="item.copyLink ? 48 : 24" |
| 32 |
rounded |
| 33 |
/> |
| 34 |
</Card> |
| 35 |
<Card v-else :header="props.title"> |
| 36 |
<div |
| 37 |
class="home-section__section-item" |
| 38 |
v-for="item in sectionItems" |
| 39 |
:key="item.title" |
| 40 |
> |
| 41 |
<div class="d-flex flex-direction-column"> |
| 42 |
<div class="d-flex align-items-center justify-content-between w-100"> |
| 43 |
<div class="d-flex flex-column"> |
| 44 |
<h3 class="h-m-0" item.title>{{ item.title }}</h3> |
| 45 |
<p class="h-m-0 text-body-2"> |
| 46 |
{{ item.description }} |
| 47 |
</p> |
| 48 |
</div> |
| 49 |
<Button |
| 50 |
@click="item.sideButton?.onClick" |
| 51 |
v-if="item.sideButton?.text" |
| 52 |
variant="text" |
| 53 |
>{{ item.sideButton?.text }}</Button |
| 54 |
> |
| 55 |
|
| 56 |
<Toggle |
| 57 |
v-else-if="item.toggleValue !== undefined" |
| 58 |
class="h-pl-16" |
| 59 |
:model-value="Boolean(item.toggleValue)" |
| 60 |
:bind="false" |
| 61 |
@click="emit('save-section', Boolean(!item.toggleValue), item)" |
| 62 |
/> |
| 63 |
</div> |
| 64 |
</div> |
| 65 |
<CopyField class="h-mt-16" v-if="item.copyLink" :link="item.copyLink" /> |
| 66 |
</div> |
| 67 |
</Card> |
| 68 |
</div> |
| 69 |
</template> |
| 70 |
|
| 71 |
<style lang="scss"> |
| 72 |
.home-section { |
| 73 |
&__section-item { |
| 74 |
margin-top: 16px; |
| 75 |
flex-direction: column; |
| 76 |
display: flex; |
| 77 |
padding-bottom: 16px; |
| 78 |
border-bottom: 1px solid var(--gray-border); |
| 79 |
|
| 80 |
&:last-child { |
| 81 |
margin-bottom: 0; |
| 82 |
border-bottom: none; |
| 83 |
padding-bottom: 0; |
| 84 |
} |
| 85 |
} |
| 86 |
} |
| 87 |
</style> |
| 88 |
|