11import ThreeSixtyIcon from "@mui/icons-material/ThreeSixty" ;
22import { Chip } from "@mui/material" ;
3- import { useEffect , useState } from "react" ;
3+ import { useState } from "react" ;
44import type { User , UserID } from "~/common/types" ;
55import NonEditableCoursesTable from "./course/NonEditableCoursesTable" ;
66import UserAvatar from "./human/avatar" ;
@@ -19,61 +19,33 @@ export function Card({ displayedUser, comparisonUserId, onFlip }: CardProps) {
1919 if ( onFlip ) onFlip ( ! isDisplayingBack ) ;
2020 } ;
2121
22- // biome-ignore lint: FIXME! 本来はuseEffectではなくスワイプのイベントで実装するべき
23- useEffect ( ( ) => {
24- const card = document . getElementById ( "card" ) ;
25-
26- if ( card ) {
27- card . style . transition = "none" ;
28- setIsDisplayingBack ( false ) ;
29-
30- requestAnimationFrame ( ( ) => {
31- if ( card ) {
32- card . style . transition = "transform 600ms" ;
33- }
34- } ) ;
35- }
36- } , [ displayedUser ] ) ;
37-
3822 return (
39- // biome-ignore lint: this cannot just be fixed rn FIXME!
4023 < div
41- style = { {
42- perspective : "1000px" ,
43- width : "min(40dvh, 87.5vw)" ,
44- height : "70dvh" ,
45- position : "relative" ,
46- } }
24+ className = "perspective-[1000px] relative cursor-pointer"
25+ style = { { width : "min(40dvh, 87.5vw)" , height : "70dvh" } }
4726 onClick = { handleRotate }
27+ onKeyDown = { ( event ) => {
28+ if ( event . key === "Enter" || event . key === " " ) handleRotate ( ) ;
29+ } }
4830 >
4931 < div
5032 id = "card"
51- style = { {
52- position : "absolute" ,
53- width : "100%" ,
54- height : "100%" ,
55- transformStyle : "preserve-3d" ,
56- transition : "transform 600ms" ,
57- transform : isDisplayingBack ? "rotateY(180deg)" : "rotateY(0deg)" ,
58- } }
33+ className = "transform-style-preserve-3d absolute h-full w-full transition-transform duration-600"
5934 >
6035 < div
36+ className = "absolute h-full w-full"
6137 style = { {
62- position : "absolute" ,
63- width : "100%" ,
64- height : "100%" ,
6538 backfaceVisibility : "hidden" ,
39+ transform : isDisplayingBack ? "rotateY(180deg)" : "rotateY(0deg)" ,
6640 } }
6741 >
6842 < CardFront displayedUser = { displayedUser } />
6943 </ div >
7044 < div
45+ className = "absolute h-full w-full"
7146 style = { {
72- position : "absolute" ,
73- width : "100%" ,
74- height : "100%" ,
7547 backfaceVisibility : "hidden" ,
76- transform : "rotateY(180deg)" ,
48+ transform : isDisplayingBack ? "rotateY(0deg)" : "rotateY(- 180deg)",
7749 } }
7850 >
7951 < CardBack
@@ -88,194 +60,62 @@ export function Card({ displayedUser, comparisonUserId, onFlip }: CardProps) {
8860
8961const CardFront = ( { displayedUser } : CardProps ) => {
9062 return (
91- < div
92- style = { {
93- display : "flex" ,
94- flexDirection : "column" ,
95- backgroundColor : "#F7FCFF" ,
96- border : "2px solid #3596C6" ,
97- padding : "20px 20px 10px 20px" ,
98- height : "100%" ,
99- gap : "2dvh" ,
100- overflow : "hidden" ,
101- justifyContent : "space-between" ,
102- } }
103- >
104- < div
105- style = { {
106- display : "grid" ,
107- gridTemplateColumns : "1fr 1fr 1fr" ,
108- alignItems : "center" ,
109- height : "30%" ,
110- } }
111- >
63+ < div className = "flex h-full flex-col justify-between gap-5 overflow-hidden border-2 border-primary bg-secondary p-5" >
64+ < div className = "grid h-[30%] grid-cols-3 items-center" >
11265 < UserAvatar
11366 pictureUrl = { displayedUser . pictureUrl }
11467 width = "10dvh"
11568 height = "10dvh"
11669 />
117- < div
118- style = { {
119- display : "flex" ,
120- gridColumn : "2 / 4" ,
121- marginLeft : "1dvh" ,
122- justifyContent : "center" ,
123- } }
124- >
125- < span
126- style = { {
127- fontSize : "3.4vh" ,
128- fontWeight : "bold" ,
129- margin : "0 auto" ,
130- } }
131- >
132- { displayedUser . name }
133- </ span >
70+ < div className = "col-span-2 ml-2 flex justify-center" >
71+ < span className = "font-bold text-4xl" > { displayedUser . name } </ span >
13472 </ div >
13573 </ div >
136- < div
137- style = { {
138- display : "grid" ,
139- gridTemplateColumns : "1fr 5fr" ,
140- alignItems : "center" ,
141- gap : "1.5dvh" ,
142- } }
143- >
144- < Chip
145- label = "学部"
146- size = "small"
147- sx = { {
148- gridColumn : "1 / 2" ,
149- } }
150- />
151- < p
152- style = { {
153- margin : 0 ,
154- fontSize : "3dvh" ,
155- } }
156- >
157- { displayedUser . faculty }
158- </ p >
74+ < div className = "grid grid-cols-6 items-center gap-4" >
75+ < Chip label = "学部" size = "small" className = "col-span-1" />
76+ < p className = "col-span-5 text-xl" > { displayedUser . faculty } </ p >
15977 </ div >
160- < div
161- style = { {
162- display : "grid" ,
163- gridTemplateColumns : "1fr 5fr" ,
164- alignItems : "center" ,
165- gap : "1.5dvh" ,
166- } }
167- >
168- < Chip label = "学科" size = "small" />
78+ < div className = "grid grid-cols-6 items-center gap-4" >
79+ < Chip label = "学科" size = "small" className = "col-span-1" />
16980 < p
170- style = {
171- displayedUser . department . length <= 7
172- ? {
173- margin : 0 ,
174- fontSize : "3dvh" ,
175- overflow : "hidden" ,
176- whiteSpace : "nowrap" ,
177- textOverflow : "ellipsis" ,
178- }
179- : {
180- margin : 0 ,
181- fontSize : "1.76dvh" ,
182- overflow : "hidden" ,
183- whiteSpace : "nowrap" ,
184- textOverflow : "ellipsis" ,
185- }
186- }
81+ className = { `col-span-5 text-xl ${ displayedUser . department . length > 7 ? "text-xs" : "text-2xl" } ` }
18782 >
18883 { displayedUser . department }
18984 </ p >
19085 </ div >
191- < div
192- style = { {
193- display : "grid" ,
194- gridTemplateColumns : "1fr 5fr" ,
195- alignItems : "center" ,
196- gap : "1.5dvh" ,
197- } }
198- >
199- < Chip label = "性別" size = "small" />
200- < p style = { { margin : 0 , fontSize : "3dvh" } } > { displayedUser . gender } </ p >
86+ < div className = "grid grid-cols-6 items-center gap-4" >
87+ < Chip label = "性別" size = "small" className = "col-span-1" />
88+ < p className = "col-span-5 text-xl" > { displayedUser . gender } </ p >
20189 </ div >
202- < div
203- style = { {
204- display : "grid" ,
205- gridTemplateColumns : "1fr 5fr" ,
206- alignItems : "center" ,
207- gap : "1.5dvh" ,
208- } }
209- >
210- < Chip label = "学年" size = "small" />
211- < p style = { { margin : 0 , fontSize : "3dvh" } } > { displayedUser . grade } </ p >
90+ < div className = "grid grid-cols-6 items-center gap-4" >
91+ < Chip label = "学年" size = "small" className = "col-span-1" />
92+ < p className = "col-span-5 text-xl" > { displayedUser . grade } </ p >
21293 </ div >
213- < div
214- style = { {
215- flex : 1 ,
216- display : "grid" ,
217- gridTemplateColumns : "1fr 5fr" ,
218- gap : "1.5dvh" ,
219- maxHeight : "32%" , // WebKitLineClamp の フォールバックとして
220- } }
221- >
222- < Chip
223- label = "自己紹介"
224- size = "small"
225- sx = { {
226- fontSize : "0.45rem" ,
227- } }
228- />
229- < p
230- style = { {
231- margin : 0 ,
232- fontSize : "1.76dvh" ,
233- overflow : "hidden" ,
234- display : "-webkit-box" ,
235- WebkitBoxOrient : "vertical" ,
236- WebkitLineClamp : 8 ,
237- lineClamp : 8 ,
238- textOverflow : "ellipsis" ,
239- } }
240- >
94+ < div className = "grid max-h-[32%] flex-1 grid-cols-6 gap-4" >
95+ < Chip label = "自己紹介" size = "small" className = "col-span-1 text-sm" />
96+ < p className = "col-span-5 line-clamp-8 overflow-hidden text-sm" >
24197 { displayedUser . intro }
24298 </ p >
24399 </ div >
244- < div >
245- < ThreeSixtyIcon
246- style = { { fontSize : "3.08dvh" , display : "block" , margin : "auto" } }
247- />
100+ < div className = "flex justify-center" >
101+ < ThreeSixtyIcon className = "text-3xl" />
248102 </ div >
249103 </ div >
250104 ) ;
251105} ;
252106
253107const CardBack = ( { displayedUser, comparisonUserId } : CardProps ) => {
254108 return (
255- < div
256- style = { {
257- display : "flex" ,
258- flexDirection : "column" ,
259- backgroundColor : "#F7FCFF" ,
260- border : "2px solid #3596C6" ,
261- padding : "10px" ,
262- height : "100%" ,
263- overflow : "hidden" ,
264- } }
265- >
266- < div style = { { display : "flex" , justifyContent : "center" } } >
267- < p style = { { fontSize : "1rem" , fontWeight : "bold" } } >
268- { displayedUser ?. name }
269- </ p >
109+ < div className = "flex h-full flex-col overflow-hidden border-2 border-primary bg-secondary p-4" >
110+ < div className = "flex justify-center" >
111+ < p className = "font-bold text-lg" > { displayedUser ?. name } </ p >
270112 </ div >
271113 < NonEditableCoursesTable
272114 userId = { displayedUser . id }
273115 comparisonUserId = { comparisonUserId }
274116 />
275- < div >
276- < ThreeSixtyIcon
277- style = { { fontSize : "3.08dvh" , display : "block" , margin : "auto" } }
278- />
117+ < div className = "mt-4 flex justify-center" >
118+ < ThreeSixtyIcon className = "text-3xl" />
279119 </ div >
280120 </ div >
281121 ) ;
0 commit comments