22
33import CloseIcon from "@mui/icons-material/Close" ;
44import FavoriteIcon from "@mui/icons-material/Favorite" ;
5- import { Box , Button } from "@mui/material " ;
5+ import { motion , useAnimation } from "framer-motion " ;
66import { useCallback , useEffect , useState } from "react" ;
77import request from "~/api/request" ;
8-
9- import shadows from "@mui/material/styles/shadows" ;
10- import { motion , useAnimation } from "framer-motion" ;
118import { useMyID , useRecommended } from "~/api/user" ;
129import { Card } from "~/components/Card" ;
1310import { DraggableCard } from "~/components/DraggableCard" ;
@@ -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,36 @@ 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- >
82+ < div className = "flex h-full flex-col items-center justify-center" >
83+ { displayedUser && (
84+ < div className = "flex h-full flex-col items-center justify-center" >
85+ { nextUser && (
86+ < div className = "relative h-full w-full" >
87+ < div className = "-translate-x-1/2 absolute inset-0 z-0 mt-4 transform" >
11288 < Card displayedUser = { nextUser } />
113- </ Box >
114- ) : null }
115- < motion . div animate = { controls } >
116- < DraggableCard
117- displayedUser = { displayedUser }
118- comparisonUserId = { myId ? myId : undefined }
119- onSwipeLeft = { reject }
120- onSwipeRight = { accept }
121- clickedButton = { clickedButton }
122- />
123- </ 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- >
89+ </ div >
90+ < motion . div
91+ animate = { controls }
92+ className = "absolute inset-0 z-10 mt-4 flex items-center justify-center"
93+ >
94+ < DraggableCard
95+ displayedUser = { displayedUser }
96+ comparisonUserId = { myId || undefined }
97+ onSwipeLeft = { reject }
98+ onSwipeRight = { accept }
99+ clickedButton = { clickedButton }
100+ />
101+ </ motion . div >
102+ </ div >
103+ ) }
104+ < div className = "button-container mt-4 mb-4 flex w-full space-x-8" >
135105 < RoundButton onclick = { onClickCross } icon = { < CloseIconStyled /> } />
136106 < RoundButton
137107 onclick = { onClickHeart }
138108 icon = { < FavoriteIconStyled /> }
139109 />
140110 </ div >
141- </ Box >
142- ) : (
143- < FullScreenCircularProgress />
111+ </ div >
144112 ) }
145113 </ div >
146114 </ NavigateByAuthState >
@@ -152,28 +120,18 @@ interface RoundButtonProps {
152120 icon : JSX . Element ;
153121}
154122
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- } ;
172-
173- const CloseIconStyled = ( ) => {
174- return < CloseIcon style = { { color : "grey" , fontSize : "4.5dvh" } } /> ;
175- } ;
176-
177- const FavoriteIconStyled = ( ) => {
178- return < FavoriteIcon style = { { color : "red" , fontSize : "4.5dvh" } } /> ;
179- } ;
123+ const RoundButton = ( { onclick, icon } : RoundButtonProps ) => (
124+ < button
125+ type = "button"
126+ onClick = { onclick }
127+ className = "btn btn-circle bg-white shadow-md"
128+ >
129+ { icon }
130+ </ button >
131+ ) ;
132+
133+ const CloseIconStyled = ( ) => < CloseIcon className = "text-4xl text-gray-500" /> ;
134+
135+ const FavoriteIconStyled = ( ) => (
136+ < FavoriteIcon className = "text-4xl text-red-500" />
137+ ) ;
0 commit comments