Skip to content

Commit 88de366

Browse files
committed
page component style improvements
1 parent 6fa66c0 commit 88de366

File tree

7 files changed

+43
-53
lines changed

7 files changed

+43
-53
lines changed

lib/components/Page/Hints/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@ exports.Hints = function (_a) {
1111
return null;
1212
}
1313
var hint = hints[hintPosition];
14-
return (React.createElement(Card_1.Card, {className: 'cr-task-hints'}, React.createElement(Card_1.CardHeader, {title: 'Hints', avatar: React.createElement(help_1.default, null), actAsExpander: true, showExpandableButton: true}), React.createElement(Card_1.CardText, {className: 'cr-task-hint', expandable: true}, React.createElement(index_1.Markdown, null, hint)), React.createElement(Card_1.CardActions, {expandable: true, className: 'cr-task-hints-actions'}, React.createElement(HintButton_1.HintButton, {type: 'prev', label: 'Previous', hintPosition: hintPosition, hintsLength: hints.length}), React.createElement(HintButton_1.HintButton, {type: 'next', label: 'Next', hintPosition: hintPosition, hintsLength: hints.length}))));
14+
return (React.createElement(Card_1.Card, {className: 'cr-task-hints'}, React.createElement(Card_1.CardHeader, {title: 'Hints', avatar: React.createElement(help_1.default, null), actAsExpander: true, showExpandableButton: true}), React.createElement(Card_1.CardText, {className: 'cr-task-hint', expandable: true}, React.createElement(index_1.Markdown, null, hint)), hints.length > 1
15+
? React.createElement(Card_1.CardActions, {expandable: true, className: 'cr-task-hints-actions'}, React.createElement(HintButton_1.HintButton, {type: 'prev', label: 'Previous', hintPosition: hintPosition, hintsLength: hints.length}), React.createElement(HintButton_1.HintButton, {type: 'next', label: 'Next', hintPosition: hintPosition, hintsLength: hints.length}))
16+
: null));
1517
};

lib/components/Page/Tasks/Task.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function getStatus(index, taskPosition, testRun) {
88
case index < taskPosition:
99
return colors_1.lightGreen200;
1010
case testRun:
11-
return colors_1.orange500;
11+
return colors_1.orange200;
1212
default:
1313
return 'inherit';
1414
}

lib/components/Progress/ProgressPage.js

+6-13
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ var __metadata = (this && this.__metadata) || function (k, v) {
1616
var React = require('react');
1717
var react_redux_1 = require('react-redux');
1818
var actions_1 = require('../../actions');
19-
var classnames = require('classnames');
2019
var List_1 = require('material-ui/List');
2120
var progressIcon_1 = require('./progressIcon');
21+
var colors_1 = require('material-ui/styles/colors');
2222
var ProgressPage = (function (_super) {
2323
__extends(ProgressPage, _super);
2424
function ProgressPage() {
@@ -29,26 +29,19 @@ var ProgressPage = (function (_super) {
2929
var earlierChapter = chapterIndex < position.chapter;
3030
var currentChapter = chapterIndex === position.chapter;
3131
var earlierOrCurrentPage = pageIndex <= position.page;
32-
if (isActive || earlierChapter ||
33-
(currentChapter && earlierOrCurrentPage)) {
34-
return true;
35-
}
36-
else {
37-
return null;
38-
}
32+
return isActive || earlierChapter ||
33+
(currentChapter && earlierOrCurrentPage);
3934
};
4035
ProgressPage.prototype.render = function () {
4136
var _a = this.props, page = _a.page, position = _a.position, chapterIndex = _a.chapterIndex, pageIndex = _a.pageIndex, selectPage = _a.selectPage;
4237
var isActive = chapterIndex === position.chapter && pageIndex === position.page;
43-
return (React.createElement(List_1.ListItem, {className: classnames({
44-
'page': true,
45-
'page-isDisabled': !this.canActivate(isActive)
46-
}), primaryText: (pageIndex + 1) + ". " + page.title, secondaryText: page.description, leftIcon: progressIcon_1.progressIcon(page.completed, isActive), onClick: this.canActivate(isActive)
38+
var canActivate = this.canActivate(isActive);
39+
return (React.createElement(List_1.ListItem, {className: 'page', style: !canActivate ? { color: colors_1.grey400 } : {}, primaryText: (pageIndex + 1) + ". " + page.title, secondaryText: canActivate ? page.description : '', leftIcon: progressIcon_1.progressIcon(page.completed, isActive), onClick: canActivate
4740
? selectPage.bind(this, {
4841
chapter: chapterIndex,
4942
page: pageIndex
5043
})
51-
: null}));
44+
: function () { return; }}));
5245
};
5346
;
5447
ProgressPage = __decorate([

src/components/Page/Hints/index.tsx

+20-17
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,26 @@ export const Hints: React.StatelessComponent<{
2626
>
2727
<Markdown>{hint}</Markdown>
2828
</CardText>
29-
<CardActions
30-
expandable={true}
31-
className='cr-task-hints-actions'
32-
>
33-
<HintButton
34-
type='prev'
35-
label='Previous'
36-
hintPosition={hintPosition}
37-
hintsLength={hints.length}
38-
/>
39-
<HintButton
40-
type='next'
41-
label='Next'
42-
hintPosition={hintPosition}
43-
hintsLength={hints.length}
44-
/>
45-
</CardActions>
29+
{hints.length > 1
30+
? <CardActions
31+
expandable={true}
32+
className='cr-task-hints-actions'
33+
>
34+
<HintButton
35+
type='prev'
36+
label='Previous'
37+
hintPosition={hintPosition}
38+
hintsLength={hints.length}
39+
/>
40+
<HintButton
41+
type='next'
42+
label='Next'
43+
hintPosition={hintPosition}
44+
hintsLength={hints.length}
45+
/>
46+
</CardActions>
47+
: null
48+
}
4649
</Card>
4750
);
4851
};

src/components/Page/Tasks/Task.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react';
22
import {Markdown} from '../../index';
33
// import {TaskCheckbox} from './TaskCheckbox';
44
import {ListItem} from 'material-ui/List';
5-
import {lightGreen200, orange500} from 'material-ui/styles/colors';
5+
import {lightGreen200, orange200} from 'material-ui/styles/colors';
66

77
function getStatus(
88
index: number, taskPosition: number, testRun: boolean
@@ -11,7 +11,7 @@ function getStatus(
1111
case index < taskPosition:
1212
return lightGreen200;
1313
case testRun:
14-
return orange500;
14+
return orange200;
1515
default:
1616
return 'inherit';
1717
}

src/components/Progress/ProgressPage.tsx

+9-13
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {pageSet, setRoute, testsLoad} from '../../actions';
44
import * as classnames from 'classnames';
55
import {ListItem} from 'material-ui/List';
66
import {progressIcon} from './progressIcon';
7+
import {grey400} from 'material-ui/styles/colors';
78

89
@connect(null, (dispatch) => {
910
return {
@@ -22,32 +23,27 @@ export class ProgressPage extends React.Component<{
2223
const earlierChapter = chapterIndex < position.chapter;
2324
const currentChapter = chapterIndex === position.chapter;
2425
const earlierOrCurrentPage = pageIndex <= position.page;
25-
if (isActive || earlierChapter ||
26-
(currentChapter && earlierOrCurrentPage)) {
27-
return true;
28-
} else {
29-
return null;
30-
}
26+
return isActive || earlierChapter ||
27+
(currentChapter && earlierOrCurrentPage);
3128
}
3229
render() {
3330
const {page, position, chapterIndex, pageIndex, selectPage} = this.props;
3431
const isActive = chapterIndex === position.chapter && pageIndex === position.page;
32+
const canActivate = this.canActivate(isActive);
3533
return (
3634
<ListItem
37-
className={classnames({
38-
'page': true,
39-
'page-isDisabled': !this.canActivate(isActive)
40-
})}
35+
className='page'
36+
style={!canActivate ? {color: grey400} : {}}
4137
primaryText={`${pageIndex + 1}. ${page.title}`}
42-
secondaryText={page.description}
38+
secondaryText={canActivate ? page.description : ''}
4339
leftIcon={progressIcon(page.completed, isActive)}
4440
onClick={
45-
this.canActivate(isActive)
41+
canActivate
4642
? selectPage.bind(this, {
4743
chapter: chapterIndex,
4844
page: pageIndex
4945
})
50-
: null
46+
: function () { return; }
5147
}
5248
/>
5349
);

src/components/progress/_progress.less

+2-6
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,8 @@
1313
padding-left: 15px;
1414
margin-top: 0;
1515
}
16-
.page .page-isDisabled {
17-
color: rgba(0, 0, 0, 0.5);
18-
background: white;
19-
&:hover {
20-
background: white;
21-
}
16+
.page.page-isDisabled {
17+
color: #E0E0E0 !important;
2218
}
2319
}
2420
}

0 commit comments

Comments
 (0)