Skip to content

Commit ff292f2

Browse files
committed
save button
1 parent eab6f71 commit ff292f2

File tree

13 files changed

+53
-15
lines changed

13 files changed

+53
-15
lines changed

lib/atom/editor.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ exports.setAtomGlobals = setAtomGlobals;
1818
var getEditorCount = 0;
1919
function save() {
2020
var editor = findEditor();
21+
console.log(editor);
2122
editor.save();
2223
}
2324
exports.save = save;

lib/components/menu/menu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ var default_1 = (function (_super) {
4949
render_1.togglePanel();
5050
};
5151
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.ListDivider, null), React.createElement(material_ui_1.MenuItem, {primaryText: 'quit', onTouchTap: this.props.quit}))}));
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}))}));
5353
};
5454
default_1 = __decorate([
5555
react_redux_1.connect(null, function (dispatch) {

lib/components/page/page.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ var default_1 = (function (_super) {
2828
var _a = this.props, page = _a.page, taskPosition = _a.taskPosition, hintPosition = _a.hintPosition, tasks = _a.tasks, runTests = _a.runTests;
2929
var currentTask = taskPosition <= tasks.length ? tasks[taskPosition] : null;
3030
var allComplete = taskPosition >= tasks.length;
31-
return (React.createElement(material_ui_1.Paper, {style: pageStyle, zDepth: 1, className: 'cr-page'}, React.createElement(content_1.default, {page: page}), React.createElement(material_ui_1.ListDivider, null), React.createElement(task_1.Tasks, {tasks: tasks, taskPosition: taskPosition, runTests: runTests}), React.createElement(hint_1.default, {task: currentTask, hintPosition: hintPosition}), React.createElement(page_complete_1.PageCompleteMessage, {page: page}), React.createElement("div", {ref: 'listEnd'}), React.createElement(toolbar_1.default, {tasks: tasks, taskPosition: taskPosition, hintPosition: hintPosition})));
31+
return (React.createElement(material_ui_1.Paper, {style: pageStyle, zDepth: 1, className: 'cr-page'}, React.createElement(content_1.default, {page: page}), React.createElement(material_ui_1.Divider, null), React.createElement(task_1.Tasks, {tasks: tasks, taskPosition: taskPosition, runTests: runTests}), React.createElement(hint_1.default, {task: currentTask, hintPosition: hintPosition}), React.createElement(page_complete_1.PageCompleteMessage, {page: page}), React.createElement("div", {ref: 'listEnd'}), React.createElement(toolbar_1.default, {tasks: tasks, taskPosition: taskPosition, hintPosition: hintPosition})));
3232
};
3333
return default_1;
3434
}(React.Component));

lib/components/page/toolbar.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,19 @@ var default_1 = (function (_super) {
3131
_super.apply(this, arguments);
3232
}
3333
default_1.prototype.render = function () {
34-
var _a = this.props, tasks = _a.tasks, taskPosition = _a.taskPosition, hintPosition = _a.hintPosition, callNextPage = _a.callNextPage, callRunTests = _a.callRunTests, showHint = _a.showHint;
34+
var _a = this.props, tasks = _a.tasks, taskPosition = _a.taskPosition, hintPosition = _a.hintPosition, callNextPage = _a.callNextPage, showHint = _a.showHint;
3535
var currentTask = taskPosition <= tasks.length ? tasks[taskPosition] : null;
3636
var progress = taskProgress(taskPosition, tasks.length);
3737
var allComplete = taskPosition >= tasks.length;
3838
return (React.createElement("section", {className: 'cr-page-toolbar'}, React.createElement(ProgressBar, {progress: progress}), React.createElement(material_ui_1.Toolbar, null, React.createElement(material_ui_1.ToolbarGroup, {float: 'right'}, allComplete ?
3939
React.createElement(material_ui_1.RaisedButton, {label: 'Continue', primary: true, onTouchTap: callNextPage})
4040
:
41-
React.createElement(material_ui_1.RaisedButton, {label: 'Save', secondary: true, onTouchTap: callRunTests})))));
41+
React.createElement(material_ui_1.RaisedButton, {label: 'Save', secondary: true, onTouchTap: editor_1.save})))));
4242
};
4343
default_1 = __decorate([
4444
react_redux_1.connect(null, function (dispatch, state) {
4545
return {
4646
callNextPage: function () { return dispatch(Action.nextPage()); },
47-
callSave: function () { return editor_1.save(); },
4847
toggleLog: function () { return dispatch(Action.toggleLog()); }
4948
};
5049
}),

lib/components/router.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ var __extends = (this && this.__extends) || function (d, b) {
66
};
77
var React = require('react');
88
var _components_1 = require('./_components');
9+
var ReactCSSTransitionGroup = require('react-addons-css-transition-group');
910
var default_1 = (function (_super) {
1011
__extends(default_1, _super);
1112
function default_1() {
@@ -25,7 +26,7 @@ var default_1 = (function (_super) {
2526
};
2627
default_1.prototype.render = function () {
2728
var state = this.props.state;
28-
return this.chooseRoute(state);
29+
return (React.createElement(ReactCSSTransitionGroup, {transitionName: 'route', transitionEnterTimeout: 500, transitionLeaveTimeout: 300}, this.chooseRoute(state)));
2930
};
3031
return default_1;
3132
}(React.Component));

src/atom/editor.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ let getEditorCount = 0;
1818

1919
export function save() {
2020
const editor = findEditor();
21+
console.log(editor);
2122
editor.save();
2223
}
2324

src/components/_index.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@import './app/_app';
2+
@import './app/_route';
23
@import './menu/_menu';
34
@import './page/_chapter';
45
@import './page/_page';

src/components/app/_route.less

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.route-enter {
2+
opacity: 0.01;
3+
}
4+
5+
.route-enter.route-enter-active {
6+
opacity: 1;
7+
transition: opacity 500ms ease-in;
8+
}
9+
10+
.route-leave {
11+
opacity: 1;
12+
}
13+
14+
.route-leave.route-leave-active {
15+
opacity: 0.01;
16+
transition: opacity 300ms ease-in;
17+
}

src/components/menu/menu.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as Action from '../../actions/actions';
55
import {togglePanel} from '../render';
66
import {onDeactivateSubscriptionsAndUnmount} from '../../atom/subscriptions';
77

8-
import {AppBar, IconButton, IconMenu, MenuItem, ListDivider} from 'material-ui';
8+
import {AppBar, IconButton, IconMenu, MenuItem, Divider} from 'material-ui';
99
let MoreVertIcon = require('material-ui/lib/svg-icons/navigation/more-vert');
1010
let NavigationClose = require('material-ui/lib/svg-icons/navigation/close');
1111
// let Feedback = require('material-ui/lib/svg-icons/action/feedback');
@@ -80,7 +80,7 @@ export default class extends React.Component<{
8080
</a>
8181
</MenuItem> : null}
8282

83-
<ListDivider />
83+
<Divider />
8484
<MenuItem primaryText='quit' onTouchTap={this.props.quit}/>
8585

8686
</IconMenu>

src/components/page/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22
import * as React from 'react';
33
import * as ReactDOM from 'react-dom';
4-
import {Paper, ListDivider} from 'material-ui';
4+
import {Paper, Divider} from 'material-ui';
55
import PageContent from './content';
66
import {Tasks} from './task';
77
import Hints from './hint';
@@ -37,7 +37,7 @@ render() {
3737
return (
3838
<Paper style={pageStyle} zDepth={1} className='cr-page'>
3939
<PageContent page={page} />
40-
<ListDivider />
40+
<Divider />
4141

4242
<Tasks tasks={tasks} taskPosition={taskPosition} runTests={runTests} />
4343
<Hints task={currentTask} hintPosition={hintPosition} />

src/components/page/toolbar.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,15 @@ function taskProgress(current: number, max: number) {
1414
@connect(null, (dispatch, state) => {
1515
return {
1616
callNextPage: () => dispatch(Action.nextPage()),
17-
callSave: () => save(),
1817
toggleLog: () => dispatch(Action.toggleLog())
1918
};
2019
})
2120
export default class extends React.Component<{
2221
tasks: CR.Task[], taskPosition: number, hintPosition: number,
23-
callNextPage?: () => void, callRunTests?: () => void, callNextTask?: () => void, showHint?: (pos: number) => void
22+
callNextPage?: () => void, callNextTask?: () => void, showHint?: (pos: number) => void
2423
}, {}> {
2524
render() {
26-
const {tasks, taskPosition, hintPosition, callNextPage, callRunTests, showHint} = this.props;
25+
const {tasks, taskPosition, hintPosition, callNextPage, showHint} = this.props;
2726
const currentTask = taskPosition <= tasks.length ? tasks[taskPosition] : null;
2827
const progress: number = taskProgress(taskPosition, tasks.length);
2928
const allComplete = taskPosition >= tasks.length;
@@ -40,7 +39,7 @@ export default class extends React.Component<{
4039
{allComplete ?
4140
<RaisedButton label='Continue' primary={true} onTouchTap={callNextPage}/>
4241
:
43-
<RaisedButton label='Save' secondary={true} onTouchTap={callRunTests}/>
42+
<RaisedButton label='Save' secondary={true} onTouchTap={save}/>
4443
}
4544
</ToolbarGroup>
4645

src/components/router.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as React from 'react';
22
import {Page, Progress, Projects} from './_components';
3+
import * as ReactCSSTransitionGroup from 'react-addons-css-transition-group';
34

45
export default class extends React.Component<{state: CR.State}, {}> {
56
chooseRoute(state: CR.State) {
@@ -23,6 +24,10 @@ export default class extends React.Component<{state: CR.State}, {}> {
2324
}
2425
render() {
2526
const state = this.props.state;
26-
return this.chooseRoute(state);
27+
return (
28+
<ReactCSSTransitionGroup transitionName='route' transitionEnterTimeout={500} transitionLeaveTimeout={300}>
29+
{this.chooseRoute(state)}
30+
</ReactCSSTransitionGroup>
31+
);
2732
}
2833
}

styles/styles.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,20 @@ atom-panel-container > atom-panel > #crv {
1212
width: 400px;
1313
}
1414
}
15+
.route-enter {
16+
opacity: 0.01;
17+
}
18+
.route-enter.route-enter-active {
19+
opacity: 1;
20+
transition: opacity 500ms ease-in;
21+
}
22+
.route-leave {
23+
opacity: 1;
24+
}
25+
.route-leave.route-leave-active {
26+
opacity: 0.01;
27+
transition: opacity 300ms ease-in;
28+
}
1529
.cr .cr-menu-bar {
1630
z-index: 999 !important;
1731
}

0 commit comments

Comments
 (0)