-
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.
Merge pull request #22 from abdowns/dev
Dev
- Loading branch information
Showing
9 changed files
with
131 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,28 @@ | ||
import "./contentblock.css" | ||
import { useState } from 'react'; | ||
|
||
import "./contentblock.css"; | ||
|
||
import Editor from '../editor/editor'; | ||
|
||
interface TextBlockProps { | ||
text: string; | ||
} | ||
|
||
export default function TextBlock(props: TextBlockProps) { | ||
const [editing, setEditing] = useState(false); | ||
const [text, setText] = useState(props.text); | ||
|
||
function toggleEditing() { | ||
setEditing(!editing); | ||
} | ||
|
||
return ( | ||
<div className="contentblock"> | ||
<p className="text">{props.text}</p> | ||
<div className="contentblock" onClick={() => {}}> | ||
{ | ||
(editing) | ||
? <Editor text={'test'} setText={setText}/> | ||
: <p> {text} </p> | ||
} | ||
</div> | ||
) | ||
} |
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,21 @@ | ||
.editor-main { | ||
border: solid; | ||
border-color: lightgray; | ||
border-width: 2px; | ||
border-radius: 5px; | ||
} | ||
|
||
.editor-main > textarea { | ||
background-color: red; | ||
|
||
width: 100%; | ||
height: 100px; | ||
margin: 10px; | ||
|
||
border: none; | ||
outline: none; | ||
resize: none; | ||
|
||
font-family: 'Inter', sans-serif; | ||
font-size: 20; | ||
} |
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,37 @@ | ||
import { useRef } from 'react'; | ||
|
||
import './editor.css' | ||
|
||
interface EditorProps { | ||
text: string; | ||
setText: (_v: string) => void; | ||
} | ||
|
||
export default function Editor(props: EditorProps) { | ||
// const textArea = document.getElementById('editor-textarea'); | ||
const textAreaRef = useRef<HTMLTextAreaElement>(null); | ||
|
||
function autoResize() { | ||
// ta.style.height = 'auto'; | ||
// ta.style.height = ta.scrollHeight + 'px'; | ||
|
||
const textArea = textAreaRef.current; | ||
if (textArea) { | ||
textArea.style.height = 'auto'; | ||
textArea.style.height = textArea.scrollHeight + 'px'; | ||
|
||
console.log(textArea.scrollHeight) | ||
} | ||
} | ||
|
||
return ( | ||
<div className='editor-main'> | ||
<textarea | ||
id='editor-textarea' | ||
onInput={autoResize} | ||
ref={textAreaRef} | ||
defaultValue={props.text} | ||
/> | ||
</div> | ||
); | ||
} |
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
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