Skip to content

Commit 761af3a

Browse files
committed
fix tutorial load issue, update coding styles
1 parent b11cd33 commit 761af3a

File tree

19 files changed

+118
-81
lines changed

19 files changed

+118
-81
lines changed

lib/components/FinalPage/index.js

+34-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,41 @@
11
"use strict";
2+
var __extends = (this && this.__extends) || function (d, b) {
3+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
4+
function __() { this.constructor = d; }
5+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6+
};
7+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
8+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
10+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
11+
return c > 3 && r && Object.defineProperty(target, key, r), r;
12+
};
13+
var __metadata = (this && this.__metadata) || function (k, v) {
14+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
15+
};
216
var React = require('react');
17+
var react_redux_1 = require('react-redux');
318
var Card_1 = require('material-ui/Card');
419
var FlatButton_1 = require('material-ui/FlatButton');
520
var styles = {
6-
margin: '5px',
7-
padding: '10px',
21+
card: {
22+
margin: '5px',
23+
padding: '10px',
24+
},
825
};
9-
exports.FinalPage = function () { return (React.createElement(Card_1.Card, {style: styles}, React.createElement(Card_1.CardTitle, {title: 'Congratulations!', subtitle: 'Tutorial Complete!'}), React.createElement(Card_1.CardText, null, "What's next?", React.createElement("br", null), React.createElement("br", null), React.createElement("a", {href: 'https://coderoad.github.io/#tutorials'}, React.createElement(FlatButton_1.default, {label: 'See More Tutorials', disabled: true})), React.createElement("span", null, " (coming soon)"), React.createElement("br", null), React.createElement("br", null), React.createElement("a", {href: 'https://coderoad.github.io/build'}, React.createElement(FlatButton_1.default, {label: 'Learn how to Create a Tutorial'}))))); };
26+
var FinalPage = (function (_super) {
27+
__extends(FinalPage, _super);
28+
function FinalPage() {
29+
_super.apply(this, arguments);
30+
}
31+
FinalPage.prototype.render = function () {
32+
return (React.createElement(Card_1.Card, {style: styles.card}, React.createElement(Card_1.CardTitle, {title: 'Congratulations!', subtitle: 'Tutorial Complete!'}), React.createElement(Card_1.CardText, null, "What's next?", React.createElement("br", null), React.createElement("br", null), React.createElement("a", {href: 'https://coderoad.github.io/#tutorials'}, React.createElement(FlatButton_1.default, {label: 'See More Tutorials', disabled: true})), React.createElement("span", null, " (coming soon)"), React.createElement("br", null), React.createElement("br", null), React.createElement("a", {href: 'https://coderoad.github.io/build'}, React.createElement(FlatButton_1.default, {label: 'Learn how to Create a Tutorial'})))));
33+
};
34+
FinalPage = __decorate([
35+
react_redux_1.connect(null, null),
36+
__metadata('design:paramtypes', [])
37+
], FinalPage);
38+
return FinalPage;
39+
}(React.Component));
1040
Object.defineProperty(exports, "__esModule", { value: true });
11-
exports.default = exports.FinalPage;
41+
exports.default = FinalPage;

lib/components/Routes/index.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ var Routes = (function (_super) {
3838
}
3939
};
4040
Routes = __decorate([
41-
react_redux_1.connect(function (state) { return ({
42-
route: state.route,
43-
}); }),
41+
react_redux_1.connect(function (state) { return ({ route: state.route }); }),
4442
__metadata('design:paramtypes', [])
4543
], Routes);
4644
return Routes;

lib/components/Tutorials/LoadTutorials/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ var LoadTutorials = (function (_super) {
2323
_super.apply(this, arguments);
2424
}
2525
LoadTutorials.prototype.render = function () {
26-
return (React.createElement(FlatButton_1.default, {label: 'Check for Tutorials', secondary: true, onTouchTap: this.props.tutorialsFind}));
26+
var tutorialsFind = this.props.tutorialsFind;
27+
return (React.createElement(FlatButton_1.default, {label: 'Check for Tutorials', secondary: true, onTouchTap: tutorialsFind}));
2728
};
2829
LoadTutorials = __decorate([
2930
react_redux_1.connect(null, function (dispatch) { return ({

lib/components/Tutorials/SelectTutorial/index.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,11 @@ var SelectTutorial = (function (_super) {
2323
_super.apply(this, arguments);
2424
}
2525
SelectTutorial.prototype.displayName = function (name) {
26-
if (name.match(/^coderoad-tutorial-/)) {
27-
return name.slice(18);
26+
switch (true) {
27+
case !!name.match(/^coderoad-tutorial-/): return name.slice(18);
28+
case !!name.match(/^coderoad-/): return name.slice(9);
29+
default: return name;
2830
}
29-
else if (name.match(/^coderoad-/)) {
30-
return name.slice(9);
31-
}
32-
return name;
3331
};
3432
SelectTutorial.prototype.render = function () {
3533
var _a = this.props, tutorial = _a.tutorial, selectTutorial = _a.selectTutorial;

lib/components/Tutorials/UpdateTutorial/index.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@ var actions_1 = require('../../../actions');
1919
var update_1 = require('material-ui/svg-icons/action/update');
2020
var colors_1 = require('material-ui/styles/colors');
2121
var styles = {
22-
width: '18px',
23-
marginLeft: '10px',
22+
icon: {
23+
width: '18px',
24+
marginLeft: '10px',
25+
},
26+
latest: {
27+
marginLeft: '10px',
28+
},
2429
};
2530
var UpdateTutorial = (function (_super) {
2631
__extends(UpdateTutorial, _super);
@@ -29,7 +34,7 @@ var UpdateTutorial = (function (_super) {
2934
}
3035
UpdateTutorial.prototype.render = function () {
3136
var _a = this.props, tutorial = _a.tutorial, tutorialUpdate = _a.tutorialUpdate;
32-
return (React.createElement("span", null, React.createElement(update_1.default, {style: styles, color: colors_1.pink500, onTouchTap: tutorialUpdate.bind(this, tutorial.name)}), "``", React.createElement("span", {style: { marginLeft: '10px' }}, tutorial.latest)));
37+
return (React.createElement("span", null, React.createElement(update_1.default, {style: styles.icon, color: colors_1.pink500, onTouchTap: tutorialUpdate.bind(this, tutorial.name)}), "``", React.createElement("span", {style: styles.latest}, tutorial.latest)));
3338
};
3439
UpdateTutorial = __decorate([
3540
react_redux_1.connect(null, function (dispatch) { return ({

lib/components/common/ContentCard.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ var React = require('react');
33
var index_1 = require('../index');
44
var Card_1 = require('material-ui/Card');
55
var styles = {
6-
margin: '5px'
6+
card: {
7+
margin: '5px',
8+
},
79
};
810
var ContentCard = function (_a) {
911
var title = _a.title, content = _a.content;
10-
return (React.createElement(Card_1.Card, {style: styles}, title ? React.createElement(Card_1.CardHeader, {title: title}) : null, React.createElement(Card_1.CardText, null, React.createElement(index_1.Markdown, null, content || ''))));
12+
return (React.createElement(Card_1.Card, {style: styles.card}, title ? React.createElement(Card_1.CardHeader, {title: title}) : null, React.createElement(Card_1.CardText, null, React.createElement(index_1.Markdown, null, content || ''))));
1113
};
1214
Object.defineProperty(exports, "__esModule", { value: true });
1315
exports.default = ContentCard;

lib/components/common/Markdown.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,8 @@ var options = {
1717
sanitize: true,
1818
smartLists: true,
1919
};
20-
function formatText(text) {
21-
return typeof text !== 'string'
22-
? ''
23-
: marked(text.toString(), options);
24-
}
25-
;
20+
var formatText = function (text) { return typeof text !== 'string' ?
21+
'' : marked(text.toString(), options); };
2622
var Markdown = function (_a) {
2723
var style = _a.style, children = _a.children;
2824
return (React.createElement("span", {className: 'cr-markdown', style: style ? style : null, dangerouslySetInnerHTML: { __html: formatText(children) }}));

lib/modules/tutorial/reducer.js

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ function tutorialReducer(t, action) {
1818
var _a = action.payload, name_1 = _a.name, dir = _a.dir;
1919
var packagePath = path_1.join(dir, 'node_modules', name_1);
2020
var packageJson = require(path_1.join(packagePath, 'package.json'));
21+
console.log(packageJson);
2122
var config = config_1.tutorialConfig(packageJson, dir);
2223
var coderoadJsonPath = path_1.join(packagePath, packageJson.main);
2324
var _b = require(coderoadJsonPath), info = _b.info, pages = _b.pages;

lib/subscriptions.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ function onActivate() {
1010
'cr-viewer:toggle': function () { return store_1.default.dispatch({ type: 'WINDOW_TOGGLE' }); }
1111
}));
1212
atom.workspace.observeTextEditors(function (editor) {
13-
subscriptions.add(editor.onDidSave(function () {
14-
store_1.default.dispatch(actions_1.testRun());
15-
}));
13+
subscriptions.add(editor.onDidSave(function () { return store_1.default.dispatch(actions_1.testRun()); }));
1614
});
1715
return subscriptions;
1816
}

src/components/App.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ export default class App extends React.Component<{
2525
<Routes />
2626
</div>
2727
</Drawer>
28-
<Alert />
29-
</section>
28+
<Alert />
29+
</section>
3030
);
3131
}
3232
};

src/components/FinalPage/index.tsx

+33-26
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,43 @@
11
import * as React from 'react';
2+
import {connect} from 'react-redux';
23
import Paper from 'material-ui/Paper';
34
import Divider from 'material-ui/Divider';
45
import {Card, CardTitle, CardText, CardActions} from 'material-ui/Card';
56
import FlatButton from 'material-ui/FlatButton';
67

78
const styles = {
8-
margin: '5px',
9-
padding: '10px',
9+
card: {
10+
margin: '5px',
11+
padding: '10px',
12+
},
1013
};
1114

12-
export const FinalPage: React.StatelessComponent<{}> = () => (
13-
<Card style={styles}>
14-
<CardTitle
15-
title='Congratulations!'
16-
subtitle='Tutorial Complete!'
17-
/>
18-
<CardText>
19-
What's next?
20-
<br /><br />
21-
<a href='https://coderoad.github.io/#tutorials'>
22-
<FlatButton
23-
label='See More Tutorials'
24-
disabled={true}
25-
/>
26-
</a>
27-
<span> (coming soon)</span>
28-
<br /><br />
29-
<a href='https://coderoad.github.io/build'>
30-
<FlatButton label='Learn how to Create a Tutorial' />
31-
</a>
32-
</CardText>
15+
@connect(null, null)
16+
export default class FinalPage extends React.Component<{}, {}> {
17+
render() {
18+
return (
19+
<Card style={styles.card}>
20+
<CardTitle
21+
title='Congratulations!'
22+
subtitle='Tutorial Complete!'
23+
/>
24+
<CardText>
25+
What's next?
26+
<br /><br />
27+
<a href='https://coderoad.github.io/#tutorials'>
28+
<FlatButton
29+
label='See More Tutorials'
30+
disabled={true}
31+
/>
32+
</a>
33+
<span> (coming soon)</span>
34+
<br /><br />
35+
<a href='https://coderoad.github.io/build'>
36+
<FlatButton label='Learn how to Create a Tutorial' />
37+
</a>
38+
</CardText>
3339

34-
</Card>
35-
);
36-
export default FinalPage;
40+
</Card>
41+
);
42+
}
43+
}

src/components/Routes/index.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import * as React from 'react';
22
import {connect} from 'react-redux';
33
import {Page, Progress, Tutorials, Start, FinalPage} from '../index';
44

5-
@connect(state => ({
6-
route: state.route,
7-
}))
5+
@connect(state => ({ route: state.route }))
86
export default class Routes extends React.Component<{
97
route?: string
108
}, {}> {

src/components/Tutorials/LoadTutorials/index.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ export default class LoadTutorials extends React.Component<{
1010
tutorialsFind?: any
1111
}, {}> {
1212
render() {
13+
const {tutorialsFind} = this.props;
1314
return (
1415
<FlatButton
1516
label='Check for Tutorials'
1617
secondary={true}
17-
onTouchTap={this.props.tutorialsFind}
18+
onTouchTap={tutorialsFind}
1819
/>
1920
);
2021
}

src/components/Tutorials/SelectTutorial/index.tsx

+5-6
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@ export default class SelectTutorial extends React.Component<{
1010
tutorial: Tutorial.Item, selectTutorial?: any
1111
}, {}> {
1212
displayName(name: string): string {
13-
if (name.match(/^coderoad-tutorial-/)) {
14-
return name.slice(18);
15-
} else if (name.match(/^coderoad-/)) {
16-
return name.slice(9);
13+
switch (true) {
14+
case !!name.match(/^coderoad-tutorial-/): return name.slice(18);
15+
case !!name.match(/^coderoad-/): return name.slice(9);
16+
default: return name;
1717
}
18-
return name;
1918
}
2019
render() {
2120
const {tutorial, selectTutorial} = this.props;
22-
const name = tutorial.name;
21+
const {name} = tutorial;
2322
return (
2423
<FlatButton
2524
label={this.displayName(name)}

src/components/Tutorials/UpdateTutorial/index.tsx

+9-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ import Update from 'material-ui/svg-icons/action/update';
55
import {pink500} from 'material-ui/styles/colors';
66

77
const styles = {
8-
width: '18px',
9-
marginLeft: '10px',
8+
icon: {
9+
width: '18px',
10+
marginLeft: '10px',
11+
},
12+
latest: {
13+
marginLeft: '10px',
14+
},
1015
};
1116

1217
@connect(null, dispatch => ({
@@ -20,11 +25,11 @@ export default class UpdateTutorial extends React.Component<{
2025
return (
2126
<span>
2227
<Update
23-
style={styles}
28+
style={styles.icon}
2429
color={pink500}
2530
onTouchTap={tutorialUpdate.bind(this, tutorial.name)}
2631
/>``
27-
<span style={{marginLeft: '10px'}}>{tutorial.latest}</span>
32+
<span style={styles.latest}>{tutorial.latest}</span>
2833
</span>
2934
);
3035
}

src/components/common/ContentCard.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ import {Markdown} from '../index';
33
import {Card, CardHeader, CardText} from 'material-ui/Card';
44

55
const styles = {
6-
margin: '5px'
6+
card: {
7+
margin: '5px',
8+
},
79
};
810

911
const ContentCard: React.StatelessComponent<{
1012
title: string, content?: string
1113
}> = ({title, content}) => (
12-
<Card style={styles}>
14+
<Card style={styles.card}>
1315
{title ? <CardHeader title={title} /> : null}
1416
<CardText>
1517
<Markdown>{content || ''}</Markdown>

src/components/common/Markdown.tsx

+2-5
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,8 @@ const options = {
2020
smartLists: true,
2121
};
2222

23-
function formatText(text: string): string {
24-
return typeof text !== 'string'
25-
? ''
26-
: marked(text.toString(), options);
27-
};
23+
const formatText = (text: string): string => typeof text !== 'string' ?
24+
'' : marked(text.toString(), options);
2825

2926
const Markdown: React.StatelessComponent<{
3027
children?: string, style?: Object

src/modules/tutorial/reducer.ts

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export default function tutorialReducer(
2424
// get tutorial package.json
2525
const packagePath: string = join(dir, 'node_modules', name);
2626
const packageJson: PackageJson = require(join(packagePath, 'package.json'));
27+
console.log(packageJson);
2728

2829
const config: Tutorial.Config = tutorialConfig(packageJson, dir);
2930
const coderoadJsonPath = join(packagePath, packageJson.main);

src/subscriptions.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ export function onActivate(): AtomCore.Disposable {
1717

1818
// run tests on save
1919
atom.workspace.observeTextEditors((editor: AtomCore.IEditor) => {
20-
subscriptions.add(
21-
editor.onDidSave(() => {
22-
store.dispatch(testRun());
23-
}));
20+
subscriptions.add(editor.onDidSave(() => store.dispatch(testRun())));
2421
});
22+
// return all subscriptions
2523
return subscriptions;
2624
}
2725

0 commit comments

Comments
 (0)