Skip to content

Instantly share code, notes, and snippets.

@amandeepmittal
Created December 6, 2018 13:28
Show Gist options
  • Save amandeepmittal/f6725a1672b43897743596dee4f5baac to your computer and use it in GitHub Desktop.
Save amandeepmittal/f6725a1672b43897743596dee4f5baac to your computer and use it in GitHub Desktop.
import Link from 'next/link';
const StoryList = ({ stories }) => (
<div className="story-list">
{stories.map(story => (
<div key={story.id} className="story">
<h2 className="story-title">
<a href={story.url} target="_blank">
{story.title}
</a>
</h2>
<div className="story-detail">
<span>{story.points || 0} points</span>
<Link href={`/story?id=${story.id}`}>
<a>{story.comments_count || 0} comments</a>
</Link>
</div>
</div>
))}
<style jsx>
{`
.story-list {
padding: 0 1em;
}
.story {
padding: 1em 0;
}
.story-title {
font-size: 1rem;
font-weight: 400;
margin: 0;
margin-bottom: 0.5rem;
}
.story-title a {
color: #444444;
text-decoration: none;
}
.story-title a:hover,
.story-detail a:hover {
text-decoration: underline;
}
.story-detail {
font-size: 0.8rem;
font-weight: bold;
}
.story-detail span {
margin-right: 1rem;
}
.story-detail a {
color: #ffa500;
text-decoration: none;
}
`}
</style>
</div>
);
export default StoryList;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment