Skip to content

Commit 8937439

Browse files
committed
feat: animate card with animate presence, add check icon
1 parent 9e15f32 commit 8937439

File tree

1 file changed

+38
-22
lines changed

1 file changed

+38
-22
lines changed

apps/web/src/routes/_app/session/start-session.tsx

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import React, { useEffect, useState } from 'react';
22

33
import { Heading } from '@douglasneuroinformatics/libui/components';
44
import { useTranslation } from '@douglasneuroinformatics/libui/hooks';
5+
import { CheckCircle } from 'lucide-react';
56
import type { FormTypes } from '@opendatacapture/runtime-core';
67
import { createFileRoute, useLocation } from '@tanstack/react-router';
8+
import { AnimatePresence, motion } from 'motion/react';
79

810
import { PageHeader } from '@/components/PageHeader';
911
import { StartSessionForm } from '@/components/StartSessionForm';
@@ -41,30 +43,44 @@ const RouteComponent = () => {
4143
{t('startSession')}
4244
</Heading>
4345
</PageHeader>
44-
<div className="space-y-4">
45-
{currentSession == null && (
46-
<StartSessionForm
47-
currentGroup={currentGroup}
48-
initialValues={initialValues}
49-
readOnly={currentSession !== null || createSessionMutation.isPending}
50-
username={currentUser?.username}
51-
onSubmit={async (formData) => {
52-
const session = await createSessionMutation.mutateAsync(formData);
53-
startSession({ ...session, type: formData.type });
54-
}}
55-
/>
56-
)}
46+
{currentSession == null && (
47+
<StartSessionForm
48+
currentGroup={currentGroup}
49+
initialValues={initialValues}
50+
readOnly={currentSession !== null || createSessionMutation.isPending}
51+
username={currentUser?.username}
52+
onSubmit={async (formData) => {
53+
const session = await createSessionMutation.mutateAsync(formData);
54+
startSession({ ...session, type: formData.type });
55+
}}
56+
/>
57+
)}
58+
<AnimatePresence>
5759
{currentSession !== null && (
58-
<div className="mx-auto block max-h-fit max-w-3xl rounded-lg border border-gray-200 bg-white p-6 opacity-70 shadow-sm dark:border-gray-700 dark:bg-gray-800">
59-
<p className="max-w-4xl text-center text-yellow-600 dark:text-yellow-300">
60-
{t({
61-
en: 'The current session must be ended before starting the form again.',
62-
fr: 'La session en cours doit être terminée avant de recommencer le formulaire.'
63-
})}
64-
</p>
65-
</div>
60+
<motion.div
61+
animate={{ opacity: 1, scale: 1 }}
62+
exit={{ opacity: 0, scale: 0 }}
63+
initial={{ opacity: 0, scale: 0 }}
64+
key="modal"
65+
>
66+
<div className="flex h-screen items-center justify-center">
67+
{currentSession !== null && (
68+
<div className="center mx-auto block max-w-3xl rounded-lg border border-gray-200 bg-white p-4 opacity-70 shadow-sm dark:border-gray-700 dark:bg-gray-800">
69+
<p className="flex max-w-4xl gap-x-3 text-center text-green-600 dark:text-green-300">
70+
<span>
71+
<CheckCircle />{' '}
72+
</span>
73+
{t({
74+
en: 'The current session must be ended before starting the form again.',
75+
fr: 'La session en cours doit être terminée avant de recommencer le formulaire.'
76+
})}
77+
</p>
78+
</div>
79+
)}
80+
</div>
81+
</motion.div>
6682
)}
67-
</div>
83+
</AnimatePresence>
6884
</React.Fragment>
6985
);
7086
};

0 commit comments

Comments
 (0)