2024-05-30 18:06:50 +07:00
|
|
|
<script setup lang="ts">
|
|
|
|
|
import RecusiveSection from "~/components/dynamic-page/page-section/RecusiveSection.vue";
|
|
|
|
|
import { enumPageSectionLayouts } from "~/definitions/enum";
|
|
|
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
|
layout?: string;
|
|
|
|
|
content?: any;
|
|
|
|
|
section: any;
|
|
|
|
|
}>();
|
|
|
|
|
|
|
|
|
|
const defineTypeRecusive = {
|
|
|
|
|
COMPONENT: "component",
|
|
|
|
|
SECTION: "section",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const SETTING_OPTIONS = computed(() => {
|
|
|
|
|
let _setting_options = {};
|
|
|
|
|
switch (props.layout) {
|
|
|
|
|
case enumPageSectionLayouts.VERTICAL_TWO:
|
|
|
|
|
_setting_options = {
|
|
|
|
|
MAX_ELEMENT: 2,
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
case enumPageSectionLayouts.VERTICAL_LEFT_TWO:
|
|
|
|
|
_setting_options = {
|
|
|
|
|
MAX_ELEMENT: 2,
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
case enumPageSectionLayouts.VERTICAL_RIGHT_TWO:
|
|
|
|
|
_setting_options = {
|
|
|
|
|
MAX_ELEMENT: 2,
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
case enumPageSectionLayouts.VERTICAL_THREE:
|
|
|
|
|
_setting_options = {
|
|
|
|
|
MAX_ELEMENT: 3,
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
case enumPageSectionLayouts.VERTICAL_FOUR:
|
|
|
|
|
_setting_options = {
|
|
|
|
|
MAX_ELEMENT: 4,
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
case enumPageSectionLayouts.HORIZONTAL_ONE:
|
|
|
|
|
_setting_options = {
|
|
|
|
|
MAX_ELEMENT: 1,
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
case enumPageSectionLayouts.HORIZONTAL_TWO:
|
|
|
|
|
_setting_options = {
|
|
|
|
|
MAX_ELEMENT: 2,
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
case enumPageSectionLayouts.HORIZONTAL_THREE:
|
|
|
|
|
_setting_options = {
|
|
|
|
|
MAX_ELEMENT: 3,
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
case enumPageSectionLayouts.HORIZONTAL_FOUR:
|
|
|
|
|
_setting_options = {
|
|
|
|
|
MAX_ELEMENT: 4,
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
case enumPageSectionLayouts.HORIZONTAL_FIVE:
|
|
|
|
|
_setting_options = {
|
|
|
|
|
MAX_ELEMENT: 5,
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
case enumPageSectionLayouts.HORIZONTAL_SIX:
|
|
|
|
|
_setting_options = {
|
|
|
|
|
MAX_ELEMENT: 6,
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
case enumPageSectionLayouts.HORIZONTAL_SEVEN:
|
|
|
|
|
_setting_options = {
|
|
|
|
|
MAX_ELEMENT: 7,
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
case enumPageSectionLayouts.HORIZONTAL_EIGHT:
|
|
|
|
|
_setting_options = {
|
|
|
|
|
MAX_ELEMENT: 8,
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
case enumPageSectionLayouts.HORIZONTAL_NINE:
|
|
|
|
|
_setting_options = {
|
|
|
|
|
MAX_ELEMENT: 9,
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
case enumPageSectionLayouts.HORIZONTAL_TEN:
|
|
|
|
|
_setting_options = {
|
|
|
|
|
MAX_ELEMENT: 10,
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
_setting_options = {
|
|
|
|
|
MAX_ELEMENT: 1,
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return _setting_options;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const CLASS_FOR_SECTION = computed(() => {
|
|
|
|
|
let _classForSection = {};
|
|
|
|
|
switch (props.layout) {
|
|
|
|
|
case enumPageSectionLayouts.VERTICAL_TWO:
|
|
|
|
|
_classForSection = {
|
2024-05-31 12:49:28 +07:00
|
|
|
section_layout: "section_layout two_col_layout mb-5 mt-2",
|
2024-05-30 18:06:50 +07:00
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
case enumPageSectionLayouts.VERTICAL_LEFT_TWO:
|
|
|
|
|
_classForSection = {
|
|
|
|
|
section_layout: "section_layout three_col_layout",
|
|
|
|
|
0: "col-span-2",
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
case enumPageSectionLayouts.VERTICAL_RIGHT_TWO:
|
|
|
|
|
_classForSection = {
|
|
|
|
|
section_layout: "section_layout three_col_layout",
|
|
|
|
|
1: "col-span-2",
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
case enumPageSectionLayouts.VERTICAL_THREE:
|
|
|
|
|
_classForSection = {
|
2024-05-31 12:49:28 +07:00
|
|
|
section_layout: "section_layout three_col_layout mt-4",
|
2024-05-30 18:06:50 +07:00
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
case enumPageSectionLayouts.VERTICAL_FOUR:
|
|
|
|
|
_classForSection = {
|
|
|
|
|
section_layout: "section_layout four_col_layout",
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
_classForSection = {
|
|
|
|
|
section_layout: "section_layout basic_column",
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return _classForSection;
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2024-05-30 22:42:55 +07:00
|
|
|
<div class="section_layout grid sm:gap-x-5 sm:gap-y-2.5 gap-[10px] lg:grid-cols-2" :class="[CLASS_FOR_SECTION.section_layout]">
|
2024-05-30 18:06:50 +07:00
|
|
|
<div
|
|
|
|
|
v-for="(position, index) in props.content || Array(SETTING_OPTIONS.MAX_ELEMENT).fill({})"
|
|
|
|
|
:key="index"
|
|
|
|
|
:class="[CLASS_FOR_SECTION[index]]"
|
|
|
|
|
>
|
2024-06-13 17:24:46 +07:00
|
|
|
|
|
|
|
|
<RecusiveSection :type="position.type" :id="position.data" :section="props.section" class="h-full"/>
|
2024-05-30 18:06:50 +07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
2024-06-13 17:24:46 +07:00
|
|
|
<style lang="scss">
|
2024-05-30 18:06:50 +07:00
|
|
|
.section_layout {
|
|
|
|
|
&.basic_column {
|
|
|
|
|
grid-template-columns: repeat(1, minmax(0, 1fr));
|
2024-06-13 17:24:46 +07:00
|
|
|
|
|
|
|
|
// & > div:first-child {
|
|
|
|
|
// .basic-article {
|
|
|
|
|
// h3 {
|
|
|
|
|
// @apply text-24px;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
2024-05-30 18:06:50 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&.two_col_layout {
|
2024-05-30 22:42:55 +07:00
|
|
|
@apply md:grid-cols-2 grid-cols-1;
|
2024-05-30 18:06:50 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&.three_col_layout {
|
2024-05-30 22:42:55 +07:00
|
|
|
@apply lg:grid-cols-3 grid-cols-1;
|
|
|
|
|
// grid-template-columns: repeat(3, minmax(0, 1fr));
|
2024-05-30 18:06:50 +07:00
|
|
|
}
|
|
|
|
|
&.four_col_layout {
|
|
|
|
|
grid-template-columns: repeat(4, minmax(0, 1fr));
|
|
|
|
|
}
|
|
|
|
|
.col-span-2 {
|
|
|
|
|
grid-column: span 2 / span 2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|