aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonardo Bishop <me@leonardobishop.com>2024-03-13 00:17:32 +0000
committerLeonardo Bishop <me@leonardobishop.com>2024-03-13 00:17:32 +0000
commit543aa0cd4a461285298d33a90ab3f11a9f084ca5 (patch)
treeffbaec5f495b2cf8b891690642df161464ac6e95
parenta072c91cc0dc26e417c51f666e8547e08ef40942 (diff)
Add home page
-rw-r--r--assets/base.css4
-rw-r--r--components/editor/EditorSidebarCategory.vue4
-rw-r--r--components/editor/EditorSidebarItem.vue4
-rw-r--r--components/editor/EditorSidebarMainConfiguration.vue4
-rw-r--r--components/editor/EditorSidebarQuest.vue2
-rw-r--r--components/header/SiteHeader.vue18
-rw-r--r--components/loader/LoaderFileSystemModal.vue3
-rw-r--r--components/loader/LoaderTestDataModal.vue3
-rw-r--r--layouts/default.vue18
-rw-r--r--middleware/editor.global.ts13
-rw-r--r--pages/editor/category/[id].vue (renamed from pages/category/[id].vue)0
-rw-r--r--pages/editor/config.vue (renamed from pages/config.vue)0
-rw-r--r--pages/editor/index.vue25
-rw-r--r--pages/editor/item/[id].vue (renamed from pages/item/[id].vue)0
-rw-r--r--pages/editor/quest/[id].vue (renamed from pages/quest/[id].vue)0
-rw-r--r--pages/index.vue70
-rw-r--r--stores/session.ts6
-rw-r--r--utils/util.ts12
18 files changed, 161 insertions, 25 deletions
diff --git a/assets/base.css b/assets/base.css
index 6b6443a..221ff06 100644
--- a/assets/base.css
+++ b/assets/base.css
@@ -66,7 +66,7 @@
--ff-monospace: monospace;
}
-@media (prefers-color-scheme: dark) {
+/* @media (prefers-color-scheme: dark) { */
:root {
--color-background: var(--c-black);
--color-background-soft: var(--c-black-soft);
@@ -84,7 +84,7 @@
--color-text-mute: var(--c-text-light-2);
--color-text-primary: var(--c-brand-light);
}
-}
+/* } */
*,
*::before,
diff --git a/components/editor/EditorSidebarCategory.vue b/components/editor/EditorSidebarCategory.vue
index cfabf39..27a5ce0 100644
--- a/components/editor/EditorSidebarCategory.vue
+++ b/components/editor/EditorSidebarCategory.vue
@@ -22,11 +22,11 @@ const expandCategory = () => {
};
const setSelectedCategory = () => {
- navigateTo({ path: `/category/${category.value.id}` })
+ navigateToEditorPane('category', category.value.id);
};
const selected = computed(() => {
- return route.path.startsWith('/category') && route.params.id === category.value.id;
+ return route.path.startsWith('/editor/category') && route.params.id === category.value.id;
});
</script>
diff --git a/components/editor/EditorSidebarItem.vue b/components/editor/EditorSidebarItem.vue
index 4696bb1..55f81d0 100644
--- a/components/editor/EditorSidebarItem.vue
+++ b/components/editor/EditorSidebarItem.vue
@@ -10,11 +10,11 @@ const { item } = toRefs(props);
const route = useRoute();
const setSelectedItem = () => {
- navigateTo({ path: `/item/${item.value.id}` })
+ navigateToEditorPane('item', item.value.id);
};
const selected = computed(() => {
- return route.path.startsWith('/item') && route.params.id === item.value.id;
+ return route.path.startsWith('/editor/item') && route.params.id === item.value.id;
});
</script>
diff --git a/components/editor/EditorSidebarMainConfiguration.vue b/components/editor/EditorSidebarMainConfiguration.vue
index c4727c6..bf7196b 100644
--- a/components/editor/EditorSidebarMainConfiguration.vue
+++ b/components/editor/EditorSidebarMainConfiguration.vue
@@ -4,11 +4,11 @@ import { computed } from 'vue';
const route = useRoute();
const setSelected = () => {
- navigateTo({ path: '/config' })
+ navigateToEditorPane('config');
};
const selected = computed(() => {
- return route.path.startsWith('/config');
+ return route.path.startsWith('/editor/config');
});
</script>
diff --git a/components/editor/EditorSidebarQuest.vue b/components/editor/EditorSidebarQuest.vue
index 85edb38..c40b22c 100644
--- a/components/editor/EditorSidebarQuest.vue
+++ b/components/editor/EditorSidebarQuest.vue
@@ -11,7 +11,7 @@ const { quest } = toRefs(props);
const route = useRoute();
const setSelectedQuest = () => {
- navigateTo({ path: `/quest/${quest.value.id}` })
+ navigateToEditorPane('quest', quest.value.id);
};
const selected = computed(() => {
diff --git a/components/header/SiteHeader.vue b/components/header/SiteHeader.vue
index 75686d8..015af3d 100644
--- a/components/header/SiteHeader.vue
+++ b/components/header/SiteHeader.vue
@@ -1,11 +1,16 @@
<script setup land="ts">
+const navigateHome = () => {
+ navigateTo('/');
+}
</script>
<template>
<header>
<div id="nav">
- <img src="@/assets/quests-logo.png" alt="Quests logo" />
- <h1>Quests Web Editor</h1>
+ <span id="logo" @click="navigateHome">
+ <img src="@/assets/quests-logo.png" alt="Quests logo" />
+ <h1>Quests Web Editor</h1>
+ </span>
<code>Preview</code>
</div>
@@ -44,6 +49,15 @@
}
+#logo {
+ cursor: pointer;
+ display: flex;
+ align-items: center;
+ justify-content: flex-start;
+ gap: 1rem;
+ color: var(--color-header-text);
+}
+
#controls {
padding: 1rem;
display: flex;
diff --git a/components/loader/LoaderFileSystemModal.vue b/components/loader/LoaderFileSystemModal.vue
index 27f4e12..25fcfa2 100644
--- a/components/loader/LoaderFileSystemModal.vue
+++ b/components/loader/LoaderFileSystemModal.vue
@@ -16,6 +16,9 @@ const confirm = () => {
session.setCategories(categories);
session.setQuests(quests);
session.setItems(items);
+ session.setSessionType('filesystem');
+
+ navigateToEditorPane(null);
showModal.value = false;
}
diff --git a/components/loader/LoaderTestDataModal.vue b/components/loader/LoaderTestDataModal.vue
index 36d2d6d..8b0df21 100644
--- a/components/loader/LoaderTestDataModal.vue
+++ b/components/loader/LoaderTestDataModal.vue
@@ -18,6 +18,9 @@ const confirm = () => {
session.setQuests(quests);
session.setCategories(categories);
session.setItems(items);
+ session.setSessionType('demo');
+
+ navigateToEditorPane(null);
showModal.value = false;
}
diff --git a/layouts/default.vue b/layouts/default.vue
index 80bf29e..087f064 100644
--- a/layouts/default.vue
+++ b/layouts/default.vue
@@ -4,5 +4,19 @@
<template>
<SiteHeader />
- <slot />
-</template> \ No newline at end of file
+ <div id="content">
+ <slot />
+ </div>
+</template>
+
+<style scoped>
+#content {
+ display: flex;
+ height: calc(100vh - 73px);
+ flex-direction: row;
+}
+
+#content {
+ width: 100%;
+}
+</style> \ No newline at end of file
diff --git a/middleware/editor.global.ts b/middleware/editor.global.ts
new file mode 100644
index 0000000..18123ae
--- /dev/null
+++ b/middleware/editor.global.ts
@@ -0,0 +1,13 @@
+import { useSessionStore } from "@/stores/session";
+
+export default defineNuxtRouteMiddleware((to, from) => {
+ const session = useSessionStore();
+
+ if (to.fullPath === '/' && session.getSessionType !== 'none') {
+ return navigateTo('/editor');
+ }
+
+ if (to.fullPath.startsWith('/editor') && session.getSessionType === 'none') {
+ return navigateTo('/');
+ }
+});
diff --git a/pages/category/[id].vue b/pages/editor/category/[id].vue
index 3189d2a..3189d2a 100644
--- a/pages/category/[id].vue
+++ b/pages/editor/category/[id].vue
diff --git a/pages/config.vue b/pages/editor/config.vue
index 4dfc679..4dfc679 100644
--- a/pages/config.vue
+++ b/pages/editor/config.vue
diff --git a/pages/editor/index.vue b/pages/editor/index.vue
new file mode 100644
index 0000000..4e9815a
--- /dev/null
+++ b/pages/editor/index.vue
@@ -0,0 +1,25 @@
+<script setup lang="ts">
+definePageMeta({
+ layout: 'editor'
+})
+</script>
+
+<template>
+ <div id="title">
+ <b>Select a quest or category to continue</b>
+ </div>
+</template>
+
+<style lang="scss" scoped>
+#title {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ height: 90%;
+
+ b {
+ font-weight: bolder;
+ font-size: 1.5rem;
+ }
+}
+</style> \ No newline at end of file
diff --git a/pages/item/[id].vue b/pages/editor/item/[id].vue
index c2456be..c2456be 100644
--- a/pages/item/[id].vue
+++ b/pages/editor/item/[id].vue
diff --git a/pages/quest/[id].vue b/pages/editor/quest/[id].vue
index bc480d9..bc480d9 100644
--- a/pages/quest/[id].vue
+++ b/pages/editor/quest/[id].vue
diff --git a/pages/index.vue b/pages/index.vue
index dd46b31..a64706a 100644
--- a/pages/index.vue
+++ b/pages/index.vue
@@ -1,17 +1,77 @@
<script setup lang="ts">
definePageMeta({
- layout: 'editor'
+ layout: 'default'
})
</script>
<template>
- <div id="title">
- <h1>Select a quest or category to continue</h1>
+ <div id="welcome-container">
+ <div id="welcome">
+ <img id="welcome-image" src="@/assets/quests-logo.png" alt="Quests logo" />
+ <b id="title">Welcome to the Quests Web Editor</b>
+ <p>This is a work in progress build of the web editor for <a href="https://github.com/LMBishop/Quests">Quests</a>.
+ It is <b>not</b> ready for use.
+ </p>
+ <p>If you would like to try this out, use the buttons in the top right corner to start a session.</p>
+ <b id="subtitle">Cannot import from filesystem</b>
+ <p>
+ If you cannot import from filesystem, then that means you are using a browser which does not implement the
+ <a href="https://wicg.github.io/file-system-access/">File System Access API</a>. At the time of writing,
+ only Chromium based browsers (Google Chrome, Microsoft Edge, Brave, etc.) implement this. This means if you
+ use Firefox or Safari, you must switch browser to use this feature.
+ </p>
+ <p>
+ You can instead load the test data instead by clicking the "Demo" button.
+ </p>
+ <b id="subtitle">Light / dark theme</b>
+ <p>
+ Note that the light theme of this website is a work in progress. Please use the dark theme. The colour scheme
+ will automatically adjust based on your browsers preferences.
+ </p>
+ <b id="subtitle">Source code</b>
+ <p>
+ Just like Quests itself, the source code is <a href="https://github.com/LMBishop/quests-web-editor">available
+ on GitHub</a>.
+ Due to the volatile state of this project, if you would like to get involved please get in touch with me first.
+ </p>
+ </div>
</div>
</template>
<style lang="scss" scoped>
-#title {
- text-align: center;
+#welcome-container {
+ display: flex;
+ justify-content: center;
+ width: 100%;
+ height: 100%;
+}
+
+#welcome {
+ display: flex;
+ flex-direction: column;
+ margin: 3rem 0;
+ gap: 1.5rem;
+ align-items: flex-start;
+ justify-content: flex-start;
+ max-width: 800px;
+
+ #title {
+ font-weight: bold;
+ font-size: 1.5rem;
+ }
+
+ #subtitle {
+ font-weight: bold;
+ font-size: 1.1rem;
+ }
+
+ #welcome-image {
+ max-width: 8rem;
+ align-self: center;
+ }
+
+ b {
+ font-weight: bold;
+ }
}
</style> \ No newline at end of file
diff --git a/stores/session.ts b/stores/session.ts
index 40587e9..a0781bc 100644
--- a/stores/session.ts
+++ b/stores/session.ts
@@ -93,9 +93,11 @@ export interface QuestItemDefinition {
}
}
+export type SessionType = 'none' | 'filesystem' | 'demo';
+
export const useSessionStore = defineStore('session', {
state: () => ({
- sessionType: '',
+ sessionType: 'none' as SessionType,
session: {
quests: [] as EditorQuest[],
categories: [] as EditorCategory[],
@@ -154,7 +156,7 @@ export const useSessionStore = defineStore('session', {
}
},
actions: {
- setSessionType(type: string) {
+ setSessionType(type: SessionType) {
this.sessionType = type
},
setQuests(quests: EditorQuest[]) {
diff --git a/utils/util.ts b/utils/util.ts
index cc500e0..273191a 100644
--- a/utils/util.ts
+++ b/utils/util.ts
@@ -4,17 +4,19 @@ export function stripColorCodes(str: string): string {
return str.replace(COLOR_CODE_REGEX, '');
}
-export function navigateToEditorPane(type: 'quest' | 'category' | 'item' | null, id?: string) {
+export function navigateToEditorPane(type: 'quest' | 'category' | 'item' | 'config' | null, id?: string) {
if (id) {
if (type === 'category') {
- navigateTo({ path: '/category/' + id })
+ navigateTo({ path: '/editor/category/' + id })
} else if (type === 'quest') {
- navigateTo({ path: '/quest/' + id })
+ navigateTo({ path: '/editor/quest/' + id })
} else if (type === 'item') {
- navigateTo({ path: '/item/' + id })
+ navigateTo({ path: '/editor/item/' + id })
}
+ } else if (type === 'config') {
+ navigateTo({ path: '/editor/config' })
} else if (!id && !type) {
- navigateTo({ path: '/' })
+ navigateTo({ path: '/editor' })
}
}