From 95d738db3ced027b9080e61dfc068980406fc62c Mon Sep 17 00:00:00 2001 From: Camerin Figueroa Date: Tue, 23 Nov 2021 14:49:07 -0500 Subject: [PATCH] Added animation when opening/closing articles --- src/components/Article.js | 37 +++++++++++++++++++++++-- src/components/css/Articles.css | 18 ++++++++++++ src/components/css/Theater.css | 2 +- src/components/subcomponents/Listing.js | 5 ++-- 4 files changed, 56 insertions(+), 6 deletions(-) diff --git a/src/components/Article.js b/src/components/Article.js index 92112be..d014e3c 100644 --- a/src/components/Article.js +++ b/src/components/Article.js @@ -1,8 +1,39 @@ -import React from 'react'; +import React, { useEffect, useState } from 'react'; import Theater from './subcomponents/Theater'; import './css/Articles.css'; const Article = ({article}) => { + const [show, setShow] = useState(""); + const [currArticle, setCurrArticle] = useState(""); + + useEffect(()=>{ + if (currArticle === ""){ + console.log("A"); + if (show === "") { + setCurrArticle(article); + setShow("open"); + setTimeout(() =>{ + setShow("show"); + }, 1024) + } else { + setShow(""); + } + } else if (currArticle !== article) { + console.log("B"); + setCurrArticle(article); + setShow("close"); + setTimeout(()=>{ + setShow(""); + setTimeout(()=>{ + setShow("open"); + setTimeout(() =>{ + setShow("show"); + }, 1024); + }, 1024); + }, 24); + } + }); + let linkProcessor = (text) => { /** * Given some text, processes and returns jsx with any link represented as an anchor @@ -107,9 +138,9 @@ const Article = ({article}) => { }); }; - + return ( -
+
{ @@ -11,12 +12,12 @@ const Listing = (props) => { */ return (
- +
{props.title}
{props.children}
-
+
); };