Skip to content

Commit

Permalink
Merge pull request #25 from LatestPrivacy/news-page
Browse files Browse the repository at this point in the history
Merge news-page branch and extras
  • Loading branch information
LukeSeers authored Jul 14, 2020
2 parents f546641 + 2503aee commit 187de69
Show file tree
Hide file tree
Showing 16 changed files with 7,504 additions and 5,616 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
.env.development.local
.env.test.local
.env.production.local
/.idea

npm-debug.log*
yarn-debug.log*
Expand Down
7,813 changes: 4,408 additions & 3,405 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,22 @@
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react-helmet": "^5.2.1",
"react-infinite-scroll-component": "^5.0.5",
"react-inview-monitor": "^2.2.1",
"react-moment": "^0.9.7",
"react-router-dom": "^5.0.1",
"react-router-hash-link": "^1.2.2",
"react-scripts": "3.1.1",
"react-scroll-parallax": "^2.1.2",
"react-scroll-parallax": "^2.3.4",
"react-slick": "^0.25.2",
"react-spinners": "^0.9.0",
"react-spring": "^8.0.27",
"react-tooltip": "^4.2.7",
"scrollmonitor-react": "^2.4.1",
"slick-carousel": "^1.8.1"
},
"devDependencies": {
"http-proxy-middleware": "^1.0.4"
"http-proxy-middleware": "^1.0.5"
},
"scripts": {
"start": "react-scripts start",
Expand Down
4 changes: 2 additions & 2 deletions src/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ class Header extends Component {
render() {
const menus = [
{
url: "#news",
url: "/news",
text: "News",
type: "hash"
type: "link"
},

{
Expand Down
137 changes: 65 additions & 72 deletions src/components/HomeDonate.js
Original file line number Diff line number Diff line change
@@ -1,82 +1,75 @@
import React, { useState, useEffect } from 'react'
import React, { useState, useEffect } from 'react';
import axios from 'axios';

import axios from 'axios'
import BodyTextAnimation from '../components/BodyTextAnimation';
import HeadingAnimation from './HeadingAnimation';
import ButtonExternal from '../components/ButtonExternal';
import InViewMonitor from 'react-inview-monitor';

import BodyTextAnimation from '../components/BodyTextAnimation'
import HeadingAnimation from './HeadingAnimation'
import InViewMonitor from 'react-inview-monitor'
import ButtonExternal from '../components/ButtonExternal'

import Style from './HomeDonate.module.scss'
import Style from './HomeDonate.module.scss';

const HomeDonate = () => {

const [data, setData] = useState({})
const [loading, setLoading] = useState(true)
const [ data, setData ] = useState( [] );

useEffect( () => {
const fetchData = async () => {
try {
const response = await axios.get( '/donate/latestprivacy.json' );

useEffect(() => {
axios.get("/donate/latestprivacy.json")
.then(res => {
setData(res.data)
setLoading(false)
//setTimeout(() => setLoading(false), 3000)
})
.catch(err => {
console.log(err)
})
}, [])
setData( data => response.data );
} catch( err ) {
setData( { 'balance': 0, 'backersCount': 0 } );
};
};

if (!data) {
return <div style={{ 'textAlign': 'center'}}>didn't get a news data</div>;
}
fetchData();
}, [] );

return (
<InViewMonitor classNameInView="animated-in">
<div className={`${Style.donate} container`} id="donate">
<div className={Style.donateLeft}>
<HeadingAnimation className={Style.title} delay={0} duration={0.7} color="#ffffff">
<h3>Our Balance</h3>
</HeadingAnimation>
<br />
<HeadingAnimation className={Style.amount} delay={0.2} duration={0.7} color="#ffffff">
<h1>£{data.balance / 100}</h1>
</HeadingAnimation>

<div className="donate__status">
<BodyTextAnimation delay={0.4} duration={0.7}>
<div className="donate__status__item">
<span>{data.backersCount}</span>
<span>Donators</span>
</div>
</BodyTextAnimation>
<BodyTextAnimation delay={0.6} duration={0.7}>
<div className="donate__status__item">
<span>0</span>
<span>Sponsors</span>
</div>
</BodyTextAnimation>
</div>
</div>
<div className={Style.donateRight}>
<HeadingAnimation className={Style.titleRight} delay={0.8} duration={0.7} color="#ffffff">
<h2>Public Funding Transparency</h2>
</HeadingAnimation>
<BodyTextAnimation delay={1} duration={0.7}>
<p>We believe in being open about the public funds we receive. You can see where it's from and also where it's being spent.</p>
</BodyTextAnimation>

<div className="donate__button">
<BodyTextAnimation delay={1.2} duration={0.7}>
<ButtonExternal url="https://opencollective.com/latestprivacy/updates" value="Our Blogs"/>
</BodyTextAnimation>
<BodyTextAnimation delay={1.4} duration={0.7}>
<ButtonExternal url="https://opencollective.com/latestprivacy#section-contribute" value="Support Us" type="line" />
</BodyTextAnimation>
</div>
</div>
</div>
</InViewMonitor>
)
return (
<InViewMonitor classNameInView="animated-in">
<div className={`${Style.donate} container`} id="donate">
<div className={Style.donateLeft}>
<HeadingAnimation className={Style.title} delay={0} duration={0.7} color="#ffffff">
<h3>Our Balance</h3>
</HeadingAnimation>
<br />
<HeadingAnimation className={Style.amount} delay={0.2} duration={0.7} color="#ffffff">
<h1>£{data.balance / 100}</h1>
</HeadingAnimation>
<div className="donate__status">
<BodyTextAnimation delay={0.4} duration={0.7}>
<div className="donate__status__item">
<span>{data.backersCount}</span>
<span>Donators</span>
</div>
</BodyTextAnimation>
<BodyTextAnimation delay={0.6} duration={0.7}>
<div className="donate__status__item">
<span>0</span>
<span>Sponsors</span>
</div>
</BodyTextAnimation>
</div>
</div>
<div className={Style.donateRight}>
<HeadingAnimation className={Style.titleRight} delay={0.8} duration={0.7} color="#ffffff">
<h2>Public Funding Transparency</h2>
</HeadingAnimation>
<BodyTextAnimation delay={1} duration={0.7}>
<p>We believe in being open about the public funds we receive. You can see where it's from and also where it's being spent.</p>
</BodyTextAnimation>
<div className="donate__button">
<BodyTextAnimation delay={1.2} duration={0.7}>
<ButtonExternal url="https://opencollective.com/latestprivacy/updates" value="Our Blogs"/>
</BodyTextAnimation>
<BodyTextAnimation delay={1.4} duration={0.7}>
<ButtonExternal url="https://opencollective.com/latestprivacy#section-contribute" value="Support Us" type="line" />
</BodyTextAnimation>
</div>
</div>
</div>
</InViewMonitor>
)
}

export default HomeDonate
16 changes: 9 additions & 7 deletions src/components/HomeMission.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import React, { Component } from 'react'
import BodyTextAnimation from '../components/BodyTextAnimation'
import InViewMonitor from 'react-inview-monitor'
import Section from '../components/Section'
import TitleAndDescription from '../components/TitleAndDescription'
import React, { Component } from 'react';

import Style from './HomeMission.module.scss'
import Cams from '../assets/images/cams.png';
import BodyTextAnimation from '../components/BodyTextAnimation';
import InViewMonitor from 'react-inview-monitor';
import Section from '../components/Section';
import TitleAndDescription from '../components/TitleAndDescription';

import Style from './HomeMission.module.scss';

//import Cams from '../assets/images/cams.png';

class HomeMission extends Component {
render() {
Expand Down
128 changes: 59 additions & 69 deletions src/components/HomeNews.js
Original file line number Diff line number Diff line change
@@ -1,82 +1,72 @@
import React, { useState, useEffect } from 'react'

import axios from 'axios'
import React, { useState, useEffect } from 'react';
import axios from 'axios';

import HeadingAnimation from './HeadingAnimation';
import BodyTextAnimation from '../components/BodyTextAnimation';
import NewsItem from '../components/NewsItem';
import Button from '../components/Button';
import InViewMonitor from 'react-inview-monitor';
import BodyTextAnimation from '../components/BodyTextAnimation'
import NewsItem from '../components/NewsItem'
import Button from '../components/Button'

import Style from './HomeNews.module.scss'
import SyncLoader from 'react-spinners/SyncLoader';

const HomeNews = () => {
import Style from './HomeNews.module.scss';

const [data, setData] = useState({})
const [loading, setLoading] = useState(true)
const limit = 8;

useEffect(() => {
axios.get("/api/articles?limit=8")
.then(res => {
setData(res.data)
setLoading(false)
//setTimeout(() => setLoading(false), 3000)
})
.catch(err => {
console.log(err)
})
}, [])
const HomeNews = () => {
const [ data, setData ] = useState( [] );
const [ loading, setLoading ] = useState( true );

/*
async componentDidMount(){
const url = "/articles?limit=4"
const response = await fetch(url)
const data = await response.json()
console.log(data)
this.setState({
loading: false,
newsData: data
})
}
*/
useEffect( () => {
const fetchArticles = async () => {
try {
const response = await axios.get( `/api/articles?limit=${limit}` );

if (!data) {
return <div style={{ 'textAlign': 'center'}}>didn't get a news data</div>;
}
setData( data => response.data );
setLoading( false );
} catch( err ) {
console.log( err );
};
};

return (
<div className={`${Style.container} container`} id="news">
<InViewMonitor classNameInView="animated-in">
<HeadingAnimation className={Style.title} delay={0} duration={0.7} color="#ffffff">
<h3>Latest News</h3>
</HeadingAnimation>
fetchArticles();
}, [] );

<div className={Style.newsWrapper}>
{
loading ? <div style={{ 'gridColumn': 'span 12', 'textAlign': 'center'}}>loading...</div> :
data.map((news, i) => {
return(
<NewsItem
author = {news.publisher}
date = {news.published_on}
/*timetoread = {news.read_time}*/ /*NewsItem.js: Line 35*/ /*NewsDetail.js: Line 72*/
slug = {news.slug}
delay = { 0.6 + (i * 0.3) }
>
{news.title}
</NewsItem>
)
})
}
</div>
<div className={Style.buttonWrapper}>
<BodyTextAnimation duration={0.7} delay={2.7}>
<Button url="#" value="Coming Soon" />
</BodyTextAnimation>
</div>
</InViewMonitor>
</div>
)
return (
<div className={`${Style.container} container`} id="news">
<InViewMonitor classNameInView="animated-in">
<HeadingAnimation className={Style.title} delay={0} duration={0.7} color="#ffffff">
<h3>Latest News</h3>
</HeadingAnimation>
<div className={Style.newsWrapper}>
{loading
? <div style={{'gridColumn': 'span 12', 'textAlign': 'center'}}>
<SyncLoader
size={8}
color={'#656565'}
loading={loading}
/>
</div>
: data.map((item, index) => (
<NewsItem
author={item.publisher}
date={item.published_on}
/*timetoread={item.read_time}*/ /*NewsItem.js: Line 35*/ /*NewsDetail.js: Line 72*/
slug={item.slug}
delay={0.6 + (index * 0.3)}
>
{item.title}
</NewsItem>
))
}
</div>
<div className={Style.buttonWrapper}>
<BodyTextAnimation duration={0.7} delay={2.7}>
<Button url="/news" value="Explore More" />
</BodyTextAnimation>
</div>
</InViewMonitor>
</div>
)
}

export default HomeNews;
Loading

0 comments on commit 187de69

Please sign in to comment.