Skip to content

Commit 563be6f

Browse files
committed
display tasks, complete message
1 parent 87e5dad commit 563be6f

File tree

8 files changed

+54
-75
lines changed

8 files changed

+54
-75
lines changed

lib/components/Page/Task/index.js

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,33 @@
11
"use strict";
22
var React = require('react');
33
var index_1 = require('../../index');
4-
var taskCheckbox_1 = require('./taskCheckbox');
54
var List_1 = require('material-ui/List');
65
var colors_1 = require('material-ui/styles/colors');
76
var styles = {
8-
margin: '5px',
9-
padding: '5px',
10-
position: 'relative'
11-
};
12-
var indexStyles = {
13-
position: 'absolute',
14-
top: '20px',
15-
left: '45px',
16-
};
17-
var descriptionStyles = {
18-
backgroundColor: 'inherit',
19-
paddingTop: '-10px',
20-
paddingLeft: '55px',
21-
fontSize: '14px',
22-
lineHeight: '1.6',
7+
task: {
8+
margin: '5px',
9+
padding: '5px',
10+
position: 'relative'
11+
},
12+
index: {
13+
position: 'absolute',
14+
top: '20px',
15+
left: '45px',
16+
},
17+
description: {
18+
backgroundColor: 'inherit',
19+
paddingTop: '-10px',
20+
paddingLeft: '55px',
21+
fontSize: '14px',
22+
lineHeight: '1.6',
23+
},
2324
};
2425
function getStatus(index, taskPosition, testRun) {
2526
return index < taskPosition ? colors_1.lightGreen200 : 'inherit';
2627
}
2728
var Task = function (_a) {
28-
var task = _a.task, taskPosition = _a.taskPosition, index = _a.index, testRun = _a.testRun;
29-
var backgroundColor = getStatus(index, taskPosition, testRun);
30-
var isCurrentTask = taskPosition === index;
31-
return (React.createElement(List_1.ListItem, {key: index, style: Object.assign({}, styles, { backgroundColor: backgroundColor })}, taskCheckbox_1.default(isCurrentTask, testRun), React.createElement("span", {style: indexStyles}, index + 1, "."), React.createElement("div", {style: descriptionStyles}, React.createElement(index_1.Markdown, null, task.description))));
29+
var task = _a.task, index = _a.index;
30+
return (React.createElement(List_1.ListItem, {key: index, style: styles.task}, React.createElement("span", {style: styles.index}, index + 1, "."), React.createElement("div", {style: styles.description}, React.createElement(index_1.Markdown, null, task.description))));
3231
};
3332
Object.defineProperty(exports, "__esModule", { value: true });
3433
exports.default = Task;

lib/components/Page/Tasks/index.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,25 @@ var __extends = (this && this.__extends) || function (d, b) {
55
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
66
};
77
var React = require('react');
8-
var ReactDOM = require('react-dom');
98
var List_1 = require('material-ui/List');
109
var Card_1 = require('material-ui/Card');
1110
var Subheader_1 = require('material-ui/Subheader');
1211
var Task_1 = require('../Task');
13-
var colors_1 = require('material-ui/styles/colors');
1412
var TasksComplete_1 = require('../TasksComplete');
1513
function visibleTasks(tasks, taskPosition) {
1614
return tasks.slice(0, taskPosition + 1);
1715
}
18-
var margin = '10px 5px';
16+
var styles = {
17+
margin: '10px 5px'
18+
};
1919
var Tasks = (function (_super) {
2020
__extends(Tasks, _super);
2121
function Tasks() {
2222
_super.apply(this, arguments);
2323
}
24-
Tasks.prototype.componentDidUpdate = function () {
25-
ReactDOM.findDOMNode(this.refs.listEnd).scrollIntoView();
26-
};
2724
Tasks.prototype.render = function () {
28-
var _a = this.props, tasks = _a.tasks, taskPosition = _a.taskPosition, testRun = _a.testRun, completed = _a.completed, page = _a.page;
29-
var visTasks = visibleTasks(tasks, taskPosition);
30-
var backgroundColor = completed ? colors_1.lightGreen200 : 'white';
31-
return (React.createElement("div", null, React.createElement(Card_1.Card, {style: { backgroundColor: backgroundColor, margin: margin }}, React.createElement(List_1.List, null, React.createElement(Subheader_1.default, null, "Tasks"), visTasks.map(function (task, index) { return (React.createElement(Task_1.default, {key: index, index: index, task: task, taskPosition: taskPosition, testRun: testRun})); }))), React.createElement(TasksComplete_1.default, {page: page, completed: completed}), React.createElement("div", {ref: 'listEnd'})));
25+
var _a = this.props, tasks = _a.tasks, page = _a.page;
26+
return (React.createElement("div", null, React.createElement(Card_1.Card, {style: styles}, React.createElement(List_1.List, null, React.createElement(Subheader_1.default, null, "Tasks"), tasks.map(function (task, index) { return (React.createElement(Task_1.default, {key: index, index: index, task: task})); }))), React.createElement(TasksComplete_1.default, {page: page}), React.createElement("div", {ref: 'listEnd'})));
3227
};
3328
return Tasks;
3429
}(React.Component));

lib/components/Page/TasksComplete/index.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,21 @@ var Card_1 = require('material-ui/Card');
44
var index_1 = require('../../index');
55
var colors_1 = require('material-ui/styles/colors');
66
var styles = {
7-
backgroundColor: colors_1.cyan500,
8-
margin: '10px 5px',
9-
};
10-
var textStyles = {
11-
color: colors_1.grey100,
12-
fontSize: '1.1em'
7+
card: {
8+
backgroundColor: colors_1.cyan500,
9+
margin: '10px 5px',
10+
},
11+
text: {
12+
color: colors_1.grey100,
13+
fontSize: '1.1em'
14+
},
1315
};
1416
var TasksComplete = function (_a) {
15-
var page = _a.page, completed = _a.completed;
16-
if (!completed || !page.onPageComplete) {
17+
var page = _a.page;
18+
if (!page.onPageComplete) {
1719
return null;
1820
}
19-
return (React.createElement(Card_1.Card, {style: styles}, React.createElement(Card_1.CardText, null, React.createElement(index_1.Markdown, {style: textStyles}, page.onPageComplete))));
21+
return (React.createElement(Card_1.Card, {style: styles.card}, React.createElement(Card_1.CardText, null, React.createElement(index_1.Markdown, {style: styles.text}, page.onPageComplete))));
2022
};
2123
Object.defineProperty(exports, "__esModule", { value: true });
2224
exports.default = TasksComplete;

lib/components/Page/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use strict";
22
var React = require('react');
33
var index_1 = require('../index');
4+
var Tasks_1 = require('./Tasks');
45
var styles = {
56
width: '100%',
67
overflowY: 'scroll',
@@ -11,7 +12,7 @@ var Page = function (_a) {
1112
if (!page) {
1213
return null;
1314
}
14-
return (React.createElement("section", {style: styles, className: 'cr-page'}, React.createElement(index_1.ContentCard, {title: page.title, content: page.description})));
15+
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})));
1516
};
1617
Object.defineProperty(exports, "__esModule", { value: true });
1718
exports.default = Page;

src/components/Page/Task/index.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,13 @@ function getStatus(
3131
}
3232

3333
const Task: React.StatelessComponent<{
34-
task: CR.Task, taskPosition: number, index: number, testRun: boolean
35-
}> = ({task, taskPosition, index, testRun}) => {
36-
const backgroundColor = getStatus(index, taskPosition, testRun);
37-
const isCurrentTask = taskPosition === index;
34+
task: CR.Task, index: number
35+
}> = ({task, index}) => {
3836
return (
3937
<ListItem
4038
key={index}
41-
style={Object.assign({}, styles.task, {backgroundColor})}
39+
style={styles.task}
4240
>
43-
{taskCheckbox(isCurrentTask, testRun)}
4441
<span style={styles.index}>{index + 1}.</span>
4542
<div style={styles.description}>
4643
<Markdown >{task.description}</Markdown>

src/components/Page/Tasks/index.tsx

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,43 +11,32 @@ function visibleTasks(tasks: CR.Task[], taskPosition: number): CR.Task[] {
1111
return tasks.slice(0, taskPosition + 1);
1212
}
1313

14-
const margin = '10px 5px';
14+
const styles = {
15+
margin: '10px 5px'
16+
};
1517

1618
export default class Tasks extends React.Component<{
17-
tasks: CR.Task[], taskPosition: number,
18-
testRun: boolean, completed: boolean, page: CR.Page
19+
tasks: CR.Task[], page: CR.Page
1920
}, {}> {
20-
refs: {
21-
[key: string]: (Element);
22-
listEnd: Element;
23-
};
24-
componentDidUpdate() {
25-
ReactDOM.findDOMNode<HTMLElement>(this.refs.listEnd).scrollIntoView();
26-
}
2721
render() {
28-
const {tasks, taskPosition, testRun, completed, page} = this.props;
29-
const visTasks = visibleTasks(tasks, taskPosition);
30-
const backgroundColor = completed ? lightGreen200 : 'white';
22+
const {tasks, page} = this.props;
3123
return (
3224
<div>
33-
<Card style={{backgroundColor, margin}}>
25+
<Card style={styles}>
3426
<List>
3527
<Subheader>Tasks</Subheader>
36-
{visTasks.map((task: CR.Task, index: number) => (
28+
{tasks.map((task: CR.Task, index: number) => (
3729
<Task
3830
key={index}
3931
index={index}
4032
task={task}
41-
taskPosition={taskPosition}
42-
testRun={testRun}
4333
/>)
4434
)}
4535
</List>
4636
</Card>
4737

4838
<TasksComplete
4939
page={page}
50-
completed={completed}
5140
/>
5241

5342
<div ref='listEnd' />

src/components/Page/TasksComplete/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ const styles = {
1515
};
1616

1717
const TasksComplete: React.StatelessComponent<{
18-
page: CR.Page, completed: boolean
19-
}> = ({page, completed}) => {
20-
if (!completed || !page.onPageComplete) { return null; }
18+
page: CR.Page
19+
}> = ({page}) => {
20+
if (!page.onPageComplete) { return null; }
2121
return (
2222
<Card style={styles.card}>
2323
<CardText>

src/components/Page/index.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react';
22
import Divider from 'material-ui/Divider';
33
import {Card} from 'material-ui/Card';
44
import {ContentCard} from '../index';
5-
// import Tasks from './Tasks';
5+
import Tasks from './Tasks';
66

77
const styles = {
88
width: '100%',
@@ -12,7 +12,6 @@ const styles = {
1212
const Page: React.StatelessComponent<{
1313
tutorial: CR.Tutorial, pagePosition: number
1414
}> = ({tutorial, pagePosition}) => {
15-
// const completed = progress.pages[pagePosition];
1615
const page = tutorial.pages[pagePosition];
1716

1817
if (!page) { return null; }
@@ -24,13 +23,10 @@ const Page: React.StatelessComponent<{
2423
content={page.description}
2524
/>
2625

27-
{/*}<Tasks
28-
tasks={tasks}
29-
taskPosition={taskPosition}
30-
testRun={testRun}
31-
completed={completed}
26+
<Tasks
27+
tasks={page.tasks}
3228
page={page}
33-
/>*/}
29+
/>
3430

3531
</section>
3632
);

0 commit comments

Comments
 (0)