simon | 26e79f7 | 2022-10-05 22:16:08 -0400 | [diff] [blame] | 1 | /* |
| 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 Sime | f5ebc2e | 2022-10-27 18:30:53 -0400 | [diff] [blame] | 18 | import { Container } from '@mui/material'; |
Adrien Béraud | 3499590 | 2021-06-07 10:12:00 -0400 | [diff] [blame] | 19 | import { AnimatePresence, motion } from 'framer-motion'; |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 20 | import { useState } from 'react'; |
simon | 07b4eb0 | 2022-09-29 17:50:26 -0400 | [diff] [blame] | 21 | |
Michelle Sepkap Sime | f5ebc2e | 2022-10-27 18:30:53 -0400 | [diff] [blame] | 22 | import { ReactComponent as JamiLogo } from '../icons/jami-logo-icon.svg'; |
| 23 | |
Adrien Béraud | 3499590 | 2021-06-07 10:12:00 -0400 | [diff] [blame] | 24 | const list = { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 25 | hidden: { opacity: 0 }, |
| 26 | visible: { |
| 27 | opacity: 1, |
| 28 | transition: { |
| 29 | when: 'beforeChildren', |
| 30 | staggerChildren: 0.3, |
| 31 | }, |
| 32 | }, |
| 33 | }; |
Adrien Béraud | 3499590 | 2021-06-07 10:12:00 -0400 | [diff] [blame] | 34 | const item = { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 35 | visible: { opacity: 1, x: 0 }, |
| 36 | hidden: { opacity: 0, x: 0 }, |
| 37 | }; |
Adrien Béraud | 3499590 | 2021-06-07 10:12:00 -0400 | [diff] [blame] | 38 | |
| 39 | export default function WelcomeAnimation(props) { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 40 | const [visible, setVisible] = useState(true); |
Adrien Béraud | 3499590 | 2021-06-07 10:12:00 -0400 | [diff] [blame] | 41 | |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 42 | 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 Sime | f5ebc2e | 2022-10-27 18:30:53 -0400 | [diff] [blame] | 54 | } else { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 55 | setVisible(false); |
| 56 | } |
| 57 | }} |
| 58 | > |
Adrien Béraud | 3499590 | 2021-06-07 10:12:00 -0400 | [diff] [blame] | 59 | <motion.div variants={item}> |
Michelle Sepkap Sime | f5ebc2e | 2022-10-27 18:30:53 -0400 | [diff] [blame] | 60 | <JamiLogo width="95%" /> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 61 | </motion.div> |
| 62 | <motion.h1 variants={item}>Welcome to Jami</motion.h1> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 63 | </motion.div> |
| 64 | )} |
| 65 | </AnimatePresence> |
Adrien Béraud | 3499590 | 2021-06-07 10:12:00 -0400 | [diff] [blame] | 66 | </Container> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 67 | ); |
| 68 | } |