qotnews/webclient/src/utils.js

60 lines
15 KiB
JavaScript
Raw Normal View History

2019-08-24 05:04:51 +00:00
import React from 'react';
import moment from 'moment';
import { Link } from 'react-router-dom';
export const sourceLink = (story) => {
const url = story.url || story.link;
const urlObj = new URL(url);
const host = urlObj.hostname.replace(/^www\./, '');
return (<a className='source' href={url}>{host}</a>);
};
export const infoLine = (story) =>
<div className='info'>
{story.score} points
by <a href={story.author_link}>{story.author}</a>
&#8203; {moment.unix(story.date).fromNow()}
&#8203; on <a href={story.link}>{story.source}</a> | &#8203;
<Link className={story.num_comments > 99 ? 'hot' : ''} to={'/' + story.id + '/c'}>
2019-08-24 05:04:51 +00:00
{story.num_comments} comment{story.num_comments !== 1 && 's'}
</Link>
</div>
;
export class ToggleDot extends React.Component {
render() {
const id = this.props.id;
const article = this.props.article;
return (
<div className='toggleDot'>
<div className='button'>
<Link to={'/' + id + (article ? '' : '/c')}>
{article ? '' : ''}
</Link>
</div>
</div>
);
}
}
export class ForwardDot extends React.Component {
render() {
return (
<div className='forwardDot'>
<div className='button'>
<a href='javascript:void(0)' onClick={() => window.history.forward()}>
</a>
</div>
</div>
);
}
}
export const logos = {
hackernews: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH4wgeBhwhciGZUAAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAGCSURBVFjD7Za/S0JRFMc/+oSgLWjLH/2AIKEhC2opIp1amqw/INCo9lbHghCnKDdpN5OoIGhISSLwx2RCEYSjUWhWpO+9hicopCHh8w29Mx3u/XLv95z7Pedcg+y1VQEBbUw0ang5gGBEY9MJ6ARMbaH6HdBnBlmC+5PfsVYX9PTCSx4KyQ4RsI6DxwcYIGSFxF5znHkOtvZBECDoa4tAe0+QDMFDVvFd7ta4pU0QTAo2GeqwBqIHIEkwMAQzaz/3Lf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