From 7ca9e6bd12f43736551c9d92d04ee8452b94d1f1 Mon Sep 17 00:00:00 2001 From: Krzysztof Karbownik <77581765+codeofcarbon@users.noreply.github.com> Date: Sun, 18 Feb 2024 14:11:08 +0100 Subject: [PATCH] minor templates refactor --- frontend/src/assets/colors.scss | 9 +++- .../cards/components/CardDetailsComponent.vue | 43 +++++++------------ .../cards/components/CardItemScroller.vue | 40 ++++++++--------- .../cards/composables/useCardsService.ts | 6 +-- .../feature/cards/pages/CardDetailsPage.vue | 2 +- .../feature/cards/pages/CardOverviewPage.vue | 26 +++++------ .../category/components/CategoryCard.vue | 37 +++++++--------- .../category/components/CategoryIterator.vue | 30 ++++--------- .../category/pages/CategoryOverviewPage.vue | 16 +++---- .../registration/pages/RegistrationPage.vue | 18 ++------ frontend/src/layouts/SideNavigation.vue | 12 +++--- frontend/src/shared/composables/useApi.ts | 13 +++--- frontend/src/shared/pages/ErrorNotFound.vue | 12 +++--- frontend/src/shared/pages/Welcome.vue | 15 +++---- 14 files changed, 116 insertions(+), 163 deletions(-) diff --git a/frontend/src/assets/colors.scss b/frontend/src/assets/colors.scss index 6482155..06a8b5d 100644 --- a/frontend/src/assets/colors.scss +++ b/frontend/src/assets/colors.scss @@ -1,5 +1,12 @@ -$--green-success: #1b8751; $--red-error: #e35448; +$--red-wrong-answer: #ff0000ff; +$--red-wrong-answer-background: #ff00007f; + +$--green-success: #1b8751; +$--green-correct-answer: #008000ff; +$--green-correct-answer-background: #00ff00cc; +$--green-selected-answer-background: #0080007f; + $--yellow-warning: #f6bc32; $--white: #ffffff; $--dark: #00000025; diff --git a/frontend/src/feature/cards/components/CardDetailsComponent.vue b/frontend/src/feature/cards/components/CardDetailsComponent.vue index 52ea068..b6817c9 100644 --- a/frontend/src/feature/cards/components/CardDetailsComponent.vue +++ b/frontend/src/feature/cards/components/CardDetailsComponent.vue @@ -7,8 +7,7 @@ - + @@ -33,10 +32,8 @@ - - + Check Answer @@ -74,12 +71,11 @@ const answerShown = ref(false); const selected = ref([] as string[]); const providedAnswer = ref(''); -const parseOption = (index: number, option: string): string => { - return `${String.fromCharCode(65 + index)}. ${option}`; -}; - -const isCorrect = (option: string) => { - return getCorrectAnswer()?.includes(option); +const parseOption = (index: number, option: string) => `${String.fromCharCode(65 + index)}. ${option}`; +const isCorrect = (option: string) => getCorrectAnswer()?.includes(option); +const highlightCorrectAnswers = () => answerShown.value = !answerShown.value; +const showCorrectAnswer = () => { + return `Correct answer${props.card.type === CardType.MULTIPLE_CHOICE ? 's' : ''}: ${getCorrectAnswer()}`; }; const toggleOption = (option: string) => { @@ -95,10 +91,6 @@ const toggleOption = (option: string) => { } }; -const checkCorrectAnswer = () => { - answerShown.value = !answerShown.value; -}; - const getCorrectAnswer = () => { const card = props.card; switch (card.type) { @@ -110,29 +102,26 @@ const getCorrectAnswer = () => { return card.correctOptions.map(i => card.options[Number(i)]).join(", "); } }; - -const showCorrectAnswer = () => { - const correctAnswer = getCorrectAnswer(); - return `Correct answer${props.card.type === CardType.MULTIPLE_CHOICE ? 's' : ''}: ${correctAnswer}`; -}; diff --git a/frontend/src/feature/cards/components/CardItemScroller.vue b/frontend/src/feature/cards/components/CardItemScroller.vue index 245f5fd..6f4219a 100644 --- a/frontend/src/feature/cards/components/CardItemScroller.vue +++ b/frontend/src/feature/cards/components/CardItemScroller.vue @@ -1,17 +1,16 @@