-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move page/screen components to src/routes along with the routing info
- Loading branch information
Showing
24 changed files
with
328 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* React Starter Kit (https://www.reactstarterkit.com/) | ||
* | ||
* Copyright © 2014-2016 Kriasoft, LLC. All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE.txt file in the root directory of this source tree. | ||
*/ | ||
|
||
import { GraphQLList as List } from 'graphql'; | ||
import fetch from '../../core/fetch'; | ||
import NewsItemType from '../types/NewsItemType'; | ||
|
||
// React.js News Feed (RSS) | ||
const url = 'http://ajax.googleapis.com/ajax/services/feed/load' + | ||
'?v=1.0&num=10&q=https://reactjsnews.com/feed.xml'; | ||
|
||
let items = []; | ||
let lastFetchTime = new Date(1970, 0, 1); | ||
|
||
const news = { | ||
type: new List(NewsItemType), | ||
resolve() { | ||
if ((new Date() - lastFetchTime) > 1000 * 60 * 10 /* 10 mins */) { | ||
lastFetchTime = new Date(); | ||
fetch(url) | ||
.then(response => response.json()) | ||
.then(data => { | ||
if (data.responseStatus === 200) { | ||
items = data.responseData.feed.entries; | ||
} | ||
}); | ||
} | ||
|
||
return items; | ||
}, | ||
}; | ||
|
||
export default news; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* React Starter Kit (https://www.reactstarterkit.com/) | ||
* | ||
* Copyright © 2014-2016 Kriasoft, LLC. All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE.txt file in the root directory of this source tree. | ||
*/ | ||
|
||
import { | ||
GraphQLObjectType as ObjectType, | ||
GraphQLString as StringType, | ||
GraphQLNonNull as NonNull, | ||
} from 'graphql'; | ||
|
||
const NewsItemType = new ObjectType({ | ||
name: 'NewsItem', | ||
fields: { | ||
title: { type: new NonNull(StringType) }, | ||
link: { type: new NonNull(StringType) }, | ||
author: { type: StringType }, | ||
publishedDate: { type: new NonNull(StringType) }, | ||
contentSnippet: { type: StringType }, | ||
}, | ||
}); | ||
|
||
export default NewsItemType; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* React Starter Kit (https://www.reactstarterkit.com/) | ||
* | ||
* Copyright © 2014-2016 Kriasoft, LLC. All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE.txt file in the root directory of this source tree. | ||
*/ | ||
|
||
import React from 'react'; | ||
import Contact from './Contact'; | ||
|
||
export const path = '/contact'; | ||
export const action = async (state) => { | ||
const title = 'Contact Us'; | ||
state.context.onSetTitle(title); | ||
return <Contact title={title} />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* React Starter Kit (https://www.reactstarterkit.com/) | ||
* | ||
* Copyright © 2014-2016 Kriasoft, LLC. All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE.txt file in the root directory of this source tree. | ||
*/ | ||
|
||
import React, { PropTypes } from 'react'; | ||
import withStyles from 'isomorphic-style-loader/lib/withStyles'; | ||
import s from './Home.scss'; | ||
|
||
function Home({ news }) { | ||
return ( | ||
<div className={s.root}> | ||
<div className={s.container}> | ||
<h1 className={s.title}>React.js News</h1> | ||
<ul className={s.news}> | ||
{news.map((item, index) => ( | ||
<li key={index} className={s.newsItem}> | ||
<a href={item.link} className={s.newsTitle}>{item.title}</a> | ||
<span | ||
className={s.newsDesc} | ||
dangerouslySetInnerHTML={{ __html: item.contentSnippet }} | ||
/> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
Home.propTypes = { | ||
news: PropTypes.arrayOf(PropTypes.shape({ | ||
title: PropTypes.string.isRequired, | ||
link: PropTypes.string.isRequired, | ||
contentSnippet: PropTypes.string, | ||
})).isRequired, | ||
}; | ||
|
||
export default withStyles(Home, s); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* React Starter Kit (https://www.reactstarterkit.com/) | ||
* | ||
* Copyright © 2014-2016 Kriasoft, LLC. All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE.txt file in the root directory of this source tree. | ||
*/ | ||
|
||
@import '../../components/variables.scss'; | ||
|
||
.root { | ||
padding-left: 20px; | ||
padding-right: 20px; | ||
} | ||
|
||
.container { | ||
margin: 0 auto; | ||
padding: 0 0 40px; | ||
max-width: $max-content-width; | ||
} | ||
|
||
.news { | ||
padding: 0; | ||
} | ||
|
||
.newsItem { | ||
list-style-type: none; | ||
padding-bottom: 6px; | ||
} | ||
|
||
.newsTitle { | ||
font-size: 1.125em; | ||
} | ||
|
||
.newsTitle, .newsDesc { | ||
display: block; | ||
} |
Oops, something went wrong.
6553936
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's so awkward to have components in your routes folder.
6553936
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.