Skip to content

Commit d68ea9a

Browse files
feat: minor table fixes
1 parent f561272 commit d68ea9a

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/block.tsx

+14-6
Original file line numberDiff line numberDiff line change
@@ -269,45 +269,52 @@ export const Block: React.FC<Block> = props => {
269269
);
270270
case "collection_view":
271271
if (!block) return null;
272+
272273
const collectionView = block?.collection?.types[0];
273274

274275
return (
275276
<div>
276277
<h3 className="notion-h3">
277278
{renderChildText(block.collection?.title!)}
278279
</h3>
280+
279281
{collectionView?.type === "table" && (
280282
<div style={{ maxWidth: "100%", marginTop: 5 }}>
281283
<table className="notion-table">
282284
<thead>
283285
<tr className="notion-tr">
284286
{collectionView.format?.table_properties
285287
?.filter(p => p.visible)
286-
.map(gp => (
288+
.map((gp, index) => (
287289
<th
288290
className="notion-th"
291+
key={index}
289292
style={{ minWidth: gp.width }}
290293
>
291-
{block.collection?.schema[gp.property].name}
294+
{block.collection?.schema[gp.property]?.name}
292295
</th>
293296
))}
294297
</tr>
295298
</thead>
299+
296300
<tbody>
297-
{block?.collection?.data.map(row => (
298-
<tr className="notion-tr">
301+
{block?.collection?.data.map((row, index) => (
302+
<tr className="notion-tr" key={index}>
299303
{collectionView.format?.table_properties
300304
?.filter(p => p.visible)
301-
.map(gp => (
305+
.map((gp, index) => (
302306
<td
307+
key={index}
303308
className={
304309
"notion-td " +
305310
(gp.property === "title" ? "notion-bold" : "")
306311
}
307312
>
308313
{
309314
renderChildText(
310-
row[block.collection?.schema[gp.property].name!]
315+
row[
316+
block.collection?.schema[gp.property]?.name!
317+
]
311318
)!
312319
}
313320
</td>
@@ -318,6 +325,7 @@ export const Block: React.FC<Block> = props => {
318325
</table>
319326
</div>
320327
)}
328+
321329
{collectionView?.type === "gallery" && (
322330
<div className="notion-gallery">
323331
{block.collection?.data.map((row, i) => (

src/styles.css

+1
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ img.notion-page-icon {
476476
}
477477

478478
.notion-table {
479+
width: 100%;
479480
border-left: none;
480481
border-right: none;
481482
border-spacing: 0px;

0 commit comments

Comments
 (0)