blob: 66edb9f93bc8bb85f7152dc75b986a5e38a9773b [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';
Michelle Sepkap Sime559cc802022-11-05 12:06:40 -040021import { useTranslation } from 'react-i18next';
simon07b4eb02022-09-29 17:50:26 -040022
Michelle Sepkap Simef5ebc2e2022-10-27 18:30:53 -040023import { ReactComponent as JamiLogo } from '../icons/jami-logo-icon.svg';
24
Adrien Béraud34995902021-06-07 10:12:00 -040025const list = {
simond47ef9e2022-09-28 22:24:28 -040026 hidden: { opacity: 0 },
27 visible: {
28 opacity: 1,
29 transition: {
30 when: 'beforeChildren',
31 staggerChildren: 0.3,
32 },
33 },
34};
Adrien Béraud34995902021-06-07 10:12:00 -040035const item = {
simond47ef9e2022-09-28 22:24:28 -040036 visible: { opacity: 1, x: 0 },
37 hidden: { opacity: 0, x: 0 },
38};
Adrien Béraud34995902021-06-07 10:12:00 -040039
40export default function WelcomeAnimation(props) {
Michelle Sepkap Sime559cc802022-11-05 12:06:40 -040041 const { t } = useTranslation();
simond47ef9e2022-09-28 22:24:28 -040042 const [visible, setVisible] = useState(true);
Adrien Béraud34995902021-06-07 10:12:00 -040043
simond47ef9e2022-09-28 22:24:28 -040044 return (
45 <Container style={{ textAlign: 'center', display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
46 <AnimatePresence>
47 {visible && (
48 <motion.div
49 initial="hidden"
50 animate="visible"
51 exit="hidden"
52 variants={list}
53 onAnimationComplete={(a) => {
54 if (a === 'hidden') {
55 props.onComplete();
Michelle Sepkap Simef5ebc2e2022-10-27 18:30:53 -040056 } else {
simond47ef9e2022-09-28 22:24:28 -040057 setVisible(false);
58 }
59 }}
60 >
Adrien Béraud34995902021-06-07 10:12:00 -040061 <motion.div variants={item}>
Michelle Sepkap Simef5ebc2e2022-10-27 18:30:53 -040062 <JamiLogo width="95%" />
simond47ef9e2022-09-28 22:24:28 -040063 </motion.div>
Michelle Sepkap Sime559cc802022-11-05 12:06:40 -040064 <motion.h1 variants={item}>{t('welcome_text')}</motion.h1>
simond47ef9e2022-09-28 22:24:28 -040065 </motion.div>
66 )}
67 </AnimatePresence>
Adrien Béraud34995902021-06-07 10:12:00 -040068 </Container>
simond47ef9e2022-09-28 22:24:28 -040069 );
70}