blob: 9f3978d861f649292abc48a309e45dee59f2b632 [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 */
Michelle Sepkap Simef5ebc2e2022-10-27 18:30:53 -040018import { 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
Michelle Sepkap Simef5ebc2e2022-10-27 18:30:53 -040022import { ReactComponent as JamiLogo } from '../icons/jami-logo-icon.svg';
23
Adrien Béraud34995902021-06-07 10:12:00 -040024const 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();
Michelle Sepkap Simef5ebc2e2022-10-27 18:30:53 -040054 } else {
simond47ef9e2022-09-28 22:24:28 -040055 setVisible(false);
56 }
57 }}
58 >
Adrien Béraud34995902021-06-07 10:12:00 -040059 <motion.div variants={item}>
Michelle Sepkap Simef5ebc2e2022-10-27 18:30:53 -040060 <JamiLogo width="95%" />
simond47ef9e2022-09-28 22:24:28 -040061 </motion.div>
62 <motion.h1 variants={item}>Welcome to Jami</motion.h1>
simond47ef9e2022-09-28 22:24:28 -040063 </motion.div>
64 )}
65 </AnimatePresence>
Adrien Béraud34995902021-06-07 10:12:00 -040066 </Container>
simond47ef9e2022-09-28 22:24:28 -040067 );
68}