mirror of
https://github.com/mastermindzh/rickvanlieshout.com
synced 2025-08-06 01:18:14 +02:00
Upgrade to Gatsby v2
This commit is contained in:
29
src/components/Feed/Feed.js
Normal file
29
src/components/Feed/Feed.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import React from 'react';
|
||||
import moment from 'moment';
|
||||
import { Link } from 'gatsby';
|
||||
import styles from './Feed.module.scss';
|
||||
|
||||
const Feed = ({ edges }) => (
|
||||
<div className={styles['feed']}>
|
||||
{edges.map((edge) => (
|
||||
<div className={styles['feed__item']} key={edge.node.fields.slug}>
|
||||
<div className={styles['feed__item-meta']}>
|
||||
<time className={styles['feed__item-meta-time']} dateTime={moment(edge.node.frontmatter.date).format('MMMM D, YYYY')}>
|
||||
{moment(edge.node.frontmatter.date).format('MMMM YYYY')}
|
||||
</time>
|
||||
<span className={styles['feed__item-meta-divider']} />
|
||||
<span className={styles['feed__item-meta-category']}>
|
||||
<Link to={edge.node.fields.categorySlug} className={styles['feed__item-meta-category-link']}>{edge.node.frontmatter.category}</Link>
|
||||
</span>
|
||||
</div>
|
||||
<h2 className={styles['feed__item-title']}>
|
||||
<Link className={styles['feed__item-title-link']} to={edge.node.fields.slug}>{edge.node.frontmatter.title}</Link>
|
||||
</h2>
|
||||
<p className={styles['feed__item-description']}>{edge.node.frontmatter.description}</p>
|
||||
<Link className={styles['feed__item-readmore']} to={edge.node.fields.slug}>Read</Link>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
|
||||
export default Feed;
|
81
src/components/Feed/Feed.module.scss
Normal file
81
src/components/Feed/Feed.module.scss
Normal file
@@ -0,0 +1,81 @@
|
||||
@import '../../assets/scss/variables';
|
||||
@import '../../assets/scss/mixins';
|
||||
|
||||
.feed {
|
||||
&__item {
|
||||
@include margin-bottom(1.25);
|
||||
|
||||
&:last-child {
|
||||
@include margin-bottom(.5);
|
||||
}
|
||||
|
||||
&-title {
|
||||
font-size: $typographic-base-font-size * 1.6875;
|
||||
@include line-height(1.5);
|
||||
@include margin-top(0);
|
||||
@include margin-bottom(.5);
|
||||
|
||||
&-link {
|
||||
color: $color-base;
|
||||
|
||||
&:hover,
|
||||
&:focus {
|
||||
color: $color-base;
|
||||
border-bottom: 1px solid $color-base;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
&-description {
|
||||
font-size: $typographic-base-font-size;
|
||||
@include line-height(1);
|
||||
@include margin-bottom(.75);
|
||||
}
|
||||
|
||||
&-meta {
|
||||
&-time {
|
||||
font-size: $typographic-small-font-size;
|
||||
color: $color-base;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
&-divider {
|
||||
margin: 0 5px;
|
||||
}
|
||||
|
||||
&-category {
|
||||
&-link {
|
||||
font-size: $typographic-small-font-size;
|
||||
color: $color-secondary;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
|
||||
&:hover,
|
||||
&:focus {
|
||||
color: $color-primary;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
&-readmore {
|
||||
font-size: $typographic-base-font-size;
|
||||
color: $color-primary;
|
||||
|
||||
&:hover,
|
||||
&:focus {
|
||||
color: $color-primary;
|
||||
border-bottom: 1px solid $color-primary;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
43
src/components/Feed/Feed.test.js
Normal file
43
src/components/Feed/Feed.test.js
Normal file
@@ -0,0 +1,43 @@
|
||||
import React from 'react';
|
||||
import renderer from 'react-test-renderer';
|
||||
import Feed from './Feed';
|
||||
|
||||
describe('Feed', () => {
|
||||
const props = {
|
||||
edges: [
|
||||
{
|
||||
node: {
|
||||
fields: {
|
||||
slug: '/test_0',
|
||||
categorySlug: '/test_0'
|
||||
},
|
||||
frontmatter: {
|
||||
date: '2016-09-01T23:46:37.121Z',
|
||||
description: 'test_0',
|
||||
category: 'test_0',
|
||||
title: 'test_0'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
node: {
|
||||
fields: {
|
||||
slug: '/test_1',
|
||||
categorySlug: '/test_1'
|
||||
},
|
||||
frontmatter: {
|
||||
date: '2016-09-01T23:46:37.121Z',
|
||||
description: 'test_1',
|
||||
category: 'test_1',
|
||||
title: 'test_1'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
it('renders correctly', () => {
|
||||
const tree = renderer.create(<Feed {...props} />).toJSON();
|
||||
expect(tree).toMatchSnapshot();
|
||||
});
|
||||
});
|
104
src/components/Feed/__snapshots__/Feed.test.js.snap
Normal file
104
src/components/Feed/__snapshots__/Feed.test.js.snap
Normal file
@@ -0,0 +1,104 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Feed renders correctly 1`] = `
|
||||
<div
|
||||
className="feed"
|
||||
>
|
||||
<div
|
||||
className="feed__item"
|
||||
>
|
||||
<div
|
||||
className="feed__item-meta"
|
||||
>
|
||||
<time
|
||||
className="feed__item-meta-time"
|
||||
dateTime="September 2, 2016"
|
||||
>
|
||||
September 2016
|
||||
</time>
|
||||
<span
|
||||
className="feed__item-meta-divider"
|
||||
/>
|
||||
<span
|
||||
className="feed__item-meta-category"
|
||||
>
|
||||
<Link
|
||||
className="feed__item-meta-category-link"
|
||||
to="/test_0"
|
||||
>
|
||||
test_0
|
||||
</Link>
|
||||
</span>
|
||||
</div>
|
||||
<h2
|
||||
className="feed__item-title"
|
||||
>
|
||||
<Link
|
||||
className="feed__item-title-link"
|
||||
to="/test_0"
|
||||
>
|
||||
test_0
|
||||
</Link>
|
||||
</h2>
|
||||
<p
|
||||
className="feed__item-description"
|
||||
>
|
||||
test_0
|
||||
</p>
|
||||
<Link
|
||||
className="feed__item-readmore"
|
||||
to="/test_0"
|
||||
>
|
||||
Read
|
||||
</Link>
|
||||
</div>
|
||||
<div
|
||||
className="feed__item"
|
||||
>
|
||||
<div
|
||||
className="feed__item-meta"
|
||||
>
|
||||
<time
|
||||
className="feed__item-meta-time"
|
||||
dateTime="September 2, 2016"
|
||||
>
|
||||
September 2016
|
||||
</time>
|
||||
<span
|
||||
className="feed__item-meta-divider"
|
||||
/>
|
||||
<span
|
||||
className="feed__item-meta-category"
|
||||
>
|
||||
<Link
|
||||
className="feed__item-meta-category-link"
|
||||
to="/test_1"
|
||||
>
|
||||
test_1
|
||||
</Link>
|
||||
</span>
|
||||
</div>
|
||||
<h2
|
||||
className="feed__item-title"
|
||||
>
|
||||
<Link
|
||||
className="feed__item-title-link"
|
||||
to="/test_1"
|
||||
>
|
||||
test_1
|
||||
</Link>
|
||||
</h2>
|
||||
<p
|
||||
className="feed__item-description"
|
||||
>
|
||||
test_1
|
||||
</p>
|
||||
<Link
|
||||
className="feed__item-readmore"
|
||||
to="/test_1"
|
||||
>
|
||||
Read
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
1
src/components/Feed/index.js
Normal file
1
src/components/Feed/index.js
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from './Feed';
|
Reference in New Issue
Block a user