@@ -5,18 +5,26 @@ import { calculate } from "./calculate";
55
66export const ResultCard = ( { condition } : { condition : Condition } ) => {
77 const [ results , setResults ] = useState <
8- { x_list : number [ ] ; y_list : number [ ] ; condition : Condition } [ ]
8+ {
9+ x_list : number [ ] ;
10+ y_list : number [ ] ;
11+ condition : Condition ;
12+ finalVelocity : number ;
13+ flightTime : number ;
14+ } [ ]
915 > ( [ ] ) ;
1016 useEffect ( ( ) => {
1117 if ( ! condition ) return ;
1218 setResults ( ( prev ) => {
1319 const exists = prev . some ( ( r ) => isSameCondition ( r . condition , condition ) ) ;
1420 if ( exists ) return prev ;
1521 const res = calculate ( condition ) ;
22+ const finalVelocity = res . finalVelocity ;
23+ const flightTime = res . flightTime ;
1624 let len = res . x_list . length ;
1725 res . x_list = res . x_list . filter ( ( _ , i ) => i % Math . ceil ( len / 500 ) === 0 ) ;
1826 res . y_list = res . y_list . filter ( ( _ , i ) => i % Math . ceil ( len / 500 ) === 0 ) ;
19- return [ ...prev , { ...res , condition } ] ;
27+ return [ ...prev , { ...res , condition, finalVelocity , flightTime } ] ;
2028 } ) ;
2129 } , [ condition ] ) ;
2230 return (
@@ -30,12 +38,12 @@ export const ResultCard = ({ condition }: { condition: Condition }) => {
3038 return (
3139 < li
3240 key = { idx }
33- className = "rounded-full px-3 py-1 text-white flex items-center justify-center gap-2 hover:shadow-lg hover:opacity-80 transition-all duration-200 ease-in-out"
41+ className = "relative group rounded-full px-3 py-1 text-white flex items-center justify-center gap-2 hover:shadow-lg hover:opacity-80 transition-all duration-200 ease-in-out"
3442 style = { { backgroundColor : color } }
3543 >
3644 < div > { idx } </ div >
3745 < div
38- className = "bg-white w-3 h-3 rounded-full flex items-center justify-center font-bold"
46+ className = "bg-white w-3 h-3 rounded-full flex items-center justify-center font-bold cursor-pointer "
3947 style = { { color : color } }
4048 onClick = { ( ) => {
4149 const newResults = results . filter ( ( _ , i ) => i !== idx ) ;
@@ -44,6 +52,21 @@ export const ResultCard = ({ condition }: { condition: Condition }) => {
4452 >
4553 ×
4654 </ div >
55+
56+ { /* Tooltip: shows condition on parent hover */ }
57+ < div className = "absolute top-full left-[200%] mb-2 transform -translate-x-1/2 w-56 p-2 rounded shadow bg-white text-neutral-800 text-xs opacity-0 scale-95 pointer-events-none group-hover:opacity-100 group-hover:scale-100 transition-all duration-200 z-10" >
58+ < div className = "font-semibold" > Condition</ div >
59+ < div > 初速: { res . condition . initV } m/s</ div >
60+ < div > 角度: { res . condition . angle } °</ div >
61+ < div > 発射高さ: { res . condition . yoffset } m</ div >
62+ < div > 飛翔体半径: { res . condition . radius } m</ div >
63+ < div > 質量: { res . condition . mass . toFixed ( 4 ) } kg</ div >
64+ < div > Δt: { res . condition . deltaT } </ div >
65+ < div > 飛距離: { Math . max ( ...res . x_list ) . toFixed ( 4 ) } m</ div >
66+ < div > 最高高度: { Math . max ( ...res . y_list ) . toFixed ( 4 ) } m</ div >
67+ < div > 到達時間: { res . flightTime . toFixed ( 4 ) } s</ div >
68+ < div > 着弾速度: { res . finalVelocity . toFixed ( 2 ) } m/s</ div >
69+ </ div >
4770 </ li >
4871 ) ;
4972 } ) }
0 commit comments