MCPcopy Create free account
hub / github.com/dailydotdev/apps / CommentInput

Function CommentInput

packages/shared/src/components/comments/CommentInput.tsx:16–69  ·  view source on GitHub ↗
({
  onClose,
  className,
  forceInline = false,
  ...props
}: CommentInputProps)

Source from the content-addressed store, hash-verified

14}
15
16export default function CommentInput({
17 onClose,
18 className,
19 forceInline = false,
20 ...props
21}: CommentInputProps): ReactElement {
22 const isFullScreen = !useViewSize(ViewSize.Laptop) && !forceInline;
23 // The draft lives above the drawer/inline swap at the Laptop breakpoint.
24 const [draft, setDraft] = useState<string>();
25
26 const mutateCommentResult = useMutateComment({
27 post: props.post,
28 editCommentId: props.editCommentId,
29 parentCommentId: props.parentCommentId,
30 onCommented: props.onCommented,
31 });
32
33 const composer = (
34 <CommentMarkdownInput
35 {...props}
36 autoFocus={isFullScreen || props.autoFocus}
37 fills={isFullScreen}
38 className={isFullScreen ? undefined : className}
39 initialContent={draft ?? props.initialContent}
40 onChange={(value) => {
41 setDraft(value);
42 props.onChange?.(value);
43 }}
44 onClose={onClose}
45 />
46 );
47
48 return (
49 <WriteCommentContext.Provider
50 value={{ mutateComment: mutateCommentResult }}
51 >
52 {isFullScreen ? (
53 <Drawer
54 isOpen
55 isFullScreen
56 // Transformed ancestors trap position: fixed
57 appendOnRoot
58 position={DrawerPosition.Bottom}
59 onClose={() => onClose?.()}
60 className={{ wrapper: 'flex flex-col !p-0' }}
61 >
62 {composer}
63 </Drawer>
64 ) : (
65 composer
66 )}
67 </WriteCommentContext.Provider>
68 );
69}

Callers

nothing calls this directly

Calls 3

useViewSizeFunction · 0.90
useMutateCommentFunction · 0.90
onCloseFunction · 0.50

Tested by

no test coverage detected