Skip to content

Commit fbf4efd

Browse files
committed
doc: added some comments
1 parent 9b18b00 commit fbf4efd

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/components/SnippetList.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const SnippetList = () => {
4040
return (
4141
<motion.li
4242
key={currentSnippet.title + idx}
43-
layoutId={currentSnippet.title + (idx + 1).toString()}
43+
layoutId={currentSnippet.title + (idx + 1).toString()} // unique id for layout animation
4444
initial={{ opacity: 0, y: 20 }}
4545
animate={{
4646
opacity: 1,
@@ -69,6 +69,7 @@ const SnippetList = () => {
6969
onClick={() =>
7070
handleOpenModal({
7171
...currentSnippet,
72+
// added idx for the layout animation to work correctly
7273
idx: idx + 1,
7374
})
7475
}

src/components/SnippetModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const SnippetModal: React.FC<Props> = ({
4949
key="modal-content"
5050
className="modal | flow"
5151
data-flow-space="lg"
52-
layoutId={snippet.title + snippet.idx?.toString()}
52+
layoutId={snippet.title + snippet.idx?.toString()} // unique id for layout animation
5353
transition={{ type: "spring", duration: shouldReduceMotion ? 0 : 0.5 }}
5454
>
5555
<div className="modal__header">

src/types/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export type SnippetType = {
1414
code: string;
1515
tags: string[];
1616
author: string;
17-
idx?: number; // Add optional idx property
17+
idx?: number;
1818
};
1919

2020
export type AppState = {

0 commit comments

Comments
 (0)