feat: new layout
This commit is contained in:
@@ -1,41 +1,45 @@
|
||||
<script lang="ts" setup>
|
||||
import { BASE_LAYOUT } from "./index";
|
||||
import { enumPageSectionLayouts } from "@/definitions/enum";
|
||||
import type { PageSection } from "@/models/cms";
|
||||
import { enumPageSectionLayouts, enumPageSectionTemplate, enumPageSectionKey } from "@/definitions/enum";
|
||||
import { NONE_DEFAULT_LAYOUT } from "./index";
|
||||
|
||||
const _props = defineProps<{
|
||||
settings?: any;
|
||||
layout?: string;
|
||||
content?: any;
|
||||
|
||||
section: any;
|
||||
}>();
|
||||
|
||||
const definedDynamicSection: Record<string, any> = {
|
||||
'Default': BASE_LAYOUT,
|
||||
[enumPageSectionLayouts.VERTICAL_TWO]: BASE_LAYOUT,
|
||||
[enumPageSectionLayouts.VERTICAL_LEFT_TWO]: BASE_LAYOUT,
|
||||
[enumPageSectionLayouts.VERTICAL_RIGHT_TWO]: BASE_LAYOUT,
|
||||
[enumPageSectionLayouts.VERTICAL_THREE]: BASE_LAYOUT,
|
||||
[enumPageSectionLayouts.VERTICAL_FOUR]: BASE_LAYOUT,
|
||||
[enumPageSectionLayouts.HORIZONTAL_ONE]: BASE_LAYOUT,
|
||||
[enumPageSectionLayouts.HORIZONTAL_TWO]: BASE_LAYOUT,
|
||||
[enumPageSectionLayouts.HORIZONTAL_THREE]: BASE_LAYOUT,
|
||||
[enumPageSectionLayouts.HORIZONTAL_FOUR]: BASE_LAYOUT,
|
||||
[enumPageSectionLayouts.HORIZONTAL_FIVE]: BASE_LAYOUT,
|
||||
[enumPageSectionLayouts.HORIZONTAL_SIX]: BASE_LAYOUT,
|
||||
[enumPageSectionLayouts.HORIZONTAL_SEVEN]: BASE_LAYOUT,
|
||||
[enumPageSectionLayouts.HORIZONTAL_EIGHT]: BASE_LAYOUT,
|
||||
[enumPageSectionLayouts.HORIZONTAL_NINE]: BASE_LAYOUT,
|
||||
[enumPageSectionLayouts.HORIZONTAL_TEN]: BASE_LAYOUT,
|
||||
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]['NONE']]['VERTICAL_TWO']]: NONE_DEFAULT_LAYOUT,
|
||||
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]['NONE']]['VERTICAL_LEFT_TWO']]: NONE_DEFAULT_LAYOUT,
|
||||
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]['NONE']]['VERTICAL_RIGHT_TWO']]: NONE_DEFAULT_LAYOUT,
|
||||
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]['NONE']]['VERTICAL_THREE']]: NONE_DEFAULT_LAYOUT,
|
||||
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]['NONE']]['VERTICAL_FOUR']]: NONE_DEFAULT_LAYOUT,
|
||||
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]['NONE']]['VERTICAL_CENTER_TWO']]: NONE_DEFAULT_LAYOUT,
|
||||
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]['NONE']]['VERTICAL_CENTER_THREE']]: NONE_DEFAULT_LAYOUT,
|
||||
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]['NONE']]['VERTICAL_CENTER_FOUR']]: NONE_DEFAULT_LAYOUT,
|
||||
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]['NONE']]['HORIZONTAL_ONE']]: NONE_DEFAULT_LAYOUT,
|
||||
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]['NONE']]['HORIZONTAL_TWO']]: NONE_DEFAULT_LAYOUT,
|
||||
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]['NONE']]['HORIZONTAL_THREE']]: NONE_DEFAULT_LAYOUT,
|
||||
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]['NONE']]['HORIZONTAL_FOUR']]: NONE_DEFAULT_LAYOUT,
|
||||
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]['NONE']]['HORIZONTAL_FIVE']]: NONE_DEFAULT_LAYOUT,
|
||||
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]['NONE']]['HORIZONTAL_SIX']]: NONE_DEFAULT_LAYOUT,
|
||||
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]['NONE']]['HORIZONTAL_SEVEN']]: NONE_DEFAULT_LAYOUT,
|
||||
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]['NONE']]['HORIZONTAL_EIGHT']]: NONE_DEFAULT_LAYOUT,
|
||||
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]['NONE']]['HORIZONTAL_NINE']]: NONE_DEFAULT_LAYOUT,
|
||||
[enumPageSectionLayouts[enumPageSectionTemplate[enumPageSectionKey.NONE]['NONE']]['HORIZONTAL_TEN']]: NONE_DEFAULT_LAYOUT,
|
||||
};
|
||||
|
||||
const getCurrentSection = computed(() => _props?.layout || "");
|
||||
const getCurrentSection = computed(() => {
|
||||
return _props.settings.layout
|
||||
});
|
||||
|
||||
const GET_PROPS = computed(() => {
|
||||
return () => {
|
||||
let props: any = {};
|
||||
if (_props.settings) {
|
||||
for (const [key, value] of _props.settings ? Object.entries(_props.settings) : []) {
|
||||
for (const [key, value] of Object.entries(_props.settings)) {
|
||||
props = {
|
||||
...props,
|
||||
[key]: value,
|
||||
@@ -49,11 +53,12 @@ const GET_PROPS = computed(() => {
|
||||
|
||||
<template>
|
||||
<component
|
||||
:is="definedDynamicSection[getCurrentSection] || null"
|
||||
:is="definedDynamicSection[getCurrentSection]"
|
||||
v-bind="{
|
||||
...GET_PROPS(),
|
||||
section: _props.section,
|
||||
content: _props.content,
|
||||
settings: _props.settings,
|
||||
}"
|
||||
>
|
||||
<slot />
|
||||
|
||||
Reference in New Issue
Block a user