-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into refact/toolbar
- Loading branch information
Showing
7 changed files
with
133 additions
and
22 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
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,20 @@ | ||
import { ElementsTypeName } from '../types/CommonTypes'; | ||
|
||
interface Props { | ||
className: string; | ||
handlerClick: (typeName: ElementsTypeName) => void; | ||
} | ||
|
||
const TextIconBtn = ({ className, handlerClick }: Props) => { | ||
return ( | ||
<button className={`${className}`} onClick={() => handlerClick('text')}> | ||
<svg viewBox="0 0 24 24" height="100%" xmlns="http://www.w3.org/2000/svg"> | ||
<text y="80%" x="20%" width={24} height={24} strokeWidth="2"> | ||
Tt | ||
</text> | ||
</svg> | ||
</button> | ||
); | ||
}; | ||
|
||
export default TextIconBtn; |
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,50 @@ | ||
import { useRef } from 'react'; | ||
import { useAtom, useAtomValue } from 'jotai'; | ||
import { isDrawingAtom, updateElementsAtom } from '../store/store'; | ||
import { Element } from '../types/CommonTypes'; | ||
|
||
type Props = { | ||
element: Element; | ||
}; | ||
|
||
const Textarea = ({ element }: Props) => { | ||
const [, updateElements] = useAtom(updateElementsAtom); | ||
const isDrawing = useAtomValue(isDrawingAtom); | ||
|
||
const textareaRef = useRef<HTMLTextAreaElement>(null); | ||
|
||
const onChangeTexstarea = (event: React.ChangeEvent<HTMLTextAreaElement>) => { | ||
if (textareaRef.current) { | ||
textareaRef.current.style.height = 'auto'; | ||
textareaRef.current.style.height = | ||
textareaRef.current.scrollHeight + 'px'; | ||
updateElements({ | ||
...element, | ||
height: textareaRef.current.scrollHeight, | ||
textvalue: event.target.value, | ||
}); | ||
} | ||
}; | ||
|
||
return ( | ||
<textarea | ||
ref={textareaRef} | ||
rows={1} | ||
autoFocus={isDrawing} | ||
style={{ | ||
width: '100%', | ||
height: '100%', | ||
resize: 'none', | ||
border: 'none', | ||
scrollbarWidth: 'none', | ||
backgroundColor: element.fill, | ||
}} | ||
placeholder="text" | ||
value={element.textvalue} | ||
onChange={(event) => onChangeTexstarea(event)} | ||
name="text-element" | ||
/> | ||
); | ||
}; | ||
|
||
export default Textarea; |
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