-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from cbeard87/enhancement/eslint-config
Set up automated formatting
- Loading branch information
Showing
70 changed files
with
4,063 additions
and
3,057 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "react-app" | ||
} |
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 |
---|---|---|
@@ -1,20 +1,22 @@ | ||
import React, { Component } from 'react'; | ||
|
||
class Article extends Component { | ||
render() { | ||
return ( | ||
<article> | ||
<header> | ||
<h1>{this.props.title}</h1> | ||
</header> | ||
<img alt={this.props.teaserImageAlt} src={this.props.teaserImageSrc} width="500"/> | ||
<p> | ||
{this.props.summary} | ||
</p> | ||
<div dangerouslySetInnerHTML={{__html: this.props.bodyCopy}} /> | ||
</article> | ||
); | ||
} | ||
render() { | ||
return ( | ||
<article> | ||
<header> | ||
<h1>{this.props.title}</h1> | ||
</header> | ||
<img | ||
alt={this.props.teaserImageAlt} | ||
src={this.props.teaserImageSrc} | ||
width="500" | ||
/> | ||
<p>{this.props.summary}</p> | ||
<div dangerouslySetInnerHTML={{ __html: this.props.bodyCopy }} /> | ||
</article> | ||
); | ||
} | ||
} | ||
|
||
export default Article; | ||
export default Article; |
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 |
---|---|---|
@@ -1,44 +1,51 @@ | ||
import Article from './Article' | ||
import Article from './Article'; | ||
|
||
import React, { Component } from 'react'; | ||
import config from './deliveryClientConfig'; | ||
import withDeliveryClient from './withDeliveryClient'; | ||
|
||
class ArticleContainer extends Component { | ||
constructor(props) { | ||
super(props) | ||
this.state = { | ||
article: undefined | ||
} | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
article: undefined | ||
}; | ||
} | ||
|
||
componentDidMount() { | ||
this.subscription = this.props.client | ||
.item(this.props.codeName) | ||
.getObservable() | ||
.subscribe(response => { | ||
this.setState({ | ||
article: response.item | ||
}); | ||
}); | ||
} | ||
|
||
componentWillUnmount() { | ||
this.subscription.dispose(); | ||
} | ||
|
||
render() { | ||
if (!this.state.article) { | ||
return <Article />; | ||
} | ||
|
||
componentDidMount() { | ||
this.subscription = this.props.client.item(this.props.codeName) | ||
.getObservable() | ||
.subscribe(response => { | ||
this.setState({ | ||
article: response.item | ||
}); | ||
}); | ||
} | ||
|
||
componentWillUnmount() { | ||
this.subscription.dispose(); | ||
} | ||
|
||
render() { | ||
if (!this.state.article) { | ||
return <Article />; | ||
} | ||
|
||
const { title, summary, bodyCopy } = this.state.article; | ||
const teaserAlt = this.state.article.teaserImage.assets[0].description; | ||
const teaserUrl = this.state.article.teaserImage.assets[0].url; | ||
|
||
return ( | ||
<Article title={title.value} summary={summary.value} bodyCopy={bodyCopy.value} teaserImageAlt={teaserAlt} teaserImageSrc={teaserUrl} /> | ||
); | ||
} | ||
const { title, summary, bodyCopy } = this.state.article; | ||
const teaserAlt = this.state.article.teaserImage.assets[0].description; | ||
const teaserUrl = this.state.article.teaserImage.assets[0].url; | ||
|
||
return ( | ||
<Article | ||
title={title.value} | ||
summary={summary.value} | ||
bodyCopy={bodyCopy.value} | ||
teaserImageAlt={teaserAlt} | ||
teaserImageSrc={teaserUrl} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
export default withDeliveryClient(config)(ArticleContainer); | ||
export default withDeliveryClient(config)(ArticleContainer); |
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 |
---|---|---|
@@ -1,31 +1,29 @@ | ||
import { ContentItem } from 'kentico-cloud-delivery'; | ||
import { ContentItem } from 'kentico-cloud-delivery'; | ||
|
||
export class Article extends ContentItem { | ||
constructor(){ | ||
super({ | ||
propertyResolver: ((fieldName) => { | ||
constructor() { | ||
super({ | ||
propertyResolver: fieldName => { | ||
if (fieldName === 'teaser_image') { | ||
return 'teaserImage'; | ||
} | ||
|
||
if (fieldName === 'teaser_image'){ | ||
return 'teaserImage'; | ||
} | ||
if (fieldName === 'post_date') { | ||
return 'postDate'; | ||
} | ||
|
||
if (fieldName === 'post_date'){ | ||
return 'postDate'; | ||
} | ||
if (fieldName === 'body_copy') { | ||
return 'bodyCopy'; | ||
} | ||
|
||
if (fieldName === 'body_copy'){ | ||
return 'bodyCopy'; | ||
} | ||
if (fieldName === 'related_articles') { | ||
return 'relatedArticles'; | ||
} | ||
|
||
if (fieldName === 'related_articles'){ | ||
return 'relatedArticles'; | ||
} | ||
|
||
if (fieldName === 'url_pattern'){ | ||
return 'urlPattern'; | ||
} | ||
}), | ||
}) | ||
} | ||
|
||
} | ||
if (fieldName === 'url_pattern') { | ||
return 'urlPattern'; | ||
} | ||
} | ||
}); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,11 +1,9 @@ | ||
import { TypeResolver } from "kentico-cloud-delivery"; | ||
import { TypeResolver } from 'kentico-cloud-delivery'; | ||
import { Article } from './ArticleModel'; | ||
|
||
const config = { | ||
projectId: '975bf280-fd91-488c-994c-2f04416e5ee3', | ||
typeResolvers: [ | ||
new TypeResolver('article', () => new Article()) | ||
] | ||
} | ||
projectId: '975bf280-fd91-488c-994c-2f04416e5ee3', | ||
typeResolvers: [new TypeResolver('article', () => new Article())] | ||
}; | ||
|
||
export default config; | ||
export default config; |
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
Oops, something went wrong.