extract story list item from Results and Feed.
This commit is contained in:
parent
b23e470317
commit
b80c1a5cb5
|
@ -5,13 +5,14 @@ import './Style-light.css';
|
||||||
import './Style-dark.css';
|
import './Style-dark.css';
|
||||||
import './fonts/Fonts.css';
|
import './fonts/Fonts.css';
|
||||||
import { ForwardDot } from './utils.js';
|
import { ForwardDot } from './utils.js';
|
||||||
import Feed from './Feed.js';
|
|
||||||
import Article from './Article.js';
|
|
||||||
import Comments from './Comments.js';
|
|
||||||
import Search from './Search.js';
|
import Search from './Search.js';
|
||||||
import Submit from './Submit.js';
|
import Submit from './Submit.js';
|
||||||
import Results from './Results.js';
|
|
||||||
import ScrollToTop from './ScrollToTop.js';
|
import ScrollToTop from './ScrollToTop.js';
|
||||||
|
import Feed from './pages/Feed.js';
|
||||||
|
import Article from './pages/Article.js';
|
||||||
|
import Comments from './pages/Comments.js';
|
||||||
|
import Results from './pages/Results.js';
|
||||||
|
|
||||||
|
|
||||||
class App extends React.Component {
|
class App extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
|
|
34
webclient/src/components/StoryItem.js
Normal file
34
webclient/src/components/StoryItem.js
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
import React from "react";
|
||||||
|
import { Link } from "react-router-dom";
|
||||||
|
import { sourceLink, infoLine, getLogoUrl } from "../utils.js";
|
||||||
|
|
||||||
|
export class StoryItem extends React.Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const story = this.props.story;
|
||||||
|
const { id, title } = story;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="item" key={id}>
|
||||||
|
<div className="title">
|
||||||
|
<Link className="link" to={"/" + id}>
|
||||||
|
<img
|
||||||
|
className="source-logo"
|
||||||
|
src={getLogoUrl(story)}
|
||||||
|
alt="source logo"
|
||||||
|
/>
|
||||||
|
{" "}
|
||||||
|
{title}
|
||||||
|
</Link>
|
||||||
|
|
||||||
|
<span className="source">({sourceLink(story)})</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{infoLine(story)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Helmet } from 'react-helmet';
|
import { Helmet } from 'react-helmet';
|
||||||
import localForage from 'localforage';
|
import localForage from 'localforage';
|
||||||
import { sourceLink, infoLine, ToggleDot } from './utils.js';
|
import { sourceLink, infoLine, ToggleDot } from '../utils.js';
|
||||||
|
|
||||||
class Article extends React.Component {
|
class Article extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
|
@ -4,7 +4,7 @@ import { HashLink } from 'react-router-hash-link';
|
||||||
import { Helmet } from 'react-helmet';
|
import { Helmet } from 'react-helmet';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import localForage from 'localforage';
|
import localForage from 'localforage';
|
||||||
import { infoLine, ToggleDot } from './utils.js';
|
import { infoLine, ToggleDot } from '../utils.js';
|
||||||
|
|
||||||
class Article extends React.Component {
|
class Article extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
|
@ -1,8 +1,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
|
||||||
import { Helmet } from 'react-helmet';
|
import { Helmet } from 'react-helmet';
|
||||||
import localForage from 'localforage';
|
import localForage from 'localforage';
|
||||||
import { sourceLink, infoLine, getLogoUrl } from './utils.js';
|
import { StoryItem } from '../components/StoryItem.js';
|
||||||
|
|
||||||
class Feed extends React.Component {
|
class Feed extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
|
@ -56,27 +55,7 @@ class Feed extends React.Component {
|
||||||
<title>Feed - QotNews</title>
|
<title>Feed - QotNews</title>
|
||||||
</Helmet>
|
</Helmet>
|
||||||
{error && <p>Connection error?</p>}
|
{error && <p>Connection error?</p>}
|
||||||
{stories ?
|
{stories ? stories.map(story => <StoryItem story={story}></StoryItem>) : <p>loading...</p>}
|
||||||
<div>
|
|
||||||
{stories.map(x =>
|
|
||||||
<div className='item' key={x.id}>
|
|
||||||
<div className='title'>
|
|
||||||
<Link className='link' to={'/' + x.id}>
|
|
||||||
<img className='source-logo' src={getLogoUrl(x)} alt='source logo' /> {x.title}
|
|
||||||
</Link>
|
|
||||||
|
|
||||||
<span className='source'>
|
|
||||||
({sourceLink(x)})
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{infoLine(x)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
:
|
|
||||||
<p>loading...</p>
|
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
|
@ -1,8 +1,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
|
||||||
import { Helmet } from 'react-helmet';
|
import { Helmet } from 'react-helmet';
|
||||||
import { sourceLink, infoLine, getLogoUrl } from './utils.js';
|
|
||||||
import AbortController from 'abort-controller';
|
import AbortController from 'abort-controller';
|
||||||
|
import { StoryItem } from '../components/StoryItem.js';
|
||||||
|
|
||||||
class Results extends React.Component {
|
class Results extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
|
@ -63,25 +62,7 @@ class Results extends React.Component {
|
||||||
<>
|
<>
|
||||||
<p>Search results:</p>
|
<p>Search results:</p>
|
||||||
<div className='comment lined'>
|
<div className='comment lined'>
|
||||||
{stories.length ?
|
{stories ? stories.map(story => <StoryItem story={story}></StoryItem>) : <p>loading...</p>}
|
||||||
stories.map(x =>
|
|
||||||
<div className='item' key={x.id}>
|
|
||||||
<div className='title'>
|
|
||||||
<Link className='link' to={'/' + x.id}>
|
|
||||||
<img className='source-logo' src={getLogoUrl(x)} alt='source logo' /> {x.title}
|
|
||||||
</Link>
|
|
||||||
|
|
||||||
<span className='source'>
|
|
||||||
({sourceLink(x)})
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{infoLine(x)}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
:
|
|
||||||
<p>none</p>
|
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
:
|
:
|
Loading…
Reference in New Issue
Block a user