Added animation when opening/closing articles
This commit is contained in:
parent
d8e5dbe1a4
commit
95d738db3c
|
|
@ -1,8 +1,39 @@
|
||||||
import React from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import Theater from './subcomponents/Theater';
|
import Theater from './subcomponents/Theater';
|
||||||
import './css/Articles.css';
|
import './css/Articles.css';
|
||||||
|
|
||||||
const Article = ({article}) => {
|
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) => {
|
let linkProcessor = (text) => {
|
||||||
/**
|
/**
|
||||||
* Given some text, processes and returns jsx with any link represented as an anchor
|
* Given some text, processes and returns jsx with any link represented as an anchor
|
||||||
|
|
@ -109,7 +140,7 @@ const Article = ({article}) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="article">
|
<div className={"article " + show}>
|
||||||
<Theater
|
<Theater
|
||||||
title={article.title}
|
title={article.title}
|
||||||
description={article.desc}
|
description={article.desc}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,24 @@
|
||||||
align-items: center;
|
align-items: center;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
max-height:0;
|
||||||
|
overflow: hidden;
|
||||||
|
transition: max-height 1s ease;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.article.open {
|
||||||
|
max-height:100vh;
|
||||||
|
transition: max-height 1s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article.close {
|
||||||
|
max-height:100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article.show {
|
||||||
|
max-height:none;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.article .content {
|
.article .content {
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
.theater-bg {
|
.theater-bg {
|
||||||
|
|
||||||
height: 100%;
|
height: inherit;
|
||||||
width:100%;
|
width:100%;
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
background-image: url('../../img/background.webp');
|
background-image: url('../../img/background.webp');
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
import '../css/Listing.css';
|
import '../css/Listing.css';
|
||||||
|
|
||||||
const Listing = (props) => {
|
const Listing = (props) => {
|
||||||
|
|
@ -11,12 +12,12 @@ const Listing = (props) => {
|
||||||
*/
|
*/
|
||||||
return (
|
return (
|
||||||
<div className="listing">
|
<div className="listing">
|
||||||
<a href={props.link}>
|
<Link to={props.link}>
|
||||||
<div className="title">{props.title}</div>
|
<div className="title">{props.title}</div>
|
||||||
<div className="content">
|
<div className="content">
|
||||||
{props.children}
|
{props.children}
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue