Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit20fbe11

Browse files
committed
refactor TaskCheckbox using selectors
1 parentf24a0bd commit20fbe11

File tree

5 files changed

+65
-25
lines changed

5 files changed

+65
-25
lines changed

‎lib/components/Page/Task/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,11 @@ var Task = (function (_super) {
4646
Task.prototype.render=function(){
4747
var_a=this.props,testRun=_a.testRun,task=_a.task,index=_a.index,isCurrentTask=_a.isCurrentTask,isCompletedTask=_a.isCompletedTask;
4848
varbackgroundColor=isCompletedTask ?colors_1.lightGreen200 :'inherit';
49-
return(React.createElement(List_1.ListItem,{key:index,style:Object.assign({},styles.task,{backgroundColor:backgroundColor})},taskCheckbox_1.default(isCurrentTask,testRun),React.createElement("span",{style:styles.index},index+1,"."),React.createElement("div",{style:styles.description},React.createElement(index_1.Markdown,null,task.description))));
49+
return(React.createElement(List_1.ListItem,{key:index,style:Object.assign({},styles.task,{backgroundColor:backgroundColor})},React.createElement(taskCheckbox_1.default,{index:index}),React.createElement("span",{style:styles.index},index+1,"."),React.createElement("div",{style:styles.description},React.createElement(index_1.Markdown,null,task.description))));
5050
};
5151
Task=__decorate([
5252
react_redux_1.connect(function(state,props){return({
5353
testRun:state.testRun,
54-
isCurrentTask:state.taskPosition===props.index,
5554
isCompletedTask:state.taskPosition>props.index,
5655
});}),
5756
__metadata('design:paramtypes',[])
Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,48 @@
11
"use strict";
2+
var__extends=(this&&this.__extends)||function(d,b){
3+
for(varpinb)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+
};
7+
var__decorate=(this&&this.__decorate)||function(decorators,target,key,desc){
8+
varc=arguments.length,r=c<3 ?target :desc===null ?desc=Object.getOwnPropertyDescriptor(target,key) :desc,d;
9+
if(typeofReflect==="object"&&typeofReflect.decorate==="function")r=Reflect.decorate(decorators,target,key,desc);
10+
elsefor(vari=decorators.length-1;i>=0;i--)if(d=decorators[i])r=(c<3 ?d(r) :c>3 ?d(target,key,r) :d(target,key))||r;
11+
returnc>3&&r&&Object.defineProperty(target,key,r),r;
12+
};
13+
var__metadata=(this&&this.__metadata)||function(k,v){
14+
if(typeofReflect==="object"&&typeofReflect.metadata==="function")returnReflect.metadata(k,v);
15+
};
216
varReact=require('react');
17+
varreact_redux_1=require('react-redux');
318
varcolors_1=require('material-ui/styles/colors');
419
varindeterminate_check_box_1=require('material-ui/svg-icons/toggle/indeterminate-check-box');
520
varstyles={
6-
position:'absolute',
7-
top:'15px'
21+
checkbox:{
22+
position:'absolute',
23+
top:'15px',
24+
},
825
};
9-
functiontaskCheckbox(isCurrentTask,testRun){
10-
if(!isCurrentTask||!testRun){
11-
returnnull;
26+
varTaskCheckbox=(function(_super){
27+
__extends(TaskCheckbox,_super);
28+
functionTaskCheckbox(){
29+
_super.apply(this,arguments);
1230
}
13-
return(React.createElement("span",{style:styles},React.createElement(indeterminate_check_box_1.default,{color:colors_1.orange500})));
14-
}
31+
TaskCheckbox.prototype.render=function(){
32+
var_a=this.props,testRun=_a.testRun,isCurrentTask=_a.isCurrentTask;
33+
if(!isCurrentTask||!testRun){
34+
returnnull;
35+
}
36+
returnReact.createElement(indeterminate_check_box_1.default,{color:colors_1.orange500,style:styles.checkbox});
37+
};
38+
TaskCheckbox=__decorate([
39+
react_redux_1.connect(function(state,props){return({
40+
testRun:state.testRun,
41+
isCurrentTask:state.taskPosition===props.index,
42+
});}),
43+
__metadata('design:paramtypes',[])
44+
],TaskCheckbox);
45+
returnTaskCheckbox;
46+
}(React.Component));
1547
Object.defineProperty(exports,"__esModule",{value:true});
16-
exports.default=taskCheckbox;
17-
;
48+
exports.default=TaskCheckbox;

‎src/components/Page/Task/index.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import*asReactfrom'react';
22
import{connect}from'react-redux';
33
import{Markdown}from'../../index';
4-
importtaskCheckboxfrom'./taskCheckbox';
4+
importTaskCheckboxfrom'./taskCheckbox';
55
import{ListItem}from'material-ui/List';
66
import{lightGreen200,orange200}from'material-ui/styles/colors';
77

@@ -27,7 +27,6 @@ const styles = {
2727

2828
@connect((state,props)=>({
2929
testRun:state.testRun,
30-
isCurrentTask:state.taskPosition===props.index,
3130
isCompletedTask:state.taskPosition>props.index,
3231
}))
3332
exportdefaultclassTaskextendsReact.Component<{
@@ -42,7 +41,7 @@ export default class Task extends React.Component<{
4241
key={index}
4342
style={Object.assign({},styles.task,{backgroundColor})}
4443
>
45-
{taskCheckbox(isCurrentTask,testRun)}
44+
<TaskCheckboxindex={index}/>
4645
<spanstyle={styles.index}>{index+1}.</span>
4746
<divstyle={styles.description}>
4847
<Markdown>{task.description}</Markdown>
Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,30 @@
11
import*asReactfrom'react';
2+
import{connect}from'react-redux';
23
import{green500,orange500}from'material-ui/styles/colors';
34
importCheckBoxfrom'material-ui/svg-icons/toggle/check-box';
45
importCheckBoxOutlineBlankfrom'material-ui/svg-icons/toggle/check-box-outline-blank';
56
importIndeterminateCheckBoxfrom'material-ui/svg-icons/toggle/indeterminate-check-box';
67

78
conststyles={
8-
position:'absolute',
9-
top:'15px'
9+
checkbox:{
10+
position:'absolute',
11+
top:'15px',
12+
},
1013
};
1114

12-
exportdefaultfunctiontaskCheckbox(isCurrentTask:boolean,testRun:boolean){
13-
if(!isCurrentTask||!testRun){returnnull;}
14-
return(
15-
<spanstyle={styles}>
16-
<IndeterminateCheckBoxcolor={orange500}/>
17-
</span>
18-
);
19-
};
15+
@connect((state,props)=>({
16+
testRun:state.testRun,
17+
isCurrentTask:state.taskPosition===props.index,
18+
}))
19+
exportdefaultclassTaskCheckboxextendsReact.Component<{
20+
testRun?:boolean,isCurrentTask?:boolean,index:number
21+
},{}>{
22+
render(){
23+
const{testRun, isCurrentTask}=this.props;
24+
if(!isCurrentTask||!testRun){returnnull;}
25+
return<IndeterminateCheckBox
26+
color={orange500}
27+
style={styles.checkbox}
28+
/>;
29+
}
30+
}

‎tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
"src/components/Page/PageToolbar/ToggleDevTools/index.tsx",
110110
"src/components/Page/ProgressBar/index.tsx",
111111
"src/components/Page/Task/index.tsx",
112-
"src/components/Page/Task/taskCheckbox.tsx",
112+
"src/components/Page/Task/TaskCheckbox.tsx",
113113
"src/components/Page/Tasks/index.tsx",
114114
"src/components/Page/TasksComplete/index.tsx",
115115
"src/components/Progress/index.tsx",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp