blob: 39e222b405ba479fc6607fa51923ad351fd07cbf [file] [log] [blame]
simon26e79f72022-10-05 22:16:08 -04001/*
2 * Copyright (C) 2022 Savoir-faire Linux Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License as
6 * published by the Free Software Foundation; either version 3 of the
7 * License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Affero General Public License for more details.
13 *
14 * You should have received a copy of the GNU Affero General Public
15 * License along with this program. If not, see
16 * <https://www.gnu.org/licenses/>.
17 */
Adrien Béraudab519ff2022-05-03 15:34:48 -040018import { Button, Container } from '@mui/material';
Adrien Béraud34995902021-06-07 10:12:00 -040019import { AnimatePresence, motion } from 'framer-motion';
simond47ef9e2022-09-28 22:24:28 -040020import { useState } from 'react';
simon07b4eb02022-09-29 17:50:26 -040021
Adrien Béraud34995902021-06-07 10:12:00 -040022const list = {
simond47ef9e2022-09-28 22:24:28 -040023 hidden: { opacity: 0 },
24 visible: {
25 opacity: 1,
26 transition: {
27 when: 'beforeChildren',
28 staggerChildren: 0.3,
29 },
30 },
31};
Adrien Béraud34995902021-06-07 10:12:00 -040032const item = {
simond47ef9e2022-09-28 22:24:28 -040033 visible: { opacity: 1, x: 0 },
34 hidden: { opacity: 0, x: 0 },
35};
Adrien Béraud34995902021-06-07 10:12:00 -040036
37export default function WelcomeAnimation(props) {
simond47ef9e2022-09-28 22:24:28 -040038 const [visible, setVisible] = useState(true);
Adrien Béraud34995902021-06-07 10:12:00 -040039
simond47ef9e2022-09-28 22:24:28 -040040 return (
41 <Container style={{ textAlign: 'center', display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
42 <AnimatePresence>
43 {visible && (
44 <motion.div
45 initial="hidden"
46 animate="visible"
47 exit="hidden"
48 variants={list}
49 onAnimationComplete={(a) => {
50 if (a === 'hidden') {
51 props.onComplete();
52 } else if (!props.showSetup) {
53 setVisible(false);
54 }
55 }}
56 >
Adrien Béraud34995902021-06-07 10:12:00 -040057 <motion.div variants={item}>
simond8ca2f22022-10-11 23:30:55 -040058 <img
59 src="/jami-logo-icon.svg"
60 style={{
61 width: '32',
62 height: '32',
63 }}
64 alt="jami n/logo"
65 />
simond47ef9e2022-09-28 22:24:28 -040066 </motion.div>
67 <motion.h1 variants={item}>Welcome to Jami</motion.h1>
68 {props.showSetup && (
69 <motion.div variants={item}>
70 <Button variant="outlined" onClick={() => setVisible(false)}>
71 Start setup
72 </Button>
73 </motion.div>
74 )}
75 </motion.div>
76 )}
77 </AnimatePresence>
Adrien Béraud34995902021-06-07 10:12:00 -040078 </Container>
simond47ef9e2022-09-28 22:24:28 -040079 );
80}