Files
NSG_PORTAL_V2/components/dynamic-page/page-component/templates/articles/cards/VideoBackground.vue
T

139 lines
4.2 KiB
Vue
Raw Normal View History

2024-07-01 15:14:17 +07:00
<script lang="ts" setup>
import { enumPageComponentTemplates } from "@/definitions/enum";
import { DEFAULT_QUERY_DROP, getInputValue } from "@/utils/parseSQL";
2024-07-02 16:03:24 +07:00
import { getResource } from "@/utils/resourceHandler";
2024-07-01 15:14:17 +07:00
const props = defineProps<{
dataResult?: any;
dataType?: any;
dataQuery?: any;
layout?: string;
2024-07-10 17:39:38 +07:00
label?: string;
component?: any;
2024-07-01 15:14:17 +07:00
}>();
const LAYOUT_PARSE = computed(() => {
const designObject = props.label ? getInputValue(props.label, "OBJECT") : {};
return Object.assign({}, designObject);
});
2024-07-10 17:39:38 +07:00
const emit = defineEmits(["selectComponent", "dropData"]);
const selectComponent = () => {
emit("selectComponent");
};
2024-07-01 15:14:17 +07:00
const parseData = computed(() => {
if (!props.dataResult) return;
const result = getInputValue(props.dataResult, "OBJECT");
return result;
});
2024-07-02 16:03:24 +07:00
2024-07-10 17:39:38 +07:00
const drop = (e: any) => {
if (e.dataTransfer.getData(`${enumPageComponentTemplates.ARTICLE}`)) {
const data = e.dataTransfer.getData(`${enumPageComponentTemplates.ARTICLE}`);
const { dataType, dataResult } = JSON.parse(data);
const dataQuery = DEFAULT_QUERY_DROP(dataType, dataResult.id);
emit("dropData", {
dataType,
dataResult,
dataQuery: dataQuery,
});
}
};
2024-07-01 15:14:17 +07:00
</script>
2024-07-10 17:39:38 +07:00
2024-07-01 15:14:17 +07:00
<template>
2024-07-10 17:39:38 +07:00
<article :id="`cpn_${props.component?.id}`" class="basic-article border-custom" :class="LAYOUT_PARSE['article_Class']" @click="selectComponent" @dragover.prevent @drop.stop.prevent="drop" :style="LAYOUT_PARSE['article']">
2024-07-02 16:03:24 +07:00
<div class="article_video">
2024-07-01 15:14:17 +07:00
<template v-if="parseData">
2024-07-10 17:39:38 +07:00
<div class="article_video_thumb article-thumbnail" :style="{ backgroundImage: `url('${parseData.thumbnail ? parseData.thumbnail : '/images/default-thumbnail.jpg'}')` }">
<div></div>
<div class="article_video_content">
<span>
<svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M23.5 18.5C24.375 17.875 25.625 17.875 26.5 18.5L44.5 29.5C45.375 30 46 31 46 32C46 33.125 45.375 34.125 44.5 34.625L26.5 45.625C25.625 46.125 24.375 46.25 23.5 45.625C22.5 45.125 22 44.125 22 43V21C22 20 22.5 19 23.5 18.5ZM64 32C64 49.75 49.625 64 32 64C14.25 64 0 49.75 0 32C0 14.375 14.25 0 32 0C49.625 0 64 14.375 64 32ZM32 6C17.625 6 6 17.75 6 32C6 46.375 17.625 58 32 58C46.25 58 58 46.375 58 32C58 17.75 46.25 6 32 6Z"
fill="#ED1C24"
/>
</svg>
</span>
<h3 class="line-clamp article-title" :class="LAYOUT_PARSE['title_Class']" :style="LAYOUT_PARSE['h3.title']">
{{ parseData.title?.replace(/<[^>]+>/g, "") }}
</h3>
<p class="mb-0 line-clamp article-intro" :class="LAYOUT_PARSE['paragraph_Class']" :style="LAYOUT_PARSE['p.paragraph']">
{{ parseData.intro?.replace(/<[^>]+>/g, "") }}
</p>
2024-07-06 18:29:38 +07:00
</div>
2024-07-10 17:39:38 +07:00
</div>
2024-07-01 15:14:17 +07:00
</template>
2024-07-10 17:39:38 +07:00
<div v-else class="empty-box">
<div class="d-flex justify-content-center align-items-center flex-column">
<i class="ri-play-circle-line"></i>
</div>
</div>
2024-07-01 15:14:17 +07:00
</div>
2024-07-10 17:39:38 +07:00
<div v-html="LAYOUT_PARSE.styleClasses" v-if="LAYOUT_PARSE.styles"></div>
2024-07-01 15:14:17 +07:00
</article>
</template>
<style lang="scss" scoped>
2024-07-10 17:39:38 +07:00
.article_video {
.article_video_thumb {
background-size: cover;
background-repeat: no-repeat;
background-position: center;
position: relative;
z-index: 0;
padding: 120px 85px 60px 85px;
border-radius: 2px;
margin: 10px;
cursor: pointer;
&::after {
content: "";
position: absolute;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.4);
z-index: 1;
top: 0px;
left: 0px;
}
.article_video_content {
position: relative;
z-index: 2;
2024-07-01 15:14:17 +07:00
2024-07-10 17:39:38 +07:00
h3 {
font-size: 44px;
font-weight: 700;
line-height: 57.2px;
text-align: left;
margin-bottom: 12px;
color: white;
}
2024-07-01 15:14:17 +07:00
2024-07-10 17:39:38 +07:00
p {
font-size: 14px;
font-weight: 400;
color: white;
}
2024-07-01 15:14:17 +07:00
2024-07-10 17:39:38 +07:00
i {
font-size: 80px;
color: #ed1c24;
}
}
}
.empty-box {
background-color: #409eff;
margin: 10px;
min-height: 60px;
i {
font-size: 60px;
2024-07-01 15:14:17 +07:00
}
2024-07-10 17:39:38 +07:00
}
}
2024-07-01 15:14:17 +07:00
</style>