-
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.
This adds a textarea input where any entered text is converted to a graph.
- Loading branch information
1 parent
fa5d36b
commit 59ee871
Showing
6 changed files
with
114 additions
and
31 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 @@ | ||
.addText { | ||
position: absolute; | ||
bottom: 30px; | ||
left: 60px; | ||
height: 90px; | ||
background-color: #eee; | ||
z-index: 1; | ||
|
||
textarea { | ||
width: 100%; | ||
height: 100%; | ||
margin: 0; | ||
padding: 10px; | ||
} | ||
|
||
display: none; | ||
&.visible { | ||
display: block; | ||
} | ||
} |
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,26 @@ | ||
import React, { forwardRef } from "react"; | ||
import { clsx } from "clsx"; | ||
|
||
import "./add-text.scss"; | ||
|
||
interface Props { | ||
visible: boolean; | ||
width: number; | ||
onChange: (newText: string) => void | ||
} | ||
|
||
// eslint-disable-next-line max-len | ||
const placeholder = "Create a Markov chain by typing or pasting text here. WARNING: your current Markov chain will be overwritten."; | ||
|
||
export const AddText = forwardRef<HTMLTextAreaElement, Props>(({visible, width, onChange}: Props, ref) => { | ||
const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => { | ||
onChange(e.currentTarget.value.trim()); | ||
}; | ||
|
||
return ( | ||
<div className={clsx("addText", {visible})} style={{width}}> | ||
<textarea ref={ref} placeholder={placeholder} onChange={handleChange} /> | ||
</div> | ||
); | ||
}); | ||
AddText.displayName = "AddText"; |
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