@@ -87,22 +87,43 @@ export default function CoursesTableCore(props: Props) {
8787 } , [ props . courses , props . comparisonCourses , transformCoursesToRows ] ) ;
8888
8989 return (
90- < table className = { styles . table } >
91- < thead >
92- < tr >
93- < th />
94- { ACTIVE_DAYS . map ( ( activeDay ) => (
95- < th align = "center" key = { `header-${ activeDay } ` } >
96- { DAY_TO_JAPANESE_MAP . get ( activeDay as Day ) }
97- </ th >
90+ < div className = "flex h-full flex-col" >
91+ < div
92+ className = "grid h-[3vh] grid-rows-1 gap-1"
93+ style = { {
94+ gridTemplateColumns : `3vh repeat(${ ACTIVE_DAYS . length } , minmax(0, 1fr))` ,
95+ } }
96+ >
97+ < span className = "rounded-sm bg-gray-100" />
98+ { ACTIVE_DAYS . map ( ( activeDay ) => (
99+ < span
100+ key = { `header-${ activeDay } ` }
101+ className = "inline-flex items-center justify-center rounded-sm bg-gray-100 text-center text-xs"
102+ >
103+ { DAY_TO_JAPANESE_MAP . get ( activeDay as Day ) }
104+ </ span >
105+ ) ) }
106+ </ div >
107+ < div className = "mt-1 flex flex-1 gap-1" >
108+ < div className = "flex h-full w-[3vh] flex-col gap-1" >
109+ { Array . from ( { length : 6 } , ( _ , i ) => (
110+ < span
111+ key = { `period-${ i + 1 } ` }
112+ className = "inline-flex flex-1 items-center justify-center rounded-sm bg-gray-100 text-xs"
113+ >
114+ { i + 1 }
115+ </ span >
98116 ) ) }
99- </ tr >
100- </ thead >
101- < tbody >
102- { rows . map ( ( row , rowIndex ) => (
103- < tr key = { `period-${ rowIndex + 1 } ` } >
104- < th key = { `header-period-${ rowIndex + 1 } ` } > { rowIndex + 1 } </ th >
105- { ACTIVE_DAYS . map ( ( day ) => (
117+ </ div >
118+ < div
119+ className = "grid flex-1 grid-rows-6 gap-1"
120+ style = { {
121+ gridTemplateColumns : `repeat(${ ACTIVE_DAYS . length } , minmax(0, 1fr))` ,
122+ } }
123+ >
124+ { /* TODO: grid-auto-flow: column; で縦方向に流すほうが余計な変形ロジックが減りそう */ }
125+ { rows . map ( ( row , rowIndex ) =>
126+ ACTIVE_DAYS . map ( ( day ) => (
106127 < Cell
107128 key = { `cell-${ day } -${ rowIndex . toString ( ) } ` }
108129 courseName = { row [ day ] ?. name ?? null }
@@ -115,11 +136,44 @@ export default function CoursesTableCore(props: Props) {
115136 : undefined
116137 }
117138 />
139+ ) ) ,
140+ ) }
141+ </ div >
142+ </ div >
143+ { /* <table className={styles.table}>
144+ <thead>
145+ <tr>
146+ <th />
147+ {ACTIVE_DAYS.map((activeDay) => (
148+ <th align="center" key={`header-${activeDay}`}>
149+ {DAY_TO_JAPANESE_MAP.get(activeDay as Day)}
150+ </th>
118151 ))}
119152 </tr>
120- ) ) }
121- </ tbody >
122- </ table >
153+ </thead>
154+ <tbody>
155+ {rows.map((row, rowIndex) => (
156+ <tr key={`period-${rowIndex + 1}`}>
157+ <th key={`header-period-${rowIndex + 1}`}>{rowIndex + 1}</th>
158+ {ACTIVE_DAYS.map((day) => (
159+ <Cell
160+ key={`cell-${day}-${rowIndex.toString()}`}
161+ courseName={row[day]?.name ?? null}
162+ teacherName={row[day]?.teacher ?? null}
163+ isOverlapping={row[day]?.isOverlapping}
164+ isButton={props.isButton}
165+ onClick={
166+ props.isButton
167+ ? () => props.onCellClick(rowIndex, day, row[day] ?? null)
168+ : undefined
169+ }
170+ />
171+ ))}
172+ </tr>
173+ ))}
174+ </tbody>
175+ </table> */ }
176+ </ div >
123177 ) ;
124178}
125179
@@ -138,7 +192,7 @@ function Cell({
138192} ) {
139193 const content = (
140194 < >
141- < p
195+ < span
142196 style = { {
143197 margin : 0 ,
144198 overflow : "hidden" ,
@@ -150,8 +204,8 @@ function Cell({
150204 } }
151205 >
152206 { courseName ? truncateStr ( courseName ?? "" , 16 ) : "" }
153- </ p >
154- < p
207+ </ span >
208+ < span
155209 style = { {
156210 margin : 0 ,
157211 overflow : "hidden" ,
@@ -163,12 +217,20 @@ function Cell({
163217 } }
164218 >
165219 { teacherName ? truncateStr ( teacherName ?? "" , 6 ) : "" }
166- </ p >
220+ </ span >
167221 </ >
168222 ) ;
169223
170224 return (
171- < td align = "center" >
225+ < span
226+ className = { `inline-flex flex-1 items-center justify-center rounded-sm text-xs ${
227+ ! courseName
228+ ? "bg-transparent"
229+ : isOverlapping
230+ ? "bg-[#FFF1BF]"
231+ : "bg-[#F7FCFF]"
232+ } `}
233+ >
172234 { isButton ? (
173235 < button
174236 type = "button"
@@ -184,7 +246,7 @@ function Cell({
184246 { content }
185247 </ button >
186248 ) : (
187- < div
249+ < span
188250 className = {
189251 isOverlapping
190252 ? styles . overlapped
@@ -194,8 +256,8 @@ function Cell({
194256 }
195257 >
196258 { content }
197- </ div >
259+ </ span >
198260 ) }
199- </ td >
261+ </ span >
200262 ) ;
201263}
0 commit comments