Fixed Missing Code from merge
This commit is contained in:
parent
9063a0ea19
commit
7cf9954f7f
|
|
@ -4,6 +4,7 @@ import "./css/App.css";
|
||||||
import Navigation from './Navigation';
|
import Navigation from './Navigation';
|
||||||
import Github from './Github';
|
import Github from './Github';
|
||||||
import Articles from './Articles';
|
import Articles from './Articles';
|
||||||
|
import ArticleEditor from './ArticleEditor';
|
||||||
import About from './About';
|
import About from './About';
|
||||||
import Intro from './Intro';
|
import Intro from './Intro';
|
||||||
|
|
||||||
|
|
@ -18,6 +19,7 @@ const App = (props) => {
|
||||||
<Route path="/github" render={(props) => <Github {...props} />} />
|
<Route path="/github" render={(props) => <Github {...props} />} />
|
||||||
<Route path="/about" component={About} />
|
<Route path="/about" component={About} />
|
||||||
<Route path="/articles" component={Articles} />
|
<Route path="/articles" component={Articles} />
|
||||||
|
<Route path="/articleEditor" component={ArticleEditor} />
|
||||||
</Switch>
|
</Switch>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,49 @@
|
||||||
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 === ""){ // If no articles have been opened
|
||||||
|
if (show === "") {
|
||||||
|
// Set the current article and initiate the open animation
|
||||||
|
setCurrArticle(article);
|
||||||
|
setShow("open");
|
||||||
|
|
||||||
|
// Once the animation runs, open the entire article
|
||||||
|
setTimeout(() =>{
|
||||||
|
setShow("show");
|
||||||
|
}, 1024)
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (currArticle !== article) { // If we've changed articles
|
||||||
|
// Change currArticle to the actual current article and initiate close animation
|
||||||
|
setCurrArticle(article);
|
||||||
|
setShow("close");
|
||||||
|
|
||||||
|
// Step through the close animation, open animation, and fully opening the article
|
||||||
|
setTimeout(()=>{
|
||||||
|
setShow("");
|
||||||
|
|
||||||
|
setTimeout(()=>{
|
||||||
|
|
||||||
|
setShow("open");
|
||||||
|
|
||||||
|
setTimeout(() =>{
|
||||||
|
setShow("show");
|
||||||
|
}, 1024);
|
||||||
|
}, 1024);
|
||||||
|
}, 24);
|
||||||
|
}
|
||||||
|
}, [currArticle, article, show]);
|
||||||
|
|
||||||
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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let output = [""]; // Stores all text in a list
|
let output = [""]; // Stores all text in a list
|
||||||
let loc = 0; // Stores the current location in output that we're working with
|
let loc = 0; // Stores the current location in output that we're working with
|
||||||
let tmp;
|
let tmp;
|
||||||
|
|
@ -127,6 +163,7 @@ const Article = ({article}) => {
|
||||||
|
|
||||||
let text = linkProcessor(output[i]); // Process links
|
let text = linkProcessor(output[i]); // Process links
|
||||||
text = newLineProcessor(text);
|
text = newLineProcessor(text);
|
||||||
|
|
||||||
if (type[i] === 0){ // Return default text type
|
if (type[i] === 0){ // Return default text type
|
||||||
|
|
||||||
return <div key={i}>{text}</div>;
|
return <div key={i}>{text}</div>;
|
||||||
|
|
@ -152,7 +189,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}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
import Article from './Article';
|
||||||
|
import "./css/ArticleEditor.css";
|
||||||
|
|
||||||
|
const ArticleEditor = (props) => {
|
||||||
|
const [content, setContent] = useState("Hello World");
|
||||||
|
|
||||||
|
let article = {
|
||||||
|
"id":"0",
|
||||||
|
"title": "Article Editor",
|
||||||
|
"desc":"This is a place to edit articles",
|
||||||
|
"contents": content
|
||||||
|
};
|
||||||
|
|
||||||
|
let copyToClipboard = () => {
|
||||||
|
navigator.clipboard.writeText(content).then(function() {
|
||||||
|
console.log('Async: Copying to clipboard was successful!');
|
||||||
|
}, function(err) {
|
||||||
|
console.error('Async: Could not copy text: ', err);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="ArticleEditor">
|
||||||
|
<div id="toolbar" className="toolbar">
|
||||||
|
<div className="btn" onClick={copyToClipboard()}>Copy to Clipboard</div>
|
||||||
|
</div>
|
||||||
|
<Article article={article}/>
|
||||||
|
<textarea onInput={e=>{setContent(e.target.value)}}></textarea>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ArticleEditor;
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
.ArticleEditor textarea {
|
||||||
|
width:100%;
|
||||||
|
height: 35vh;
|
||||||
|
border-style: solid;
|
||||||
|
border-color: lightgray;
|
||||||
|
border-radius: 2px;
|
||||||
|
border-width: 2px;
|
||||||
|
padding: 0.4em 0.4em 0.4em 0;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ArticleEditor .toolbar {
|
||||||
|
width: 100%;
|
||||||
|
height: 56px;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ArticleEditor .toolbar .btn {
|
||||||
|
color: white;
|
||||||
|
background-color: darkgreen;
|
||||||
|
text-align: center;
|
||||||
|
align-items:center;
|
||||||
|
justify-content: center;
|
||||||
|
display: flex;
|
||||||
|
padding-left: 3px;
|
||||||
|
padding-right: 3px;
|
||||||
|
}
|
||||||
|
.ArticleEditor .toolbar .btn:hover{
|
||||||
|
background-color: #005400
|
||||||
|
}
|
||||||
|
|
||||||
|
.ArticleEditor .article .open {
|
||||||
|
max-height:100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ArticleEditor .article .Close {
|
||||||
|
max-height:100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ArticleEditor .article {
|
||||||
|
max-height:100vh;
|
||||||
|
}
|
||||||
|
|
@ -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