-
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.
- Loading branch information
Showing
18 changed files
with
742 additions
and
219 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,23 @@ | ||
import type { ClassValue } from "clsx"; | ||
import type { ReactNode } from "react"; | ||
import { cn } from "~/lib/utils"; | ||
|
||
type props = { | ||
focus: boolean; | ||
children: ReactNode; | ||
className?: ClassValue; | ||
}; | ||
|
||
const Circle = ({ focus, children, className }: props) => ( | ||
<div | ||
className={cn( | ||
"flex h-12 w-12 items-center justify-center rounded-full border-2 border-stone-500 font-extrabold text-2xl text-stone-500", | ||
focus && "bg-stone-950 text-white", | ||
className, | ||
)} | ||
> | ||
{children} | ||
</div> | ||
); | ||
|
||
export { Circle }; |
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,42 @@ | ||
import { | ||
type ChangeEventHandler, | ||
useCallback, | ||
useEffect, | ||
useState, | ||
} from "react"; | ||
import { useFocusRef } from "../functional/useFocusRef"; | ||
import { Textarea, type TextareaProps } from "../ui/textarea"; | ||
|
||
type props = TextareaProps & { | ||
onTextSet: (text: string) => void; | ||
focus: boolean; | ||
}; | ||
|
||
/** | ||
* focus が true のときに自動でフォーカスを当てる textarea | ||
*/ | ||
const AttractiveTextArea = ({ focus, onTextSet, ...props }: props) => { | ||
const [text, setText] = useState(""); | ||
const DOMRef = useFocusRef<HTMLTextAreaElement>(focus); | ||
|
||
const onChangeHandler: ChangeEventHandler<HTMLTextAreaElement> = useCallback( | ||
(event) => setText(event.target.value), | ||
[], | ||
); | ||
|
||
useEffect(() => { | ||
onTextSet(text); | ||
}, [text, onTextSet]); | ||
|
||
return ( | ||
<Textarea | ||
value={text} | ||
onChange={onChangeHandler} | ||
ref={DOMRef} | ||
disabled={!focus} | ||
{...props} | ||
/> | ||
); | ||
}; | ||
|
||
export { AttractiveTextArea }; |
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,28 @@ | ||
import { cn } from "~/lib/utils"; | ||
import { Circle } from "../atoms/Circle"; | ||
|
||
type props = { | ||
title: string; | ||
focus: boolean; | ||
number: number; | ||
}; | ||
|
||
const InputHeader = ({ title, focus, number }: props) => { | ||
return ( | ||
<div className="flex items-center p-3"> | ||
<Circle focus={focus} className="flex-initial"> | ||
{number} | ||
</Circle> | ||
<h2 | ||
className={cn( | ||
"pl-5 font-semibold text-stone-500 text-xl", | ||
focus && "text-black", | ||
)} | ||
> | ||
{title} | ||
</h2> | ||
</div> | ||
); | ||
}; | ||
|
||
export { InputHeader }; |
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,57 @@ | ||
import { type ComponentProps, useEffect, useRef } from "react"; | ||
import type { Drawer as DrawerPrimitive } from "vaul"; | ||
import { Button } from "../ui/button"; | ||
import { | ||
Drawer, | ||
DrawerContent, | ||
DrawerFooter, | ||
DrawerHeader, | ||
DrawerTitle, | ||
} from "../ui/drawer"; | ||
|
||
const sleep = (time: number) => | ||
new Promise((resolve) => setTimeout(resolve, time)); //timeはミリ秒 | ||
|
||
type props = ComponentProps<typeof DrawerPrimitive.Root> & { | ||
focus: boolean; | ||
children: React.ReactNode; | ||
onConfirm: () => void; | ||
}; | ||
|
||
const ConfirmDrawer = ({ children, focus, onConfirm, ...props }: props) => { | ||
const buttonRef = useRef<HTMLButtonElement>(null); | ||
|
||
useEffect(() => { | ||
console.log("use eefect"); | ||
const wait = async () => { | ||
await sleep(3000); | ||
}; | ||
wait(); | ||
if (focus) { | ||
buttonRef.current?.focus(); | ||
console.log("focue executed"); | ||
} | ||
}, [focus]); | ||
|
||
return ( | ||
<Drawer open={focus} {...props}> | ||
<DrawerContent> | ||
<DrawerHeader> | ||
<DrawerTitle className="text-center">送信しますか?</DrawerTitle> | ||
</DrawerHeader> | ||
{children} | ||
<DrawerFooter className="flex items-center justify-center"> | ||
<Button | ||
ref={buttonRef} | ||
onClick={onConfirm} | ||
className="w-1/2 bg-orange-600" | ||
> | ||
送信 | ||
</Button> | ||
</DrawerFooter> | ||
</DrawerContent> | ||
</Drawer> | ||
); | ||
}; | ||
|
||
export { ConfirmDrawer }; |
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
Oops, something went wrong.