Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김대휘
/
Do-gether
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
김대휘
2020-06-21 14:03:06 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
009c3e5869feab9c47151d9cfff8513bc32349c2
009c3e58
1 parent
2b921e18
CheckBox re-rendering
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
29 deletions
client/src/components/AddButton.js
client/src/components/TodoCard.js
client/src/components/AddButton.js
View file @
009c3e5
...
...
@@ -7,7 +7,7 @@ import Icon from "@material-ui/core/Icon";
import
IconButton
from
"@material-ui/core/IconButton"
;
import
TextField
from
"@material-ui/core/TextField"
;
import
Button
from
"@material-ui/core/Button"
;
import
Typography
from
'@material-ui/core/Typography'
;
import
Typography
from
"@material-ui/core/Typography"
;
const
useStyles
=
makeStyles
((
theme
)
=>
({
iconButton
:
{
...
...
@@ -19,7 +19,7 @@ const useStyles = makeStyles((theme) => ({
},
icon
:
{
fontSize
:
70
,
color
:
"black"
color
:
"black"
,
},
paper
:
{
...
...
@@ -35,12 +35,12 @@ const useStyles = makeStyles((theme) => ({
width
:
"30ch"
,
},
},
button
:{
'& > *'
:
{
button
:
{
"& > *"
:
{
margin
:
theme
.
spacing
(
1
),
float
:
"right"
float
:
"right"
,
},
},
}
}));
function
getModalStyle
()
{
...
...
@@ -64,7 +64,16 @@ export default function AddButton() {
setOpen
(
false
);
};
const
body
=
(
return
(
<>
<
IconButton
className
=
{
classes
.
iconButton
}
onClick
=
{
handleOpen
}
>
<
Icon
className
=
{
classes
.
icon
}
>
add_circle
<
/Icon
>
<
/IconButton
>
<
Modal
open
=
{
open
}
aria
-
labelledby
=
"simple-modal-title"
aria
-
describedby
=
"simple-modal-description"
>
<
div
style
=
{
modalStyle
}
className
=
{
classes
.
paper
}
>
<
Typography
variant
=
"h5"
>
ADD
TODO
LIST
<
/Typography
>
...
...
@@ -83,19 +92,6 @@ export default function AddButton() {
<
/Button
>
<
/form
>
<
/div
>
);
return
(
<>
<
IconButton
className
=
{
classes
.
iconButton
}
onClick
=
{
handleOpen
}
>
<
Icon
className
=
{
classes
.
icon
}
>
add_circle
<
/Icon
>
<
/IconButton
>
<
Modal
open
=
{
open
}
aria
-
labelledby
=
"simple-modal-title"
aria
-
describedby
=
"simple-modal-description"
>
{
body
}
<
/Modal
>
<
/
>
);
...
...
client/src/components/TodoCard.js
View file @
009c3e5
import
React
from
"react"
;
import
React
,
{
useState
}
from
"react"
;
import
{
makeStyles
}
from
"@material-ui/core/styles"
;
import
Card
from
"@material-ui/core/Card"
;
import
CardContent
from
"@material-ui/core/CardContent"
;
...
...
@@ -30,15 +30,24 @@ const useStyles = makeStyles({
},
});
export
default
function
TodoCard
({
data
,
isMine
,
isVisible
})
{
const
classes
=
useStyles
();
const
[
render
,
setRender
]
=
useState
(
0
);
const
todo
=
data
.
todo
.
split
(
","
);
const
check
=
data
.
ck
.
split
(
","
).
map
((
ck
)
=>
{
const
[
checkState
,
setCheckState
]
=
useState
(
data
.
ck
.
split
(
","
).
map
((
ck
)
=>
{
return
parseInt
(
ck
);
});
}))
let
settingButton
=
null
;
const
handleCheck
=
(
idx
)
=>
{
let
tempArr
=
checkState
;
tempArr
[
idx
]
=
tempArr
[
idx
]?
0
:
1
;
setCheckState
(
tempArr
);
setRender
([]);
};
if
(
isMine
)
{
settingButton
=
(
<
SettingButton
><
/SettingButton
>
...
...
@@ -56,15 +65,16 @@ export default function TodoCard({ data, isMine, isVisible }) {
<
Typography
className
=
{
classes
.
title
}
variant
=
"h6"
>
{
data
.
title
}
<
/Typography
>
{
/* <Typography className={classes.percent} variant="h6">
99%
</Typography> */
}
<
Typography
className
=
{
classes
.
percent
}
variant
=
"h6"
>
{
checkState
.
reduce
((
a
,
b
)
=>
a
+
b
)}
/{checkState.length
}
<
/Typography
>
{
todo
.
map
((
item
,
idx
)
=>
{
return
(
<
FormControlLabel
className
=
{
classes
.
checkBox
}
control
=
{
<
Checkbox
/>
}
checked
=
{
check
[
idx
]}
control
=
{
<
Checkbox
onClick
=
{
e
=>
(
handleCheck
(
idx
))}
/>
}
checked
=
{
check
State
[
idx
]}
label
=
{
item
}
/
>
);
...
...
Please
register
or
login
to post a comment