Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add floating mobile menu #58

Merged
merged 2 commits into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/client-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function ClientLayout({ children }: PropsWithChildren<{}>) {
>
<NavigationBar />
{children}
<Toaster />
<Toaster position="top-center" />
</ThemeProvider>
);
}
Expand Down
10 changes: 7 additions & 3 deletions src/components/flashcard/answer-buttons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ function AnswerButton({
<TooltipProvider key={rating}>
<Tooltip>
<TooltipTrigger asChild>
<Button variant="outline" onClick={() => onRating(rating)}>
<Button
className="h-full"
variant="outline"
onClick={() => onRating(rating)}
>
<p>{rating}</p>
</Button>
</TooltipTrigger>
Expand All @@ -52,7 +56,7 @@ export default function AnswerButtons({
const ratingsToShow: Rating[] = ["Again", "Hard", "Good", "Easy"];

return (
<div className="grid w-80 grid-cols-2 gap-x-2 gap-y-2 sm:w-96 md:grid-cols-4">
<div className="grid h-12 w-screen grid-cols-2 gap-x-2 gap-y-2 px-2 sm:w-96 md:grid-cols-4">
{open ? (
ratingsToShow.map((rating) => {
return (
Expand All @@ -70,7 +74,7 @@ export default function AnswerButtons({
) : (
<Button
variant="secondary"
className="col-span-2 font-mono hover:animate-pulse md:col-span-4"
className="invisible col-span-2 h-full font-mono hover:animate-pulse sm:visible md:col-span-4"
onClick={() => setOpen(true)}
>
space to reveal
Expand Down
14 changes: 6 additions & 8 deletions src/components/flashcard/flashcard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
import { buttonVariants } from "@/components/ui/button";
import { UiCard } from "@/components/ui/card";
import {
Dialog,
DialogContent,
Expand All @@ -38,7 +37,7 @@ import { cn } from "@/utils/ui";
import { zodResolver } from "@hookform/resolvers/zod";
import _ from "lodash";
import { FilePenIcon, Info, Telescope, TrashIcon } from "lucide-react";
import { useEffect, useRef, useState } from "react";
import { useRef, useState } from "react";
import { useForm } from "react-hook-form";

type Props = {
Expand Down Expand Up @@ -174,10 +173,7 @@ export default function Flashcard({
</div>

<Form {...form}>
<form
action=""
className="col-span-8 grid grid-cols-8 place-items-end gap-x-4 gap-y-4 sm:grid-rows-[2fr_1fr]"
>
<div className="col-span-8 grid grid-cols-8 place-items-end gap-x-4 gap-y-4 sm:grid-rows-[2fr_1fr]">
<div
className={cn(
"col-span-8 flex h-full min-h-80 w-full items-center overflow-y-auto border border-input sm:col-span-4 sm:min-h-96",
Expand Down Expand Up @@ -221,15 +217,17 @@ export default function Flashcard({
/>
</div>

<div className="col-span-8 flex justify-center self-start justify-self-center">
<div className="h-40 sm:hidden"></div>

<div className="fixed bottom-8 z-20 col-span-8 flex justify-center self-start justify-self-center sm:static">
<AnswerButtons
schemaRatingToReviewDay={schemaRatingToReviewDay}
onRating={onRating}
open={open}
setOpen={setOpen}
/>
</div>
</form>
</div>
</Form>
</div>
);
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/card/use-grade-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export function useGradeCard(options?: GradeMutationOptions): GradeMutation {
},

async onSuccess() {
await utils.card.sessionData.cancel();
const sessionData = utils.card.sessionData.getData();
// Refetch periodically to get more cards
// We don't use infinite queries here because there is no pagination
Expand All @@ -43,6 +44,7 @@ export function useGradeCard(options?: GradeMutationOptions): GradeMutation {
)
return;

console.log("Invalidated");
await utils.card.sessionData.invalidate();
},

Expand Down