|
| 1 | +import styled from "styled-components"; |
| 2 | +import { COLOR } from "../../styles/color"; |
| 3 | +import { useNavigate } from "react-router-dom"; |
| 4 | +import { Box, CircularProgress, SvgIcon, Typography } from "@mui/material"; |
| 5 | +import CheckRoundedIcon from "@mui/icons-material/CheckRounded"; |
| 6 | +import { ReactComponent as Arrow } from "../../assets/icons/arrowLongRight.svg"; |
| 7 | +import propTypes from "prop-types"; |
| 8 | + |
| 9 | +const ReviewTemplateItem = (props) => { |
| 10 | + const data = props.data; |
| 11 | + const navigate = new useNavigate(); |
| 12 | + |
| 13 | + const ItemIcon = { |
| 14 | + default: ( |
| 15 | + <> |
| 16 | + <TemplateIconWrapper /> |
| 17 | + <ItemProgress progresscolor={COLOR.MAIN_SKYBLUE} /> |
| 18 | + </> |
| 19 | + ), |
| 20 | + true: ( |
| 21 | + <> |
| 22 | + <TemplateIconWrapper |
| 23 | + component={CheckRoundedIcon} |
| 24 | + iconcolor={COLOR.MAIN_NAVY} |
| 25 | + /> |
| 26 | + <ItemProgress |
| 27 | + variant="determinate" |
| 28 | + value={100} |
| 29 | + progresscolor={COLOR.MAIN_SKYBLUE} |
| 30 | + /> |
| 31 | + </> |
| 32 | + ), |
| 33 | + false: ( |
| 34 | + <> |
| 35 | + <TemplateIconWrapper |
| 36 | + component={data.icon} |
| 37 | + iconcolor={COLOR.MAIN_NAVY} |
| 38 | + /> |
| 39 | + <ItemProgress |
| 40 | + variant="determinate" |
| 41 | + value={100} |
| 42 | + progresscolor={COLOR.MAIN_ROSE} |
| 43 | + /> |
| 44 | + </> |
| 45 | + ), |
| 46 | + }; |
| 47 | + |
| 48 | + return ( |
| 49 | + <StTemplateItemBox |
| 50 | + onClick={() => { |
| 51 | + navigate(data.path); |
| 52 | + }} |
| 53 | + > |
| 54 | + <TemplateItemIconBox> |
| 55 | + {props.isLoadingTemplate |
| 56 | + ? ItemIcon["default"] |
| 57 | + : ItemIcon[props.reviewData[data.item]]} |
| 58 | + </TemplateItemIconBox> |
| 59 | + <TextContainer> |
| 60 | + <TemplateItemTitle variant="h4">{data.title}</TemplateItemTitle> |
| 61 | + <TemplateDecsText variant="subtitle1">{data.desc}</TemplateDecsText> |
| 62 | + </TextContainer> |
| 63 | + <ArrowIcon component={Arrow} inheritViewBox /> |
| 64 | + </StTemplateItemBox> |
| 65 | + ); |
| 66 | +}; |
| 67 | + |
| 68 | +ReviewTemplateItem.propTypes = { |
| 69 | + data: propTypes.object, |
| 70 | + isLoadingTemplate: propTypes.bool, |
| 71 | + reviewData: propTypes.object, |
| 72 | +}; |
| 73 | + |
| 74 | +export const ReviewTemplateList = (props) => { |
| 75 | + return ( |
| 76 | + <StReviewList> |
| 77 | + {props.data.map((it) => { |
| 78 | + return ( |
| 79 | + <ReviewTemplateItem |
| 80 | + key={it.item} |
| 81 | + data={it} |
| 82 | + isLoadingTemplate={props.isLoadingTemplate} |
| 83 | + reviewData={props.reviewData} |
| 84 | + /> |
| 85 | + ); |
| 86 | + })} |
| 87 | + </StReviewList> |
| 88 | + ); |
| 89 | +}; |
| 90 | + |
| 91 | +ReviewTemplateList.propTypes = { |
| 92 | + data: propTypes.array, |
| 93 | + isLoadingTemplate: propTypes.bool, |
| 94 | + reviewData: propTypes.object, |
| 95 | +}; |
| 96 | + |
| 97 | +const StReviewList = styled.div` |
| 98 | + display: flex; |
| 99 | + justify-content: space-between; |
| 100 | + flex-direction: row; |
| 101 | +`; |
| 102 | + |
| 103 | +//default |
| 104 | +const StItemBox = styled.div` |
| 105 | + display: flex; |
| 106 | + justify-content: space-evenly; |
| 107 | + flex-direction: column; |
| 108 | + width: 23rem; |
| 109 | + height: 22rem; |
| 110 | + padding: 1.5rem; |
| 111 | + /* gap: 1rem; */ |
| 112 | + /* border: 0.1rem solid lightgrey; */ |
| 113 | + border-radius: 2rem; |
| 114 | + background-color: ${COLOR.MAIN_WHITE}; |
| 115 | + box-shadow: 0rem 0.1rem 2rem lightgrey; |
| 116 | +`; |
| 117 | + |
| 118 | +const ItemIconBox = styled(Box)` |
| 119 | + display: flex; |
| 120 | + align-items: center; |
| 121 | + justify-content: center; |
| 122 | + position: relative; |
| 123 | + top: 0; |
| 124 | + width: 5rem; |
| 125 | + height: 5rem; |
| 126 | + margin: 0.1rem; |
| 127 | +`; |
| 128 | + |
| 129 | +const IconWrapper = styled(SvgIcon)` |
| 130 | + position: absolute; |
| 131 | + color: ${(props) => props.iconcolor}; |
| 132 | + font-size: 2.7rem; |
| 133 | +`; |
| 134 | + |
| 135 | +const TextContainer = styled.div` |
| 136 | + display: flex; |
| 137 | + flex-direction: column; |
| 138 | + gap: 0.5rem; |
| 139 | +`; |
| 140 | + |
| 141 | +const ItemTitle = styled(Typography)` |
| 142 | + font-weight: bolder; |
| 143 | + text-align: left; |
| 144 | +`; |
| 145 | +const DecsText = styled(Typography)` |
| 146 | + color: ${COLOR.FONT_GRAY}; |
| 147 | + font-size: 1.2rem; |
| 148 | + text-align: justify; |
| 149 | +`; |
| 150 | + |
| 151 | +// for template |
| 152 | +const StTemplateItemBox = styled(StItemBox)` |
| 153 | + &:hover { |
| 154 | + padding: 2rem 1.5rem; |
| 155 | + background-color: ${COLOR.MAIN_PURPLE}; |
| 156 | + transition: all 0.3s ease-in; |
| 157 | + } |
| 158 | +`; |
| 159 | + |
| 160 | +const TemplateItemIconBox = styled(ItemIconBox)` |
| 161 | + transition: all 1s ease-in-out; |
| 162 | + ${StTemplateItemBox}:hover & { |
| 163 | + display: none; |
| 164 | + transition: all 0.5s ease-in-out; |
| 165 | + } |
| 166 | +`; |
| 167 | + |
| 168 | +const TemplateIconWrapper = styled(IconWrapper)``; |
| 169 | + |
| 170 | +const TemplateItemTitle = styled(ItemTitle)` |
| 171 | + ${StTemplateItemBox}:hover & { |
| 172 | + color: ${COLOR.MAIN_WHITE}; |
| 173 | + transition: all 0.2s ease-in-out; |
| 174 | + } |
| 175 | +`; |
| 176 | +const TemplateDecsText = styled(DecsText)` |
| 177 | + ${StTemplateItemBox}:hover & { |
| 178 | + color: ${COLOR.MAIN_WHITE}; |
| 179 | + transition: all 0.2s ease-in-out; |
| 180 | + } |
| 181 | +`; |
| 182 | + |
| 183 | +const ArrowIcon = styled(SvgIcon)` |
| 184 | + display: none; |
| 185 | + color: ${COLOR.MAIN_WHITE}; |
| 186 | + font-size: 5rem; |
| 187 | + ${StTemplateItemBox}:hover & { |
| 188 | + display: block; |
| 189 | + color: ${COLOR.MAIN_WHITE}; |
| 190 | + transition: all 0.2s ease-in-out; |
| 191 | + } |
| 192 | +`; |
| 193 | + |
| 194 | +const ItemProgress = styled(CircularProgress)` |
| 195 | + display: flex; |
| 196 | + justify-content: center; |
| 197 | + align-items: center; |
| 198 | + color: ${(props) => props.progresscolor}; |
| 199 | +
|
| 200 | + .MuiCircularProgress-svg { |
| 201 | + width: 5rem; |
| 202 | + height: 5rem; |
| 203 | + } |
| 204 | +`; |
0 commit comments