blob: ca160a08bc8cc86b01799209e54e472575d9971f [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
simond47ef9e2022-09-28 22:24:28 -040022import JamiLogo from '../../public/jami-logo-icon.svg';
Adrien Béraud34995902021-06-07 10:12:00 -040023
24const list = {
simond47ef9e2022-09-28 22:24:28 -040025 hidden: { opacity: 0 },
26 visible: {
27 opacity: 1,
28 transition: {
29 when: 'beforeChildren',
30 staggerChildren: 0.3,
31 },
32 },
33};
Adrien Béraud34995902021-06-07 10:12:00 -040034const item = {
simond47ef9e2022-09-28 22:24:28 -040035 visible: { opacity: 1, x: 0 },
36 hidden: { opacity: 0, x: 0 },
37};
Adrien Béraud34995902021-06-07 10:12:00 -040038
39export default function WelcomeAnimation(props) {
simond47ef9e2022-09-28 22:24:28 -040040 const [visible, setVisible] = useState(true);
Adrien Béraud34995902021-06-07 10:12:00 -040041
simond47ef9e2022-09-28 22:24:28 -040042 return (
43 <Container style={{ textAlign: 'center', display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
44 <AnimatePresence>
45 {visible && (
46 <motion.div
47 initial="hidden"
48 animate="visible"
49 exit="hidden"
50 variants={list}
51 onAnimationComplete={(a) => {
52 if (a === 'hidden') {
53 props.onComplete();
54 } else if (!props.showSetup) {
55 setVisible(false);
56 }
57 }}
58 >
Adrien Béraud34995902021-06-07 10:12:00 -040059 <motion.div variants={item}>
simond47ef9e2022-09-28 22:24:28 -040060 <JamiLogo size="32px" />
61 </motion.div>
62 <motion.h1 variants={item}>Welcome to Jami</motion.h1>
63 {props.showSetup && (
64 <motion.div variants={item}>
65 <Button variant="outlined" onClick={() => setVisible(false)}>
66 Start setup
67 </Button>
68 </motion.div>
69 )}
70 </motion.div>
71 )}
72 </AnimatePresence>
Adrien Béraud34995902021-06-07 10:12:00 -040073 </Container>
simond47ef9e2022-09-28 22:24:28 -040074 );
75}