-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
81 create a general purpose sentence creator form (#91)
* Initial work Add global store for dialog Start to create form Need to work out UX * Mostly working version with settings * Generations form in good shape Time to integrate into the other areas * Wire up the sentence form to the plans
- Loading branch information
Showing
15 changed files
with
1,141 additions
and
21 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 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,52 @@ | ||
"use client"; | ||
|
||
import { useEffect } from "react"; | ||
|
||
import { | ||
Dialog, | ||
DialogContent, | ||
DialogDescription, | ||
DialogHeader, | ||
DialogTitle, | ||
} from "~/components/ui/dialog"; | ||
|
||
import { useSentenceCreatorStore } from "./_stores/sentenceCreatorStore"; | ||
import { SentenceCreatorForm } from "./SentenceCreatorForm"; | ||
|
||
export function SentenceCreatorDialog() { | ||
const isModalOpen = useSentenceCreatorStore((state) => state.isModalOpen); | ||
|
||
const toggleModal = useSentenceCreatorStore((state) => state.toggleModal); | ||
const setModalOpen = useSentenceCreatorStore((state) => state.setModalOpen); | ||
|
||
const targetWords = useSentenceCreatorStore((state) => state.targetWords); | ||
|
||
useEffect(() => { | ||
const down = (e: KeyboardEvent) => { | ||
if (e.key === "j" && (e.metaKey || e.ctrlKey)) { | ||
e.preventDefault(); | ||
toggleModal(); | ||
} | ||
}; | ||
|
||
document.addEventListener("keydown", down); | ||
return () => document.removeEventListener("keydown", down); | ||
|
||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); | ||
|
||
return ( | ||
<div> | ||
<Dialog open={isModalOpen} onOpenChange={setModalOpen}> | ||
<DialogContent className="max-w-[800px]"> | ||
<DialogHeader> | ||
<DialogTitle>Sentence Creator Helper</DialogTitle> | ||
<DialogDescription> | ||
<SentenceCreatorForm initialWordTargets={targetWords} /> | ||
</DialogDescription> | ||
</DialogHeader> | ||
</DialogContent> | ||
</Dialog> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.