Add site logos, keep displaying news on error
This commit is contained in:
parent
0053147226
commit
c7734eb2bc
BIN
webclient/public/logos/hackernews.png
Normal file
BIN
webclient/public/logos/hackernews.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 538 B |
BIN
webclient/public/logos/reddit.png
Normal file
BIN
webclient/public/logos/reddit.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.4 KiB |
BIN
webclient/public/logos/tildes.png
Normal file
BIN
webclient/public/logos/tildes.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 500 B |
|
@ -2,7 +2,7 @@ import React from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { sourceLink, infoLine, ToggleDot } from './utils.js';
|
import { sourceLink, infoLine, ToggleDot } from './utils.js';
|
||||||
|
|
||||||
const apiUrl = 'http://news-api.dns.t0.vc/';
|
const apiUrl = 'https://news-api.t0.vc/';
|
||||||
|
|
||||||
class Article extends React.Component {
|
class Article extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
|
@ -39,32 +39,27 @@ class Article extends React.Component {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='article-container'>
|
<div className='article-container'>
|
||||||
{error ?
|
{error && <p>Connection error?</p>}
|
||||||
<p>Something went wrong.</p>
|
{story ?
|
||||||
:
|
<div className='article'>
|
||||||
<div>
|
<h1>{story.title}</h1>
|
||||||
{story ?
|
|
||||||
<div className='article'>
|
|
||||||
<h1>{story.title}</h1>
|
|
||||||
|
|
||||||
<div className='info'>
|
<div className='info'>
|
||||||
Source: {sourceLink(story)}
|
Source: {sourceLink(story)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{infoLine(story)}
|
{infoLine(story)}
|
||||||
|
|
||||||
{story.text ?
|
{story.text ?
|
||||||
<div className='story-text' dangerouslySetInnerHTML={{ __html: story.text }} />
|
<div className='story-text' dangerouslySetInnerHTML={{ __html: story.text }} />
|
||||||
:
|
|
||||||
<p>Problem getting article :(</p>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
:
|
:
|
||||||
<p>loading...</p>
|
<p>Problem getting article :(</p>
|
||||||
}
|
}
|
||||||
<ToggleDot id={id} article={false} />
|
|
||||||
</div>
|
</div>
|
||||||
|
:
|
||||||
|
<p>loading...</p>
|
||||||
}
|
}
|
||||||
|
<ToggleDot id={id} article={false} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { Link } from 'react-router-dom';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { sourceLink, infoLine, ToggleDot } from './utils.js';
|
import { sourceLink, infoLine, ToggleDot } from './utils.js';
|
||||||
|
|
||||||
const apiUrl = 'http://news-api.dns.t0.vc/';
|
const apiUrl = 'https://news-api.t0.vc/';
|
||||||
|
|
||||||
class Article extends React.Component {
|
class Article extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
|
@ -58,30 +58,25 @@ class Article extends React.Component {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='container'>
|
<div className='container'>
|
||||||
{error ?
|
{error && <p>Connection error?</p>}
|
||||||
<p>Something went wrong.</p>
|
{story ?
|
||||||
:
|
<div className='article'>
|
||||||
<div>
|
<h1>{story.title}</h1>
|
||||||
{story ?
|
|
||||||
<div className='article'>
|
|
||||||
<h1>{story.title}</h1>
|
|
||||||
|
|
||||||
<div className='info'>
|
<div className='info'>
|
||||||
<Link to={'/' + story.id + '/a'}>View article</Link>
|
<Link to={'/' + story.id + '/a'}>View article</Link>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{infoLine(story)}
|
{infoLine(story)}
|
||||||
|
|
||||||
<div className='comments'>
|
<div className='comments'>
|
||||||
{story.comments.map(c => this.displayComment(story, c, 0))}
|
{story.comments.map(c => this.displayComment(story, c, 0))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
:
|
|
||||||
<p>loading...</p>
|
|
||||||
}
|
|
||||||
<ToggleDot id={id} article={true} />
|
|
||||||
</div>
|
</div>
|
||||||
|
:
|
||||||
|
<p>loading...</p>
|
||||||
}
|
}
|
||||||
|
<ToggleDot id={id} article={true} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { sourceLink, infoLine } from './utils.js';
|
import { siteLogo, sourceLink, infoLine } from './utils.js';
|
||||||
import { clearStorage } from './utils.js';
|
import { clearStorage } from './utils.js';
|
||||||
|
|
||||||
const apiUrl = 'http://news-api.dns.t0.vc/';
|
const apiUrl = 'https://news-api.t0.vc/';
|
||||||
|
|
||||||
class Feed extends React.Component {
|
class Feed extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
|
@ -14,7 +14,7 @@ class Feed extends React.Component {
|
||||||
error: false,
|
error: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
fetch(apiUrl)
|
fetch(apiUrl)
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
|
@ -23,7 +23,7 @@ class Feed extends React.Component {
|
||||||
this.setState({ stories: result.stories });
|
this.setState({ stories: result.stories });
|
||||||
clearStorage();
|
clearStorage();
|
||||||
localStorage.setItem('stories', JSON.stringify(result.stories));
|
localStorage.setItem('stories', JSON.stringify(result.stories));
|
||||||
result.stories.slice(0, 25).forEach(x => {
|
result.stories.filter(x => x.score >= 20).slice(0, 25).forEach(x => {
|
||||||
fetch(apiUrl + x.id)
|
fetch(apiUrl + x.id)
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(result => {
|
.then(result => {
|
||||||
|
@ -45,34 +45,29 @@ class Feed extends React.Component {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='container'>
|
<div className='container'>
|
||||||
{error ?
|
{error && <p>Connection error?</p>}
|
||||||
<p>Something went wrong.</p>
|
{stories ?
|
||||||
:
|
|
||||||
<div>
|
<div>
|
||||||
{stories ?
|
{stories.map((x, i) =>
|
||||||
<div>
|
<div className='item'>
|
||||||
{stories.map((x, i) =>
|
<div className='num'>
|
||||||
<div className='item'>
|
{i+1}.
|
||||||
<div className='num'>
|
</div>
|
||||||
{i+1}.
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className='title'>
|
<div className='title'>
|
||||||
<Link className='link' to={'/' + x.id + '/a'}>{x.title}</Link>
|
<Link className='link' to={'/' + x.id + '/a'}>{siteLogo[x.source]} {x.title}</Link>
|
||||||
|
|
||||||
<span className='source'>
|
<span className='source'>
|
||||||
​({sourceLink(x)})
|
​({sourceLink(x)})
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{infoLine(x)}
|
{infoLine(x)}
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
:
|
)}
|
||||||
<p>loading...</p>
|
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
|
:
|
||||||
|
<p>loading...</p>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -10,6 +10,10 @@
|
||||||
color: #828282;
|
color: #828282;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dark .item .source-logo {
|
||||||
|
filter: grayscale(1);
|
||||||
|
}
|
||||||
|
|
||||||
.dark .item a {
|
.dark .item a {
|
||||||
color: #828282;
|
color: #828282;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,11 @@ a {
|
||||||
margin-bottom: 0.6rem;
|
margin-bottom: 0.6rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.item .source-logo {
|
||||||
|
width: 0.9rem;
|
||||||
|
height: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
.item a {
|
.item a {
|
||||||
color: #828282;
|
color: #828282;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,12 @@ export const sourceLink = (story) => {
|
||||||
return (<a className='source' href={url}>{host}</a>);
|
return (<a className='source' href={url}>{host}</a>);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const siteLogo = {
|
||||||
|
hackernews: <img className='source-logo' src='logos/hackernews.png' />,
|
||||||
|
tildes: <img className='source-logo' src='logos/tildes.png' />,
|
||||||
|
reddit: <img className='source-logo' src='logos/reddit.png' />,
|
||||||
|
};
|
||||||
|
|
||||||
export const infoLine = (story) =>
|
export const infoLine = (story) =>
|
||||||
<div className='info'>
|
<div className='info'>
|
||||||
{story.score} points
|
{story.score} points
|
||||||
|
|
Loading…
Reference in New Issue
Block a user