forked from tanner/qotnews
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,10 +39,7 @@ 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>
|
|
||||||
:
|
|
||||||
<div>
|
|
||||||
{story ?
|
{story ?
|
||||||
<div className='article'>
|
<div className='article'>
|
||||||
<h1>{story.title}</h1>
|
<h1>{story.title}</h1>
|
||||||
|
@ -64,8 +61,6 @@ class Article extends React.Component {
|
||||||
}
|
}
|
||||||
<ToggleDot id={id} article={false} />
|
<ToggleDot id={id} article={false} />
|
||||||
</div>
|
</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,10 +58,7 @@ class Article extends React.Component {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='container'>
|
<div className='container'>
|
||||||
{error ?
|
{error && <p>Connection error?</p>}
|
||||||
<p>Something went wrong.</p>
|
|
||||||
:
|
|
||||||
<div>
|
|
||||||
{story ?
|
{story ?
|
||||||
<div className='article'>
|
<div className='article'>
|
||||||
<h1>{story.title}</h1>
|
<h1>{story.title}</h1>
|
||||||
|
@ -81,8 +78,6 @@ class Article extends React.Component {
|
||||||
}
|
}
|
||||||
<ToggleDot id={id} article={true} />
|
<ToggleDot id={id} article={true} />
|
||||||
</div>
|
</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) {
|
||||||
|
@ -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,10 +45,7 @@ class Feed extends React.Component {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='container'>
|
<div className='container'>
|
||||||
{error ?
|
{error && <p>Connection error?</p>}
|
||||||
<p>Something went wrong.</p>
|
|
||||||
:
|
|
||||||
<div>
|
|
||||||
{stories ?
|
{stories ?
|
||||||
<div>
|
<div>
|
||||||
{stories.map((x, i) =>
|
{stories.map((x, i) =>
|
||||||
|
@ -58,7 +55,7 @@ class Feed extends React.Component {
|
||||||
</div>
|
</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)})
|
||||||
|
@ -73,8 +70,6 @@ class Feed extends React.Component {
|
||||||
<p>loading...</p>
|
<p>loading...</p>
|
||||||
}
|
}
|
||||||
</div>
|
</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