Skip to content

Commit 20d49d7

Browse files
committed
open TopPanel only on Page
1 parent bb0c279 commit 20d49d7

File tree

10 files changed

+66
-35
lines changed

10 files changed

+66
-35
lines changed

Diff for: lib/components/Page/index.js

+24-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,35 @@
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+
};
27
var React = require('react');
38
var index_1 = require('../index');
49
var Tasks_1 = require('./Tasks');
10+
var Top_1 = require('../TopPanel/Top');
511
var styles = {
612
width: '100%',
713
overflowY: 'scroll',
814
};
9-
var Page = function (_a) {
10-
var tutorial = _a.tutorial, pagePosition = _a.pagePosition;
11-
var page = tutorial.pages[pagePosition];
12-
console.log(page);
13-
if (!page) {
14-
return null;
15+
var Page = (function (_super) {
16+
__extends(Page, _super);
17+
function Page() {
18+
_super.apply(this, arguments);
1519
}
16-
return (React.createElement("section", {style: styles, className: 'cr-page'}, React.createElement(index_1.ContentCard, {title: page.title, content: page.description}), React.createElement(Tasks_1.default, {tasks: page.tasks, page: page})));
17-
};
20+
Page.prototype.componentDidMount = function () {
21+
Top_1.default.toggle(true);
22+
};
23+
Page.prototype.render = function () {
24+
var _a = this.props, tutorial = _a.tutorial, pagePosition = _a.pagePosition;
25+
var page = tutorial.pages[pagePosition];
26+
if (!page) {
27+
return null;
28+
}
29+
return (React.createElement("section", {style: styles, className: 'cr-page'}, React.createElement(index_1.ContentCard, {title: page.title, content: page.description}), React.createElement(Tasks_1.default, {tasks: page.tasks, page: page})));
30+
};
31+
return Page;
32+
}(React.Component));
1833
Object.defineProperty(exports, "__esModule", { value: true });
1934
exports.default = Page;
35+
;

Diff for: lib/components/Routes/index.js

-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ var __assign = (this && this.__assign) || Object.assign || function(t) {
1414
};
1515
var React = require('react');
1616
var index_1 = require('../index');
17-
var Top_1 = require('../TopPanel/Top');
1817
var Routes = (function (_super) {
1918
__extends(Routes, _super);
2019
function Routes() {
@@ -23,7 +22,6 @@ var Routes = (function (_super) {
2322
Routes.prototype.render = function () {
2423
switch (this.props.route) {
2524
case 'page':
26-
Top_1.default.toggle(false);
2725
return React.createElement(index_1.Page, __assign({}, this.props));
2826
case 'start':
2927
return React.createElement(index_1.Start, __assign({}, this.props));

Diff for: lib/components/TopPanel/Top.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var Top = {
1111
return _this.top;
1212
},
1313
toggle: function (open) {
14-
_this.top.hidden = open || !_this.top.hidden;
14+
_this.top.hidden = !open || !_this.top.hidden;
1515
},
1616
unmount: function () {
1717
ReactDOM.unmountComponentAtNode(_this.root);

Diff for: lib/components/TutorialConfig/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ var RaisedButton_1 = require('material-ui/RaisedButton');
2323
var actions_1 = require('../../actions');
2424
var languageItems_1 = require('./languageItems');
2525
var runnerItems_1 = require('./runnerItems');
26+
var Top_1 = require('../TopPanel/Top');
2627
var styles = {
2728
card: {
2829
margin: '10px',
@@ -41,6 +42,9 @@ var TutorialConfig = (function (_super) {
4142
pj: this.props.packageJson
4243
};
4344
}
45+
TutorialConfig.prototype.componentDidMount = function () {
46+
Top_1.default.toggle(false);
47+
};
4448
TutorialConfig.prototype.handleText = function (prop, event) {
4549
this.handleChange(prop, event.target.value);
4650
};

Diff for: lib/components/TutorialInfo/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ var TextField_1 = require('material-ui/TextField');
1919
var Card_1 = require('material-ui/Card');
2020
var RaisedButton_1 = require('material-ui/RaisedButton');
2121
var actions_1 = require('../../actions');
22+
var Top_1 = require('../TopPanel/Top');
2223
var styles = {
2324
margin: '10px',
2425
padding: '30px 20px',
@@ -35,6 +36,9 @@ var TutorialInfo = (function (_super) {
3536
pj: this.props.packageJson
3637
};
3738
}
39+
TutorialInfo.prototype.componentDidMount = function () {
40+
Top_1.default.toggle(false);
41+
};
3842
TutorialInfo.prototype.handleText = function (prop, event) {
3943
this.handleChange(prop, event.target.value);
4044
};

Diff for: src/components/Page/index.tsx

+23-20
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,36 @@ import Divider from 'material-ui/Divider';
33
import {Card} from 'material-ui/Card';
44
import {ContentCard} from '../index';
55
import Tasks from './Tasks';
6+
import Top from '../TopPanel/Top';
67

78
const styles = {
89
width: '100%',
910
overflowY: 'scroll',
1011
};
1112

12-
const Page: React.StatelessComponent<{
13+
export default class Page extends React.Component<{
1314
tutorial: CR.Tutorial, pagePosition: number
14-
}> = ({tutorial, pagePosition}) => {
15-
const page = tutorial.pages[pagePosition];
16-
console.log(page);
15+
}, {}> {
16+
componentDidMount() {
17+
Top.toggle(true);
18+
}
19+
render() {
20+
const {tutorial, pagePosition} = this.props;
21+
const page = tutorial.pages[pagePosition];
1722

18-
if (!page) { return null; }
23+
if (!page) { return null; }
1924

20-
return (
21-
<section style={styles} className='cr-page'>
22-
<ContentCard
23-
title={page.title}
24-
content={page.description}
25-
/>
26-
27-
<Tasks
28-
tasks={page.tasks}
29-
page={page}
30-
/>
31-
32-
</section>
33-
);
25+
return (
26+
<section style={styles} className='cr-page'>
27+
<ContentCard
28+
title={page.title}
29+
content={page.description}
30+
/>
31+
<Tasks
32+
tasks={page.tasks}
33+
page={page}
34+
/>
35+
</section>
36+
);
37+
}
3438
};
35-
export default Page;

Diff for: src/components/Routes/index.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as React from 'react';
22
import {Page, Start, TutorialConfig, TutorialInfo} from '../index';
3-
import Top from '../TopPanel/Top';
43

54
export default class Routes extends React.Component<{
65
route: string, checks: Builder.Checks, pagePosition: CR.PagePosition,
@@ -9,7 +8,6 @@ export default class Routes extends React.Component<{
98
render() {
109
switch (this.props.route) {
1110
case 'page':
12-
Top.toggle(false);
1311
return <Page {...this.props} />;
1412
case 'start':
1513
return <Start {...this.props} />;

Diff for: src/components/TopPanel/Top.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const Top = {
1010
return this.top;
1111
},
1212
toggle: (open?: boolean) => {
13-
this.top.hidden = open || !this.top.hidden;
13+
this.top.hidden = !open || !this.top.hidden;
1414
},
1515
unmount: () => {
1616
ReactDOM.unmountComponentAtNode(this.root);

Diff for: src/components/TutorialConfig/index.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import RaisedButton from 'material-ui/RaisedButton';
99
import {pjSave, tutorialInit, routeSet} from '../../actions';
1010
import languageItems from './languageItems';
1111
import runnerItems from './runnerItems';
12+
import Top from '../TopPanel/Top';
1213

1314
const styles = {
1415
card: {
@@ -43,6 +44,9 @@ export default class TutorialConfig extends React.Component <{
4344
pj: this.props.packageJson
4445
};
4546
}
47+
componentDidMount() {
48+
Top.toggle(false);
49+
}
4650
handleText(prop, event) {
4751
this.handleChange(prop, event.target.value);
4852
}

Diff for: src/components/TutorialInfo/index.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import {connect} from 'react-redux';
33
import TextField from 'material-ui/TextField';
44
import SelectField from 'material-ui/SelectField';
55
import MenuItem from 'material-ui/MenuItem';
6-
import {Card, CardHeader} from 'material-ui/Card'
6+
import {Card, CardHeader} from 'material-ui/Card';
77
import RaisedButton from 'material-ui/RaisedButton';
88
import {pjSave, routeSet} from '../../actions';
9+
import Top from '../TopPanel/Top';
910

1011
const styles = {
1112
margin: '10px',
@@ -38,6 +39,9 @@ export default class TutorialInfo extends React.Component<{
3839
pj: this.props.packageJson
3940
};
4041
}
42+
componentDidMount() {
43+
Top.toggle(false);
44+
}
4145
handleText(prop, event) {
4246
this.handleChange(prop, event.target.value);
4347
}

0 commit comments

Comments
 (0)