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 | */ |
Adrien Béraud | ab519ff | 2022-05-03 15:34:48 -0400 | [diff] [blame] | 18 | import { Button, 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 | |
Adrien Béraud | 3499590 | 2021-06-07 10:12:00 -0400 | [diff] [blame] | 22 | const list = { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 23 | hidden: { opacity: 0 }, |
| 24 | visible: { |
| 25 | opacity: 1, |
| 26 | transition: { |
| 27 | when: 'beforeChildren', |
| 28 | staggerChildren: 0.3, |
| 29 | }, |
| 30 | }, |
| 31 | }; |
Adrien Béraud | 3499590 | 2021-06-07 10:12:00 -0400 | [diff] [blame] | 32 | const item = { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 33 | visible: { opacity: 1, x: 0 }, |
| 34 | hidden: { opacity: 0, x: 0 }, |
| 35 | }; |
Adrien Béraud | 3499590 | 2021-06-07 10:12:00 -0400 | [diff] [blame] | 36 | |
| 37 | export default function WelcomeAnimation(props) { |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 38 | const [visible, setVisible] = useState(true); |
Adrien Béraud | 3499590 | 2021-06-07 10:12:00 -0400 | [diff] [blame] | 39 | |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 40 | return ( |
| 41 | <Container style={{ textAlign: 'center', display: 'flex', flexDirection: 'column', alignItems: 'center' }}> |
| 42 | <AnimatePresence> |
| 43 | {visible && ( |
| 44 | <motion.div |
| 45 | initial="hidden" |
| 46 | animate="visible" |
| 47 | exit="hidden" |
| 48 | variants={list} |
| 49 | onAnimationComplete={(a) => { |
| 50 | if (a === 'hidden') { |
| 51 | props.onComplete(); |
| 52 | } else if (!props.showSetup) { |
| 53 | setVisible(false); |
| 54 | } |
| 55 | }} |
| 56 | > |
Adrien Béraud | 3499590 | 2021-06-07 10:12:00 -0400 | [diff] [blame] | 57 | <motion.div variants={item}> |
simon | d8ca2f2 | 2022-10-11 23:30:55 -0400 | [diff] [blame^] | 58 | <img |
| 59 | src="/jami-logo-icon.svg" |
| 60 | style={{ |
| 61 | width: '32', |
| 62 | height: '32', |
| 63 | }} |
| 64 | alt="jami n/logo" |
| 65 | /> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 66 | </motion.div> |
| 67 | <motion.h1 variants={item}>Welcome to Jami</motion.h1> |
| 68 | {props.showSetup && ( |
| 69 | <motion.div variants={item}> |
| 70 | <Button variant="outlined" onClick={() => setVisible(false)}> |
| 71 | Start setup |
| 72 | </Button> |
| 73 | </motion.div> |
| 74 | )} |
| 75 | </motion.div> |
| 76 | )} |
| 77 | </AnimatePresence> |
Adrien Béraud | 3499590 | 2021-06-07 10:12:00 -0400 | [diff] [blame] | 78 | </Container> |
simon | d47ef9e | 2022-09-28 22:24:28 -0400 | [diff] [blame] | 79 | ); |
| 80 | } |