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