-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added card statistics modal, updated packages
- very basic right now, only card history graph - accessible via card menu - updated packages (mantine to 7.5.1) - installed @mantine/charts
- Loading branch information
Showing
11 changed files
with
1,498 additions
and
261 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import React, { useMemo } from "react"; | ||
import { AreaChart } from "@mantine/charts"; | ||
import { Card, CardType } from "../../logic/card"; | ||
|
||
interface CardHistoryProps { | ||
card?: Card<CardType>; | ||
} | ||
|
||
export default function CardHistory({ card }: CardHistoryProps) { | ||
const data = useMemo(() => { | ||
if (card) { | ||
return card.history.map((h) => { | ||
return { | ||
date: h.review.getTime(), | ||
rating: h.rating, | ||
}; | ||
}); | ||
} | ||
return []; | ||
}, [card]); | ||
|
||
console.log(card?.model.due.getTime()); | ||
|
||
return ( | ||
<AreaChart | ||
h={300} | ||
data={data} | ||
series={[{ name: "rating", color: "forest" }]} | ||
dataKey="date" | ||
curveType="monotone" | ||
withTooltip={false} | ||
gridAxis="x" | ||
yAxisProps={{ | ||
domain: [1, 4], | ||
tickCount: 4, | ||
tickFormatter: (value) => { | ||
switch (value) { | ||
case 1: | ||
return "Again"; | ||
case 2: | ||
return "Hard"; | ||
case 3: | ||
return "Good"; | ||
case 4: | ||
return "Easy"; | ||
} | ||
return ""; | ||
}, | ||
}} | ||
xAxisProps={{ | ||
domain: ["dataMin", new Date(Date.now()).getTime()], | ||
scale: "linear", | ||
tickFormatter: (value) => new Date(value).toLocaleDateString(), | ||
}} | ||
connectNulls | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Modal } from "@mantine/core"; | ||
import { Card, CardType } from "../../logic/card"; | ||
import ModalProps from "../custom/ModalProps"; | ||
import CardHistory from "./CardHistory"; | ||
|
||
interface DeckOptionsModalProps extends ModalProps { | ||
card?: Card<CardType>; | ||
} | ||
|
||
function DeckOptionsModal({ opened, setOpened, card }: DeckOptionsModalProps) { | ||
return ( | ||
<Modal opened={opened} onClose={() => setOpened(false)} title="Statistics"> | ||
<CardHistory card={card} /> | ||
</Modal> | ||
); | ||
} | ||
|
||
export default DeckOptionsModal; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters