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-15 15:06:02 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8e219dad52b4437266ed5c24a37e11cb50d083bf
8e219dad
1 parent
95988a16
조건부 카드 렌더링 구현
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
18 deletions
client/src/components/BodyLayout.js
client/src/components/TodoCard.js
client/src/components/BodyLayout.js
View file @
8e219da
...
...
@@ -22,6 +22,12 @@ const useStyles = makeStyles((theme) => ({
marginLeft
:
"auto"
,
marginRight
:
"auto"
,
},
date
:
{
width
:
"100%"
,
paddingLeft
:
"1rem"
,
paddingTop
:
"1rem"
,
color
:
"white"
,
},
}));
export
default
function
BodyLayout
()
{
...
...
@@ -40,6 +46,7 @@ export default function BodyLayout() {
callApi
()
.
then
((
res
)
=>
{
setData
(
res
);
console
.
log
(
res
);
setIsLoading
(
0
);
})
.
catch
((
err
)
=>
console
.
log
(
err
));
...
...
@@ -53,28 +60,45 @@ export default function BodyLayout() {
<
Container
className
=
{
classes
.
container
}
maxwidth
=
"md"
>
<
Grid
className
=
{
classes
.
item
}
container
>
{
data
.
map
((
card
,
idx
)
=>
{
if
(
idx
===
0
||
card
.
date
!==
data
[
idx
-
1
].
date
)
{
let
isVisible
=
card
.
isPublic
;
let
showDate
=
null
;
const
isMine
=
card
.
name
===
"aa"
;
////data.name과 session name 비교 로그인 구현하고 수정
if
(
idx
===
0
||
card
.
date
!==
data
[
idx
-
1
].
date
)
{
showDate
=
(
<
Typography
variant
=
"h4"
className
=
{
classes
.
date
}
>
{
card
.
date
}
<
/Typography
>
);
}
if
(
isMine
)
{
isVisible
=
1
;
}
if
(
isVisible
===
1
)
{
return
(
<>
<
Typography
variant
=
"h4"
style
=
{{
width
:
"100%"
,
color
:
"white"
}}
>
{
card
.
date
}
<
/Typography
>
{
showDate
}
<
Grid
item
xs
=
{
6
}
sm
=
{
6
}
md
=
{
3
}
>
<
TodoCard
key
=
{
card
.
id
}
data
=
{
card
}
/
>
<
TodoCard
key
=
{
card
.
id
}
data
=
{
card
}
isVisible
=
{
isVisible
}
isMine
=
{
isMine
}
/
>
<
/Grid
>
<
/
>
);
}
else
{
return
(
<
Grid
item
xs
=
{
6
}
sm
=
{
6
}
md
=
{
3
}
>
<
TodoCard
key
=
{
card
.
id
}
data
=
{
card
}
/
>
<
/Grid
>
);
return
<>
{
showDate
}
<
/>
;
}
})}
{
/* <Grid item xs={6} sm={6} md={3}>
<Icon style={{ fontSize: 60 }}>add_circle</Icon>
</Grid> */
}
<
/Grid
>
<
/Container
>
<
/div
>
...
...
client/src/components/TodoCard.js
View file @
8e219da
...
...
@@ -35,15 +35,22 @@ const useStyles = makeStyles({
},
});
export
default
function
TodoCard
(
props
)
{
export
default
function
TodoCard
(
{
data
,
isMine
,
isVisible
}
)
{
const
classes
=
useStyles
();
const
data
=
props
.
data
;
const
todo
=
data
.
todo
.
split
(
","
);
const
isTrue
=
"1"
;
const
check
=
data
.
ck
.
split
(
","
).
map
((
ck
)
=>
{
return
isTrue
===
ck
;
return
parseInt
(
ck
)
;
});
let
settingButton
=
null
;
if
(
isMine
)
{
settingButton
=
(
<
Icon
className
=
{
classes
.
icon
}
color
=
"primary"
>
settings
<
/Icon
>
);
}
return
(
<
Card
className
=
{
classes
.
root
}
>
<
CardContent
>
...
...
@@ -51,18 +58,14 @@ export default function TodoCard(props) {
{
data
.
date
}
&
middot
;
{
data
.
name
}
<
/Typography
>
<
Icon
className
=
{
classes
.
icon
}
color
=
"primary"
>
settings
<
/Icon
>
{
settingButton
}
<
Typography
className
=
{
classes
.
title
}
variant
=
"h6"
>
{
data
.
title
}
<
/Typography
>
{
/* <Typography className={classes.percent} variant="h6">
99%
</Typography> */
}
{
todo
.
map
((
item
,
idx
)
=>
{
return
(
<
FormControlLabel
...
...
Please
register
or
login
to post a comment