From 7e2989e3839e66dc23d088be9fa31ed08d142b3b Mon Sep 17 00:00:00 2001
From: Alexis <35.alexis.pele@gmail.com>
Date: Sun, 2 Mar 2025 20:02:51 +0100
Subject: [PATCH] Polished world modal behaviour
---
components/global/input/Color.vue | 100 ++++++++++++++++++++++++-
components/ui/select/SelectContent.vue | 3 +-
components/world/dialog/Create.vue | 1 +
components/world/dialog/Edit.vue | 1 +
components/world/form/Create.vue | 2 +-
models/World.ts | 2 +-
6 files changed, 102 insertions(+), 7 deletions(-)
diff --git a/components/global/input/Color.vue b/components/global/input/Color.vue
index 7f597e4..75448ec 100644
--- a/components/global/input/Color.vue
+++ b/components/global/input/Color.vue
@@ -1,20 +1,112 @@
-
+
-
+
-
+
{{ $t(`ui.colors.${color}`) }}
+
+
diff --git a/components/ui/select/SelectContent.vue b/components/ui/select/SelectContent.vue
index 2b0473f..3fb413c 100644
--- a/components/ui/select/SelectContent.vue
+++ b/components/ui/select/SelectContent.vue
@@ -36,9 +36,10 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits)
diff --git a/components/world/dialog/Edit.vue b/components/world/dialog/Edit.vue
index 661aec6..da07aa6 100644
--- a/components/world/dialog/Edit.vue
+++ b/components/world/dialog/Edit.vue
@@ -20,6 +20,7 @@ const emit = defineEmits(["on-close"])
function handleClose() {
emit("on-close")
+ worldSkeletonName.value = props.world?.name ?? ""
}
diff --git a/components/world/form/Create.vue b/components/world/form/Create.vue
index 94bbc72..d5b65fe 100644
--- a/components/world/form/Create.vue
+++ b/components/world/form/Create.vue
@@ -4,7 +4,7 @@ import type { World } from "~/models/World";
const user = useSupabaseUser()
-const defaultWorld: World = { name: "", description: "", gmId: user.value?.id }
+const defaultWorld: World = { name: "", description: "", gmId: user.value?.id, color: "white", state: "draft" }
const worldSkeleton = ref({ ...defaultWorld })
onMounted(() => {
diff --git a/models/World.ts b/models/World.ts
index 8a98fa3..d57b624 100644
--- a/models/World.ts
+++ b/models/World.ts
@@ -17,7 +17,7 @@ export interface World {
export const postWorldSchema = z.object({
name: z.string(),
description: z.string().optional().nullable(),
- color: rpgColorSchema,
+ color: rpgColorSchema.default("white"),
gmId: z.string().optional().nullable(),
state: z.string().optional().nullable().default("draft"),
})