22
33import CloseIcon from "@mui/icons-material/Close" ;
44import FavoriteIcon from "@mui/icons-material/Favorite" ;
5- import { Box , Button } from "@mui/material" ;
65import { useCallback , useEffect , useState } from "react" ;
76import request from "~/api/request" ;
8-
9- import shadows from "@mui/material/styles/shadows" ;
107import { motion , useAnimation } from "framer-motion" ;
118import { useMyID , useRecommended } from "~/api/user" ;
129import { Card } from "~/components/Card" ;
@@ -16,7 +13,6 @@ import { NavigateByAuthState } from "~/components/common/NavigateByAuthState";
1613
1714export default function Home ( ) {
1815 const { data : recommended , error } = useRecommended ( ) ;
19-
2016 const [ nth , setNth ] = useState < number > ( 0 ) ;
2117 const displayedUser = recommended ?. [ nth ] ;
2218 const nextUser = recommended ?. [ nth + 1 ] ;
@@ -30,7 +26,7 @@ export default function Home() {
3026 if ( ! displayedUser ) return ;
3127 recommended ?. push ( displayedUser ) ;
3228 setNth ( ( n ) => n + 1 ) ;
33- } , [ displayedUser , recommended ?. push /* ew */ ] ) ;
29+ } , [ displayedUser , recommended ] ) ;
3430
3531 const accept = useCallback ( async ( ) => {
3632 setNth ( ( n ) => n + 1 ) ;
@@ -83,64 +79,33 @@ export default function Home() {
8379
8480 return (
8581 < NavigateByAuthState type = "toLoginForUnauthenticated" >
86- < div
87- style = { {
88- height : "100%" ,
89- display : "flex" ,
90- flexDirection : "column" ,
91- justifyContent : "center" ,
92- } }
93- >
94- { displayedUser ? (
95- < Box
96- display = "flex"
97- flexDirection = "column"
98- justifyContent = "space-evenly"
99- alignItems = "center"
100- height = "100%"
101- >
102- < Box style = { { position : "relative" } } >
103- { nextUser ? (
104- < Box
105- style = { {
106- position : "absolute" ,
107- top : "0" ,
108- left : "0" ,
109- zIndex : - 1 ,
110- } }
111- >
112- < Card displayedUser = { nextUser } />
113- </ Box >
114- ) : null }
115- < motion . div animate = { controls } >
82+ < div className = "h-full flex flex-col justify-center items-center" >
83+ { displayedUser && (
84+ < div className = "h-full flex flex-col justify-center items-center" >
85+ { nextUser && (
86+ < div className = "relative w-full h-full" >
87+ < div className = "absolute inset-0 z-0 mt-4 transform -translate-x-1/2" >
88+ < Card displayedUser = { nextUser } />
89+ </ div >
90+ < motion . div
91+ animate = { controls }
92+ className = "absolute inset-0 z-10 flex justify-center items-center mt-4"
93+ >
11694 < DraggableCard
11795 displayedUser = { displayedUser }
118- comparisonUserId = { myId ? myId : undefined }
96+ comparisonUserId = { myId || undefined }
11997 onSwipeLeft = { reject }
12098 onSwipeRight = { accept }
12199 clickedButton = { clickedButton }
122100 />
123101 </ motion . div >
124- </ Box >
125- < div
126- style = { {
127- display : "flex" ,
128- flexDirection : "row" ,
129- alignItems : "center" ,
130- justifyContent : "space-around" ,
131- width : "min(100%, 46dvh)" ,
132- marginBottom : "10px" ,
133- } }
134- >
102+ </ div >
103+ ) }
104+ < div className = "flex w-full mb-4 mt-4 space-x-8 button-container" >
135105 < RoundButton onclick = { onClickCross } icon = { < CloseIconStyled /> } />
136- < RoundButton
137- onclick = { onClickHeart }
138- icon = { < FavoriteIconStyled /> }
139- />
106+ < RoundButton onclick = { onClickHeart } icon = { < FavoriteIconStyled /> } />
140107 </ div >
141- </ Box >
142- ) : (
143- < FullScreenCircularProgress />
108+ </ div >
144109 ) }
145110 </ div >
146111 </ NavigateByAuthState >
@@ -152,28 +117,16 @@ interface RoundButtonProps {
152117 icon : JSX . Element ;
153118}
154119
155- const RoundButton = ( { onclick, icon } : RoundButtonProps ) => {
156- return (
157- < div >
158- < Button onClick = { onclick } style = { ButtonStyle } >
159- { icon }
160- </ Button >
161- </ div >
162- ) ;
163- } ;
164-
165- const ButtonStyle = {
166- borderRadius : "50%" ,
167- width : "7dvh" ,
168- height : "7dvh" ,
169- boxShadow : shadows [ 10 ] ,
170- backgroundColor : "white" ,
171- } ;
120+ const RoundButton = ( { onclick, icon } : RoundButtonProps ) => (
121+ < button onClick = { onclick } className = "btn btn-circle shadow-md bg-white" >
122+ { icon }
123+ </ button >
124+ ) ;
172125
173- const CloseIconStyled = ( ) => {
174- return < CloseIcon style = { { color : "grey" , fontSize : "4.5dvh" } } /> ;
175- } ;
126+ const CloseIconStyled = ( ) => (
127+ < CloseIcon className = "text-gray-500 text-4xl" />
128+ ) ;
176129
177- const FavoriteIconStyled = ( ) => {
178- return < FavoriteIcon style = { { color : " red" , fontSize : "4.5dvh" } } /> ;
179- } ;
130+ const FavoriteIconStyled = ( ) => (
131+ < FavoriteIcon className = "text- red-500 text-4xl" />
132+ ) ;
0 commit comments