-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from zsh-eng/loading-and-done-screen
loading and done screen
- Loading branch information
Showing
15 changed files
with
104 additions
and
61 deletions.
There are no files selected for viewing
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,27 @@ | ||
import { Rating } from "@/schema"; | ||
|
||
/** | ||
* The limit below which we should refetch cards. | ||
*/ | ||
export const THRESHOLD_CARDS_FOR_REFETCH = 10; | ||
|
||
export const KEY_RATING_AGAIN = "1"; | ||
export const KEY_RATING_HARD = "2"; | ||
export const KEY_RATING_GOOD = "3"; | ||
export const KEY_RATING_EASY = "4"; | ||
|
||
export const KEY_TO_RATING: Record<string, Rating> = { | ||
[KEY_RATING_AGAIN]: "Again", | ||
[KEY_RATING_HARD]: "Hard", | ||
[KEY_RATING_GOOD]: "Good", | ||
[KEY_RATING_EASY]: "Easy", | ||
[" "]: "Good", | ||
}; | ||
|
||
export const RATING_TO_KEY: Record<Rating, string | undefined> = { | ||
Again: KEY_RATING_AGAIN, | ||
Hard: KEY_RATING_HARD, | ||
Good: KEY_RATING_GOOD, | ||
Easy: KEY_RATING_EASY, | ||
Manual: undefined, | ||
}; |
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,26 @@ | ||
import { Button } from "@/components/ui/button"; | ||
import { trpc } from "@/utils/trpc"; | ||
import { cn } from "@/utils/ui"; | ||
import { useMediaQuery } from "@uidotdev/usehooks"; | ||
import { Loader2 } from "lucide-react"; | ||
|
||
export function FetchIndicator() { | ||
const { isLoading, isFetching } = trpc.card.sessionData.useQuery(); | ||
|
||
const isMobile = useMediaQuery("only screen and (max-width: 640px)"); | ||
|
||
return isMobile ? null : ( | ||
<Button | ||
className={cn( | ||
"fixed right-4 top-16 cursor-default transition duration-500", | ||
!isLoading && isFetching ? "opacity-100" : "opacity-0", | ||
)} | ||
variant="secondary" | ||
> | ||
<Loader2 className="mr-2 h-4 w-4 animate-spin" /> | ||
Fetching Cards... | ||
</Button> | ||
); | ||
} | ||
|
||
FetchIndicator.displayName = "FetchIndicator"; |
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
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
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