Skip to content

Commit

Permalink
feat: Init template system
Browse files Browse the repository at this point in the history
  • Loading branch information
surajshetty3416 committed Feb 23, 2024
1 parent cd697c4 commit 673df5c
Show file tree
Hide file tree
Showing 8 changed files with 1,617 additions and 1,811 deletions.
1 change: 0 additions & 1 deletion frontend/src/components/BlockContextMenu.vue
Expand Up @@ -45,7 +45,6 @@ import blockController from "@/utils/blockController";
import getBlockTemplate from "@/utils/blockTemplate";
import { confirm, detachBlockFromComponent, getBlockCopy } from "@/utils/helpers";
import { vOnClickOutside } from "@vueuse/components";
import { Dialog } from "frappe-ui";
import { nextTick, ref } from "vue";
import { toast } from "vue-sonner";
import ContextMenu from "./ContextMenu.vue";
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/components/BlockEditor.vue
Expand Up @@ -77,7 +77,6 @@
<script setup lang="ts">
import Block from "@/utils/block";
import { addPxToNumber } from "@/utils/helpers";
import { Dialog } from "frappe-ui";
import { Ref, computed, inject, nextTick, onMounted, ref, watch, watchEffect } from "vue";
import blockController from "@/utils/blockController";
Expand Down Expand Up @@ -146,7 +145,10 @@ watchEffect(() => {
parentBlock?.getStyle("justifyContent");
parentBlock?.getStyle("alignItems");
parentBlock?.getStyle("flexDirection");
parentBlock?.getStyle("padding");
parentBlock?.getStyle("paddingTop");
parentBlock?.getStyle("paddingBottom");
parentBlock?.getStyle("paddingLeft");
parentBlock?.getStyle("paddingRight");
parentBlock?.getStyle("margin");
store.builderLayout.leftPanelWidth;
store.builderLayout.rightPanelWidth;
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion frontend/src/components/BuilderToolbar.vue
Expand Up @@ -77,7 +77,7 @@
</template>
<script setup lang="ts">
import { UseDark } from "@vueuse/components";
import { Dialog, Tooltip } from "frappe-ui";
import { Tooltip } from "frappe-ui";
import { ref } from "vue";
import useStore from "../store";
Expand Down
1 change: 0 additions & 1 deletion frontend/src/components/PageScript.vue
Expand Up @@ -53,7 +53,6 @@
import { webPages } from "@/data/webPage";
import useStore from "@/store";
import { BuilderPage } from "@/types/Builder/BuilderPage";
import { Dialog } from "frappe-ui";
import { onMounted, ref } from "vue";
import CodeEditor from "./CodeEditor.vue";
import PageClientScriptManager from "./PageClientScriptManager.vue";
Expand Down
12 changes: 11 additions & 1 deletion frontend/src/main.ts
@@ -1,5 +1,14 @@
import App from "@/App.vue";
import { Button, FeatherIcon, FormControl, FrappeUI, Input, frappeRequest, setConfig } from "frappe-ui";
import {
Button,
Dialog,
FeatherIcon,
FormControl,
FrappeUI,
Input,
frappeRequest,
setConfig,
} from "frappe-ui";
import { createPinia } from "pinia";
import { createApp } from "vue";
import "./index.css";
Expand All @@ -19,6 +28,7 @@ app.use(pinia);
app.component("Button", Button);
app.component("Input", Input);
app.component("FormControl", FormControl);
app.component("Dialog", Dialog);

app.component("FeatherIcon", FeatherIcon);
app.mount("#app");
30 changes: 27 additions & 3 deletions frontend/src/pages/PageBuilderLanding.vue
Expand Up @@ -52,9 +52,7 @@
{ label: 'Published', value: 'published' },
{ label: 'Unpublished', value: 'unpublished' },
]" />
<router-link :to="{ name: 'builder', params: { pageId: 'new' } }">
<Button variant="solid" icon-left="plus">New</Button>
</router-link>
<Button variant="solid" icon-left="plus" @click="() => (showDialog = true)">New</Button>
</div>
</div>
<div class="flex flex-wrap gap-6">
Expand Down Expand Up @@ -170,11 +168,26 @@
</div>
</router-link>
</div>
<Dialog
:options="{
title: 'Select Template',
size: '6xl',
}"
v-model="showDialog">
<template #body-content>
<div
class="flex h-12 w-48 cursor-pointer items-center rounded-sm bg-gray-50 p-4 align-middle dark:bg-zinc-900"
@click="() => loadPage(null)">
Blank
</div>
</template>
</Dialog>
</section>
</template>
<script setup lang="ts">
import CrossIcon from "@/components/Icons/Cross.vue";
import { webPages } from "@/data/webPage";
import router from "@/router";
import useStore from "@/store";
import { BuilderPage } from "@/types/Builder/BuilderPage";
import { confirm } from "@/utils/helpers";
Expand All @@ -188,6 +201,7 @@ const displayType = useStorage('displayType', 'grid');
const store = useStore();
const filter = ref("");
const typeFilter = ref("");
const showDialog = ref(false);
const pages = computed(() =>
(webPages.data || []).filter((page: BuilderPage) => {
Expand Down Expand Up @@ -225,6 +239,16 @@ const duplicatePage = async (page: BuilderPage) => {
await webPages.insert.submit(pageCopy);
};
// <router-link :to="{ name: 'builder', params: { pageId: 'new' } }">
// </router-link>
const loadPage = (template: string | null) => {
if (!template) {
router.push({ name: "builder", params: { pageId: "new" } });
showDialog.value = false;
}
};
onActivated(() => {
webPages.fetch();
});
Expand Down

0 comments on commit 673df5c

Please sign in to comment.