- Fix routes

- move functions to inline rendering in ttt-tile and mw homepage
This commit is contained in:
morant 2016-12-20 12:06:58 -05:00
parent 7bbb498a4f
commit 485d3903e0
3 changed files with 18 additions and 34 deletions

View file

@ -14,16 +14,6 @@ var TTTTile = React.createClass({
tutorialLoc: React.PropTypes.string.isRequired, tutorialLoc: React.PropTypes.string.isRequired,
onGuideClick: React.PropTypes.func.isRequired onGuideClick: React.PropTypes.func.isRequired
}, },
tileGuidesIfExists: function () {
if (this.props.onGuideClick) {
return (
<div className="ttt-tile-guides" onClick={this.props.onGuideClick}>
<FormattedMessage id='tile.guides' defaultMessage='See Cards and Guides'/>
<img className="ttt-tile-see-more" src="/svgs/ttt/see-more.svg" />
</div>
);
}
},
render: function () { render: function () {
var classes = classNames( var classes = classNames(
'ttt-tile', 'ttt-tile',
@ -54,7 +44,12 @@ var TTTTile = React.createClass({
</div> </div>
</a> </a>
{this.tileGuidesIfExists()} {this.props.onGuideClick && (
<div className="ttt-tile-guides" onClick={this.props.onGuideClick}>
<FormattedMessage id='tile.guides' defaultMessage='See Cards and Guides'/>
<img className="ttt-tile-see-more" src="/svgs/ttt/see-more.svg" />
</div>
)}
</div> </div>
); );
} }

View file

@ -250,7 +250,7 @@
{ {
"name": "microworlds-homepage", "name": "microworlds-homepage",
"pattern": "^/microworlds/go/?(\\?.*)?$", "pattern": "^/microworlds/go/?(\\?.*)?$",
"routeAlias": "microworlds", "routeAlias": "/microworlds",
"view": "microworldshomepage/microworldshomepage", "view": "microworldshomepage/microworldshomepage",
"title": "Microworlds" "title": "Microworlds"
} }

View file

@ -14,27 +14,6 @@ require('./microworldshomepage.scss');
var MicroworldsHomepage = injectIntl(React.createClass({ var MicroworldsHomepage = injectIntl(React.createClass({
type: 'MicroworldsHomepage', type: 'MicroworldsHomepage',
renderTTTTiles: function () {
var formatMessage = this.props.intl.formatMessage;
var translatedTiles = [];
var translatedTile = {};
Tiles.map(function (tile, key) {
translatedTile = {
title: formatMessage({id: tile.title}),
tutorialLoc: tile.tutorialLoc,
thumbUrl: tile.thumbUrl,
bannerUrl: tile.bannerUrl
};
translatedTiles.push(
<TTTTile
key={key}
{...translatedTile}
/>
);
}, this); // don't forget to pass 'this' into map function
return translatedTiles;
},
render: function () { render: function () {
return ( return (
<div className="microworlds"> <div className="microworlds">
@ -48,7 +27,17 @@ var MicroworldsHomepage = injectIntl(React.createClass({
</TitleBanner> </TitleBanner>
<div className="inner"> <div className="inner">
<MasonryGrid > <MasonryGrid >
{this.renderTTTTiles()} {Tiles.map(
function (tile, key) {
return <TTTTile
key={key}
title={this.props.intl.formatMessage({id: tile.title})}
tutorialLoc={tile.tutorialLoc}
thumbUrl={tile.thumbUrl}
bannerUrl={tile.bannerUrl}
/>;
}, this)
}
</MasonryGrid> </MasonryGrid>
</div> </div>
</div> </div>