-
-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement improved highlights form with ai auto-summarise (#1381)
- Loading branch information
Showing
141 changed files
with
1,199 additions
and
827 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,30 @@ | ||
import clsx from "clsx"; | ||
import React from "react"; | ||
|
||
interface FabProps extends React.HTMLAttributes<HTMLButtonElement> { | ||
position?: "top-left" | "top-right" | "bottom-left" | "bottom-right"; | ||
onClick?: () => void; | ||
} | ||
const Fab = ({ position, children, className }: FabProps) => { | ||
const getFabPositionStyles = () => { | ||
switch (position) { | ||
case "top-left": | ||
return "top-4 left-4"; | ||
case "top-right": | ||
return "top-4 right-4"; | ||
case "bottom-left": | ||
return "bottom-4 left-4"; | ||
case "bottom-right": | ||
return "bottom-4 right-4"; | ||
default: | ||
return "bottom-8 right-8"; | ||
} | ||
}; | ||
return ( | ||
<button type="button" className={clsx("fixed", getFabPositionStyles(), className)}> | ||
{children} | ||
</button> | ||
); | ||
}; | ||
|
||
export default Fab; |
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
65 changes: 65 additions & 0 deletions
65
components/atoms/TypeWriterTextArea/type-writer-text-area.tsx
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,65 @@ | ||
import React, { ChangeEvent, useEffect, useRef } from "react"; | ||
import clsx from "clsx"; | ||
|
||
interface TypeWriterTextAreaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> { | ||
onChangeText?: (value: string) => void; | ||
typewrite?: boolean; | ||
textContent?: string; | ||
defaultRow?: number; | ||
} | ||
|
||
const TypeWriterTextArea = React.forwardRef<HTMLTextAreaElement, TypeWriterTextAreaProps>( | ||
({ className, onChangeText, typewrite, textContent, defaultRow, ...props }) => { | ||
const textareaRef = useRef<HTMLTextAreaElement>(null); | ||
const autoGrowTextarea = () => { | ||
const textarea = textareaRef.current; | ||
if (textarea) { | ||
textarea.style.height = "auto"; | ||
textarea.style.height = `${textarea.scrollHeight}px`; | ||
} | ||
}; | ||
|
||
const typeWrite = (text: string) => { | ||
const textarea = textareaRef.current; | ||
if (textarea) { | ||
textarea.focus(); | ||
textarea.value = ""; | ||
textarea.selectionStart = textarea.selectionEnd = textarea.value.length; | ||
const interval = setInterval(() => { | ||
if (textarea.value.length === text.length) { | ||
clearInterval(interval); | ||
} else { | ||
textarea.value = text.slice(0, textarea.value.length + 1); | ||
} | ||
}, 10); | ||
} | ||
}; | ||
|
||
useEffect(() => { | ||
if (typewrite && textContent) { | ||
typeWrite(textContent); | ||
} | ||
}, [typewrite, textContent]); | ||
|
||
const handleInputChange = (event: ChangeEvent<HTMLTextAreaElement>) => { | ||
onChangeText?.(event.target.value); | ||
autoGrowTextarea(); | ||
}; | ||
|
||
return ( | ||
<textarea | ||
onChange={handleInputChange} | ||
className={clsx( | ||
"flex h-20 md:min-h-26 md:h-auto w-full rounded-md py-2 text-sm placeholder:text-slate-400 disabled:cursor-not-allowed disabled:opacity-50", | ||
className | ||
)} | ||
rows={defaultRow} | ||
ref={textareaRef} | ||
{...props} | ||
/> | ||
); | ||
} | ||
); | ||
TypeWriterTextArea.displayName = "TypeWriterTextArea"; | ||
|
||
export { TypeWriterTextArea }; |
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.