From c6bcf23af1e0fa3c77076a1190cf2df7603f2aef Mon Sep 17 00:00:00 2001 From: Brandon Egger Date: Tue, 11 Apr 2023 01:47:25 -0500 Subject: [PATCH] add proper backwards animations --- src/components/Survey.tsx | 13 +++++++---- src/pages/resources/survey.tsx | 42 +++++++++++++++++----------------- tailwind.config.cjs | 7 +++++- 3 files changed, 36 insertions(+), 26 deletions(-) diff --git a/src/components/Survey.tsx b/src/components/Survey.tsx index c9f7a32..3543983 100644 --- a/src/components/Survey.tsx +++ b/src/components/Survey.tsx @@ -72,7 +72,7 @@ const QuestionPage = ({isLastPage, page, question, updatePage, formData, updateF if (dontCare) { return ( - ) @@ -162,12 +162,16 @@ const QuestionPage = ({isLastPage, page, question, updatePage, formData, updateF ) } -const PageTransition = ({lastPage, currentPage}: { +/** + * Wrapper for last and current page to enable the transition animation + */ +const PageTransition = ({backwards, lastPage, currentPage}: { + backwards: boolean, lastPage: JSX.Element | null, currentPage: JSX.Element, }) => { return ( -
+
{currentPage}
@@ -242,6 +246,7 @@ const GuidedSurvey = ({questions}: { const lastPage = ; const currentPage = ; + const backwards = (previousPage ?? -1) >= page; return (
@@ -249,7 +254,7 @@ const GuidedSurvey = ({questions}: {

Search

- + {/** Hidden html */}
diff --git a/src/pages/resources/survey.tsx b/src/pages/resources/survey.tsx index 19ae224..6cb0121 100644 --- a/src/pages/resources/survey.tsx +++ b/src/pages/resources/survey.tsx @@ -47,26 +47,6 @@ const questions: Question[] = [ } ] }, - { - for: "skill_levels", - header: "Skill Level", - question: "What skill level(s) should the resource have?", - optional: true, - options: [ - { - label: "Beginner", - value: "BEGINNER", - }, - { - label: "Intermediate", - value: "INTERMEDIATE", - }, - { - label: "Advanced", - value: "ADVANCED", - } - ] - }, { for: "skills", header: "Skills Practiced", @@ -98,7 +78,27 @@ const questions: Question[] = [ value: "ENVIRONMENT", }, ] - } + }, + { + for: "skill_levels", + header: "Skill Level", + question: "What skill level(s) should the resource have?", + optional: true, + options: [ + { + label: "Beginner", + value: "BEGINNER", + }, + { + label: "Intermediate", + value: "INTERMEDIATE", + }, + { + label: "Advanced", + value: "ADVANCED", + } + ] + }, ] const ChoiceQuestion = ({question, formData, updateFormData}: {question: Question, formData: Record, updateFormData: Dispatch>>}) => { diff --git a/tailwind.config.cjs b/tailwind.config.cjs index 94d5bd3..dc1fe14 100644 --- a/tailwind.config.cjs +++ b/tailwind.config.cjs @@ -11,11 +11,16 @@ const config = { slide_left_full: { '0%': { transform: 'translate(0%)' }, '100%': { transform: 'translate(-50%)' }, + }, + slide_right_full: { + '0%': { transform: 'translate(-50%)' }, + '100%': { transform: 'translate(0%)' }, } }, animation: { expand_in_out: 'expand_in_out 2s ease-in-out infinite', - slide_survey_page: 'slide_left_full 1s ease-in-out', + slide_survey_page: 'slide_left_full 0.5s ease-in-out', + slide_survey_page_backwards: 'slide_right_full 0.5s ease-in-out' }, }, },