Skip to content

Commit 18fcd6a

Browse files
committed
i --save, fix chapter text
1 parent 8e0ca1e commit 18fcd6a

File tree

12 files changed

+3357
-3282
lines changed

12 files changed

+3357
-3282
lines changed

lib/atom/editor.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ function getEditor() {
4848
}
4949
exports.getEditor = getEditor;
5050
function open(filePath, options) {
51+
if (options === void 0) { options = {}; }
5152
if (exists_1.fileExists(filePath)) {
5253
fs.unlink(filePath);
5354
}
@@ -65,6 +66,7 @@ function set(text) {
6566
}
6667
exports.set = set;
6768
function insert(text, options) {
69+
if (options === void 0) { options = {}; }
6870
options = Object.assign(options, {
6971
autoIndent: true
7072
});

lib/components/alert/alert.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ var default_1 = (function (_super) {
2929
}
3030
default_1.prototype.render = function () {
3131
var _a = this.props, alert = _a.alert, toggleAlert = _a.toggleAlert;
32-
return (React.createElement(material_ui_1.Snackbar, {className: classNames('cr-alert', alert.action), open: alert.open || false, message: alert.message || '', action: alert.action, autoHideDuration: alert.duration || 1500, onActionTouchTap: toggleAlert, onRequestClose: toggleAlert}));
32+
var action = alert.action, open = alert.open, message = alert.message, duration = alert.duration;
33+
return (React.createElement(material_ui_1.Snackbar, {className: classNames('cr-alert', action), open: open || false, message: message || '', action: action, autoHideDuration: duration || 1500, onActionTouchTap: toggleAlert, onRequestClose: toggleAlert}));
3334
};
3435
default_1 = __decorate([
3536
react_redux_1.connect(null, function (dispatch) {

lib/components/menu/menu.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,32 @@ var default_1 = (function (_super) {
2828
_super.apply(this, arguments);
2929
}
3030
default_1.prototype.navOptions = function () {
31+
var _a = this.props, routeToProgress = _a.routeToProgress, routeToPage = _a.routeToPage;
3132
switch (this.props.route) {
3233
case 'page':
33-
return React.createElement("button", {onTouchTap: this.props.routeToProgress}, "progress");
34+
return React.createElement("button", {onTouchTap: routeToProgress}, "progress");
3435
case 'progress':
35-
return React.createElement("button", {onTouchTap: this.props.routeToPage}, "page");
36+
return React.createElement("button", {onTouchTap: routeToPage}, "page");
3637
default: return null;
3738
}
3839
};
3940
default_1.prototype.menuOptions = function () {
41+
var _a = this.props, routeToProgress = _a.routeToProgress, routeToProjects = _a.routeToProjects;
4042
switch (this.props.route) {
4143
case 'page':
42-
return (React.createElement("div", null, React.createElement(material_ui_1.MenuItem, {primaryText: 'progress', onTouchTap: this.props.routeToProgress, key: 'progress'}), React.createElement(material_ui_1.MenuItem, {primaryText: 'projects', onTouchTap: this.props.routeToProjects, key: 'projects'})));
44+
return (React.createElement("div", null, React.createElement(material_ui_1.MenuItem, {primaryText: 'progress', onTouchTap: routeToProgress, key: 'progress'}), React.createElement(material_ui_1.MenuItem, {primaryText: 'projects', onTouchTap: routeToProjects, key: 'projects'})));
4345
case 'progress':
44-
return React.createElement(material_ui_1.MenuItem, {primaryText: 'projects', onTouchTap: this.props.routeToProjects, key: 'projects'});
46+
return React.createElement(material_ui_1.MenuItem, {primaryText: 'projects', onTouchTap: routeToProjects, key: 'projects'});
4547
default: return null;
4648
}
4749
};
4850
default_1.prototype.closePanel = function () {
4951
render_1.togglePanel();
5052
};
5153
default_1.prototype.render = function () {
52-
return (React.createElement(material_ui_1.AppBar, {title: 'CodeRoad', className: 'cr-menu-bar', iconElementLeft: React.createElement(material_ui_1.IconButton, {onTouchTap: this.closePanel}, React.createElement(NavigationClose, null)), iconElementRight: React.createElement(material_ui_1.IconMenu, {iconButtonElement: React.createElement(material_ui_1.IconButton, null, React.createElement(MoreVertIcon, null)), targetOrigin: { horizontal: 'right', vertical: 'top' }, anchorOrigin: { horizontal: 'right', vertical: 'top' }}, this.menuOptions(), window.coderoad.issuesPath ? React.createElement(material_ui_1.MenuItem, {key: 'issue'}, React.createElement("a", {href: window.coderoad.issuesPath}, "post issue")) : null, React.createElement(material_ui_1.Divider, null), React.createElement(material_ui_1.MenuItem, {primaryText: 'quit', onTouchTap: this.props.quit}))}));
54+
var origin = { horizontal: 'right', vertical: 'top' };
55+
var quit = this.props.quit;
56+
return (React.createElement(material_ui_1.AppBar, {title: 'CodeRoad', className: 'cr-menu-bar', iconElementLeft: React.createElement(material_ui_1.IconButton, {onTouchTap: this.closePanel}, React.createElement(NavigationClose, null)), iconElementRight: React.createElement(material_ui_1.IconMenu, {iconButtonElement: React.createElement(material_ui_1.IconButton, null, React.createElement(MoreVertIcon, null)), targetOrigin: origin, anchorOrigin: origin}, this.menuOptions(), window.coderoad.issuesPath ? React.createElement(material_ui_1.MenuItem, {key: 'issue'}, React.createElement("a", {href: window.coderoad.issuesPath}, "post issue")) : null, React.createElement(material_ui_1.Divider, null), React.createElement(material_ui_1.MenuItem, {primaryText: 'quit', onTouchTap: quit}))}));
5357
};
5458
default_1 = __decorate([
5559
react_redux_1.connect(null, function (dispatch) {

lib/components/page/edit.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
var React = require('react');
33
var path = require('path');
44
var Edit = require('material-ui/lib/svg-icons/editor/mode-edit');
5+
var editStyle = { position: 'absolute', top: '10px', right: '10px' };
56
Object.defineProperty(exports, "__esModule", { value: true });
67
exports.default = function (editPath) {
78
if (editPath && window.coderoad.edit) {
89
var repoPath = path.join(window.coderoad.repo, 'edit', 'master', editPath);
9-
return React.createElement("a", {href: repoPath}, React.createElement(Edit, {style: { position: 'absolute', top: '10px', right: '10px' }}));
10+
return React.createElement("a", {href: repoPath}, React.createElement(Edit, {style: editStyle}));
1011
}
1112
};

lib/components/progress/progress.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ var React = require('react');
1717
var react_redux_1 = require('react-redux');
1818
var Action = require('../../actions/actions');
1919
var material_ui_1 = require('material-ui');
20+
var _components_1 = require('../_components');
2021
var classnames = require('classnames');
2122
var Colors = require('material-ui/lib/styles/colors');
2223
var Completed = require('material-ui/lib/svg-icons/toggle/check-box');
@@ -80,12 +81,12 @@ exports.default = function (_a) {
8081
var progress = _a.progress, position = _a.position;
8182
return (React.createElement(material_ui_1.Paper, {style: style, zDepth: 1, className: 'cr-progress'}, React.createElement(material_ui_1.List, {subheader: 'Progress'}, progress.chapters.map(function (chapter, chapterIndex) {
8283
var isActive = chapterIndex === position.chapter;
83-
return React.createElement(material_ui_1.ListItem, {primaryText: (chapterIndex + 1) + ". " + chapter.title, key: 'c' + chapterIndex, className: classnames({
84+
return React.createElement(material_ui_1.ListItem, {key: 'c' + chapterIndex, className: classnames({
8485
'chapter': true,
8586
'isActive': isActive
86-
}), secondaryText: chapter.description, secondaryTextLines: chapter.description.length > 35 ? 2 : 1, initiallyOpen: chapterIndex === 0, leftIcon: chapter.completed ? React.createElement(AllCompleted, null) : null, primaryTogglesNestedList: chapterIndex === position.chapter && !chapter.completed, nestedItems: chapter.pages.map(function (page, pageIndex) {
87+
}), initiallyOpen: chapterIndex === 0, leftIcon: chapter.completed ? React.createElement(AllCompleted, null) : null, primaryTogglesNestedList: chapterIndex === position.chapter && !chapter.completed, nestedItems: chapter.pages.map(function (page, pageIndex) {
8788
var itemPosition = { chapter: chapterIndex, page: pageIndex };
8889
return React.createElement(ProgressPage, {key: 'c' + chapterIndex + 'p' + pageIndex, page: page, itemPosition: itemPosition, position: position});
89-
})});
90+
})}, React.createElement("h3", null, chapterIndex + 1, ". ", chapter.title), React.createElement("span", {className: 'cr-chapter-description'}, React.createElement(_components_1.MarkdownText, {text: chapter.description})));
9091
}))));
9192
};

lib/components/projects/projects.js

Lines changed: 62 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,65 @@
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');
18+
var Action = require('../../actions/actions');
319
var material_ui_1 = require('material-ui');
4-
var setup_1 = require('./setup');
5-
var tutorials_1 = require('./tutorials');
6-
exports.Project = function (_a) {
7-
var tutorials = _a.tutorials;
8-
return (React.createElement(material_ui_1.Paper, {className: 'cr-projects'}, React.createElement("div", {className: 'cr-projects-header'}, React.createElement("span", {className: 'title'}, "CodeRoad"), React.createElement("p", {className: 'tagline'}, "Tutorials in the Editor"), window.coderoad.dir && window.coderoad.setup.hasPackageJson && tutorials.length > 0 ?
9-
React.createElement(tutorials_1.default, {tutorials: tutorials}) : React.createElement(setup_1.SetupGuide, null), React.createElement("p", {className: 'notes'}, "Beta"))));
10-
};
20+
var Projects = (function (_super) {
21+
__extends(Projects, _super);
22+
function Projects() {
23+
_super.apply(this, arguments);
24+
}
25+
Projects.prototype.load = function () {
26+
this.props.loadTutorials();
27+
};
28+
Projects.prototype.trim = function (name) {
29+
if (name.match(/^coderoad-tutorial-/)) {
30+
return name.slice(18);
31+
}
32+
if (name.match(/^coderoad-/)) {
33+
return name.slice(9);
34+
}
35+
return name;
36+
};
37+
Projects.prototype.render = function () {
38+
var _this = this;
39+
return (React.createElement(material_ui_1.Paper, {className: 'cr-projects'}, React.createElement("div", {className: 'cr-projects-header'}, React.createElement("span", {className: 'title'}, "CodeRoad"), React.createElement("p", {className: 'tagline'}, "Tutorials in the Editor"), React.createElement("div", {className: 'cr-tutorials'}, React.createElement(material_ui_1.List, {subheader: 'Tutorials'}, window.coderoad.dir ? null : React.createElement(material_ui_1.ListItem, {key: 'open', primaryText: 'Create an Atom Project', secondaryText: 'File > Open > any older'}), this.props.tutorials.length > 0 ?
40+
this.props.tutorials.map(function (tutorial, index) {
41+
return (React.createElement(material_ui_1.ListItem, {key: index, primaryText: _this.trim(tutorial), onClick: _this.props.selectProject.bind(_this, tutorial)}));
42+
}) : React.createElement(material_ui_1.ListItem, {key: 'demo', primaryText: 'Try a Demo', secondaryText: 'npm i -s coderoad-functional-school'})), React.createElement("br", null), React.createElement(material_ui_1.RaisedButton, {label: 'Load Tutorials', secondary: true, onClick: this.load.bind(this)})), React.createElement("p", {className: 'notes'}, "Beta"))));
43+
};
44+
Projects = __decorate([
45+
react_redux_1.connect(null, function (dispatch) {
46+
return {
47+
selectProject: function (name) {
48+
Action.loadTutorial(name);
49+
dispatch(Action.setRoute('progress'));
50+
},
51+
toggleAlert: function (item) {
52+
dispatch(Action.toggleAlert(item));
53+
},
54+
loadTutorials: function () {
55+
dispatch(Action.loadTutorials());
56+
}
57+
};
58+
}),
59+
__metadata('design:paramtypes', [])
60+
], Projects);
61+
return Projects;
62+
}(React.Component));
63+
Object.defineProperty(exports, "__esModule", { value: true });
64+
exports.default = Projects;
65+
;

lib/services/package.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ var PackageService = (function () {
3232
this.data = require(path.join(packagePath, this.config.main));
3333
this.packageName = packageName;
3434
};
35-
PackageService.prototype.page = function (position) {
36-
var page = _.cloneDeep(this.data.chapters[position.chapter].pages[position.page]);
37-
return page;
35+
PackageService.prototype.page = function (_a) {
36+
var chapter = _a.chapter, page = _a.page;
37+
return _.cloneDeep(this.data.chapters[chapter].pages[page]);
3838
};
3939
PackageService.prototype.getConfig = function () {
4040
return this.config;
@@ -73,17 +73,18 @@ var PackageService = (function () {
7373
PackageService.prototype.getSavedRoute = function () {
7474
return 'progress';
7575
};
76-
PackageService.prototype.getNextPosition = function (position) {
76+
PackageService.prototype.getNextPosition = function (_a) {
77+
var chapter = _a.chapter, page = _a.page;
7778
var chapters = this.data.chapters;
78-
if (position.page < chapters[position.chapter].pages.length - 1) {
79-
return { chapter: position.chapter, page: position.page + 1 };
79+
if (page < chapters[chapter].pages.length - 1) {
80+
return { chapter: chapter, page: page + 1 };
8081
}
81-
else if (position.chapter < chapters.length - 1) {
82-
return { chapter: position.chapter + 1, page: 0 };
82+
else if (chapter < chapters.length - 1) {
83+
return { chapter: chapter + 1, page: 0 };
8384
}
8485
else {
8586
_base_1.store.dispatch(Action.projectComplete());
86-
return position;
87+
return { chapter: chapter, page: page };
8788
}
8889
};
8990
PackageService.prototype.getProject = function () {

src/components/progress/_progress.less

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
.chapter {
44
margin-bottom: 0;
55
}
6+
.chapter-description {
7+
font-size: 14px;
8+
}
69
.chapter.isActive {
710
background-color: darken(white, 10%);
811
}

src/components/progress/progress.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as React from 'react';
33
import {connect} from 'react-redux';
44
import * as Action from '../../actions/actions';
55
import {Paper, List, ListItem, RaisedButton} from 'material-ui';
6+
import {MarkdownText} from '../_components';
67
import * as classnames from 'classnames';
78
import * as Colors from 'material-ui/lib/styles/colors';
89
let Completed = require('material-ui/lib/svg-icons/toggle/check-box');
@@ -67,24 +68,27 @@ const style = {
6768
export default ({progress, position}) => (
6869
<Paper style={style} zDepth={1} className='cr-progress'>
6970
{/*}<ProjectDescription project={project} />*/}
70-
<List subheader='Progress'>
71+
<List subheader='Chapters'>
7172
{progress.chapters.map((chapter: CR.Chapter, chapterIndex: number) => {
7273
const isActive = chapterIndex === position.chapter;
73-
return <ListItem primaryText={`${chapterIndex + 1}. ${chapter.title}`}
74+
return <ListItem
7475
key={'c' + chapterIndex}
7576
className={classnames({
7677
'chapter': true,
7778
'isActive': isActive
7879
})}
79-
secondaryText={chapter.description}
80-
secondaryTextLines={chapter.description.length > 35 ? 2 : 1}
8180
initiallyOpen={chapterIndex === 0}
8281
leftIcon={chapter.completed ? <AllCompleted /> : null}
8382
primaryTogglesNestedList={chapterIndex === position.chapter && !chapter.completed}
8483
nestedItems={chapter.pages.map((page: CR.Page, pageIndex: number) => {
8584
const itemPosition = {chapter: chapterIndex, page: pageIndex};
8685
return <ProgressPage key={'c' + chapterIndex + 'p' + pageIndex} page={page} itemPosition={itemPosition} position={position}/>;
87-
})}/>;
86+
})}>
87+
<h4>{chapterIndex + 1}. {chapter.title}</h4>
88+
<span className='cr-chapter-description'>
89+
<MarkdownText text={chapter.description} />
90+
</span>
91+
</ListItem>;
8892
})}
8993
</List>
9094
</Paper>

src/components/projects/projects.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export default class Projects extends React.Component<{
6161
}) : <ListItem
6262
key='demo'
6363
primaryText='Try a Demo'
64-
secondaryText='npm i -s coderoad-functional-school'/>}
64+
secondaryText='npm i --save-dev coderoad-functional-school'/>}
6565

6666
</List>
6767
<br />

0 commit comments

Comments
 (0)