here and use it to wrap the
+ // `SessionPreview`, implementing `SessionPreview` as a generic
.
+ // However, this breaks the CSS layout when any of the `SessionPreview`s'
+ // dates don't fit on a single line, as then the cards' heights vary
+ // depending on whether the displayed date wraps.
+ //
+ // However, if we implement the `SessionPreview` as a
rather than as
+ // a
inside a
, then the CSS works as expected: each card in a
+ // given row is the same height, irrespective of whether the displayed
+ // date wraps. (@dhess: I don't understand CSS well enough to know why
+ // this happens.)
+ //
+ // There are two implications of this design choice:
+ //
+ // 1. `SessionPreview` is less generic than we'd like (
rather than
+ //
).
+ //
+ // 2. We have to pass a `key` property here to `SessionPreview`, or else
+ // eslint complains, even though `SessionPreview` knows how to set the key
+ // itself. We could tell eslint to ignore the warning in this situation,
+ // but I'm not sure whether React also needs the key to be specified
+ // explicitly, so better safe than sorry.
+
))}
);
diff --git a/src/components/SessionPreview/index.tsx b/src/components/SessionPreview/index.tsx
index 833b7c7a..2ae3aea1 100644
--- a/src/components/SessionPreview/index.tsx
+++ b/src/components/SessionPreview/index.tsx
@@ -1,5 +1,8 @@
import "@/index.css";
+import { StarIcon, TrashIcon, UserPlusIcon } from "@heroicons/react/24/outline";
+
+import type { Key } from "react";
import { Link } from "react-router-dom";
import { SessionMeta } from "@/Types";
@@ -7,29 +10,87 @@ import { BinaryTreePlaceholder } from "@/components";
export interface SessionPreviewProps {
session: SessionMeta;
+ key: Key;
}
+// Note: `SessionPreview` is implemented as a
for reasons explained in
+// `SessionList.ts`. This is fine for now, as we only display session previews
+// in the sessions list, but we would prefer that this type were more generic.
+
export const SessionPreview = ({
session,
+ key,
}: SessionPreviewProps): JSX.Element => {
const locale: string = navigator.language;
return (
-