From d4bfe9138f727f476e286049135564823a5f3d33 Mon Sep 17 00:00:00 2001 From: Mawoka Date: Thu, 16 Jun 2022 19:44:56 +0200 Subject: [PATCH] :construction: New editor nearly done --- frontend/src/lib/editor.svelte | 38 +++++- frontend/src/lib/editor/card.svelte | 127 +++++++++++++++++++ frontend/src/lib/editor/checker-bg.svg | 3 + frontend/src/lib/editor/settings-card.svelte | 54 +++++++- frontend/src/lib/editor/sidebar.svelte | 20 ++- frontend/src/lib/yupSchemas.ts | 8 +- frontend/src/routes/__layout.svelte | 1 + 7 files changed, 238 insertions(+), 13 deletions(-) create mode 100644 frontend/src/lib/editor/card.svelte create mode 100644 frontend/src/lib/editor/checker-bg.svg diff --git a/frontend/src/lib/editor.svelte b/frontend/src/lib/editor.svelte index 3c3fd5a..77c2c6f 100644 --- a/frontend/src/lib/editor.svelte +++ b/frontend/src/lib/editor.svelte @@ -5,6 +5,7 @@ import type { EditorData, Question, Answer } from './quiz_types'; import Sidebar from '$lib/editor/sidebar.svelte'; import SettingsCard from '$lib/editor/settings-card.svelte'; + import QuizCard from '$lib/editor/card.svelte'; const { t } = getLocalization(); @@ -68,9 +69,38 @@
-
- {#if selected_question === -1} - - {/if} +
+
+ {#if schemaInvalid} +

{yupErrorMessage}

+ {/if} + +
+
+ {#if selected_question === -1} + + {:else} + + {/if} +
diff --git a/frontend/src/lib/editor/card.svelte b/frontend/src/lib/editor/card.svelte new file mode 100644 index 0000000..011a2e9 --- /dev/null +++ b/frontend/src/lib/editor/card.svelte @@ -0,0 +1,127 @@ + + +
+
+
+
+ + + +
+
+
+
+ +
+
+ not available +
+
+
+ {#each question.answers as answer, index} +
{ + question.answers.splice(index, 1); + question.answers = question.answers; + }} + class="p-4 rounded-lg flex justify-center w-full" + class:bg-red-500={!answer.right} + class:bg-green-500={answer.right} + class:bg-yellow-500={!reach( + dataSchema, + 'questions[].answers[].answer' + ).isValidSync(answer.answer)} + > + + +
+ {/each} + {#if question.answers.length < 4} + + {/if} +
+
+

Right-click on an answer to delete it!

+
+
+
diff --git a/frontend/src/lib/editor/checker-bg.svg b/frontend/src/lib/editor/checker-bg.svg new file mode 100644 index 0000000..2996684 --- /dev/null +++ b/frontend/src/lib/editor/checker-bg.svg @@ -0,0 +1,3 @@ + + + diff --git a/frontend/src/lib/editor/settings-card.svelte b/frontend/src/lib/editor/settings-card.svelte index 9707d8d..4f47e91 100644 --- a/frontend/src/lib/editor/settings-card.svelte +++ b/frontend/src/lib/editor/settings-card.svelte @@ -4,7 +4,7 @@ export let data: EditorData; -
+
@@ -24,9 +24,59 @@
+
+