Skip to content

Commit b25d1db

Browse files
committed
handle TopPanel page routing from tests
1 parent bad8ff0 commit b25d1db

File tree

9 files changed

+59
-25
lines changed

9 files changed

+59
-25
lines changed

lib/components/Page/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ var TasksComplete_1 = require('./TasksComplete');
2121
var TopPanel_1 = require('../TopPanel');
2222
var actions_1 = require('../../actions');
2323
var styles = {
24-
height: '100%',
25-
width: '100%',
26-
overflowY: 'scroll',
24+
page: {
25+
height: '100%',
26+
width: '100%',
27+
overflowY: 'scroll',
28+
},
2729
};
2830
var Page = (function (_super) {
2931
__extends(Page, _super);
@@ -38,7 +40,7 @@ var Page = (function (_super) {
3840
TopPanel_1.topElement.toggle(false);
3941
};
4042
Page.prototype.render = function () {
41-
return (React.createElement("section", {style: styles, className: 'cr-page'},
43+
return (React.createElement("section", {style: styles.page, className: 'cr-page'},
4244
React.createElement(PageDescription_1.default, null),
4345
React.createElement(Tasks_1.default, null),
4446
React.createElement(TasksComplete_1.default, null)));

lib/components/Test/index.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,17 @@ var __metadata = (this && this.__metadata) || function (k, v) {
1515
};
1616
var React = require('react');
1717
var react_redux_1 = require('react-redux');
18+
var Card_1 = require('material-ui/Card');
1819
var TopPanel_1 = require('../TopPanel');
1920
var styles = {
20-
height: '100%',
21-
width: '100%',
22-
overflowY: 'scroll',
21+
page: {
22+
height: '100%',
23+
width: '100%',
24+
overflowY: 'scroll',
25+
},
26+
card: {
27+
margin: '5px',
28+
},
2329
};
2430
var Test = (function (_super) {
2531
__extends(Test, _super);
@@ -30,8 +36,10 @@ var Test = (function (_super) {
3036
TopPanel_1.topElement.toggle(true);
3137
};
3238
Test.prototype.render = function () {
33-
return (React.createElement("section", {style: styles, className: 'cr-page'},
34-
React.createElement("h1", null, "Test")
39+
return (React.createElement("section", {style: styles.page, className: 'cr-page'},
40+
React.createElement(Card_1.Card, {style: styles.card, initiallyExpanded: true},
41+
React.createElement(Card_1.CardTitle, null, "Test"),
42+
React.createElement(Card_1.CardText, {expandable: true}, "test test"))
3543
));
3644
};
3745
Test = __decorate([

lib/components/TopPanel/TopPanel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ var TopPanel = (function (_super) {
4646
};
4747
TopPanel.prototype.render = function () {
4848
var _this = this;
49-
var _a = this.props, tutorial = _a.tutorial, tutorialPageAdd = _a.tutorialPageAdd;
49+
var tutorial = this.props.tutorial;
5050
if (!tutorial || !tutorial.pages) {
5151
return null;
5252
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
"use strict";
22
var types_1 = require('./types');
3+
var actions_1 = require('../../actions');
34
function pageSet(pagePosition) {
4-
return { type: types_1.PAGE_SET, payload: { pagePosition: pagePosition } };
5+
return function (dispatch, getState) {
6+
dispatch({ type: types_1.PAGE_SET, payload: { pagePosition: pagePosition } });
7+
dispatch(actions_1.routeSet('page'));
8+
};
59
}
610
exports.pageSet = pageSet;

src/actions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ export {
1414
alertOpen, alertClose, alertReplay,
1515
editorDevToolsToggle, editorOpen, editorInsert,
1616
editorSave, editorSet, editorScroll,
17-
routeSet
17+
routeSet,
1818
} from 'core-coderoad';

src/components/Page/index.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ import {topElement} from '../TopPanel';
99
import {editorMarkdownOpen} from '../../actions';
1010

1111
const styles = {
12-
height: '100%',
13-
width: '100%',
14-
overflowY: 'scroll',
12+
page: {
13+
height: '100%',
14+
width: '100%',
15+
overflowY: 'scroll',
16+
},
1517
};
1618

1719
@connect(null, {editorMarkdownOpen})
@@ -27,7 +29,7 @@ export default class Page extends React.Component<{
2729
}
2830
render() {
2931
return (
30-
<section style={styles} className='cr-page'>
32+
<section style={styles.page} className='cr-page'>
3133
<PageDescription />
3234
<Tasks />
3335
<TasksComplete />

src/components/Test/index.tsx

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
import * as React from 'react';
22
import {connect} from 'react-redux';
3-
import {Card} from 'material-ui/Card';
3+
import {Card, CardText, CardTitle} from 'material-ui/Card';
44
import {topElement} from '../TopPanel';
55

66
const styles = {
7-
height: '100%',
8-
width: '100%',
9-
overflowY: 'scroll',
7+
page: {
8+
height: '100%',
9+
width: '100%',
10+
overflowY: 'scroll',
11+
},
12+
card: {
13+
margin: '5px',
14+
},
1015
};
1116

1217
@connect(null, {})
@@ -16,8 +21,17 @@ export default class Test extends React.Component<{}, {}> {
1621
}
1722
render() {
1823
return (
19-
<section style={styles} className='cr-page'>
20-
<h1>Test</h1>
24+
<section style={styles.page} className='cr-page'>
25+
<Card
26+
style={styles.card}
27+
initiallyExpanded={true}
28+
>
29+
<CardTitle>Test</CardTitle>
30+
31+
<CardText expandable={true}>
32+
test test
33+
</CardText>
34+
</Card>
2135
</section>
2236
);
2337
}

src/components/TopPanel/TopPanel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const styles = {
2525
};
2626

2727
@connect(state => ({
28-
tutorial: state.tutorial,
28+
tutorial: state.tutorial,
2929
}), {pageSet, editorMarkdownOpen, tutorialPageAdd})
3030
export default class TopPanel extends React.Component<{
3131
tutorial?: CR.Tutorial,
@@ -38,7 +38,7 @@ export default class TopPanel extends React.Component<{
3838
this.props.editorMarkdownOpen(title, index);
3939
}
4040
render() {
41-
const {tutorial, tutorialPageAdd} = this.props;
41+
const {tutorial} = this.props;
4242

4343
// no tutorial or pages? no need for a tab bar
4444
if (!tutorial || !tutorial.pages) { return null; }
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import {PAGE_SET} from './types';
2+
import {routeSet} from '../../actions';
23

34
export function pageSet(pagePosition: number) {
4-
return { type: PAGE_SET, payload: { pagePosition } };
5+
return (dispatch, getState) => {
6+
dispatch({ type: PAGE_SET, payload: { pagePosition } });
7+
dispatch(routeSet('page'));
8+
};
59
}

0 commit comments

Comments
 (0)