-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
23cae7e
commit 85a085e
Showing
14 changed files
with
1,169 additions
and
136 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,14 +1,23 @@ | ||
{ | ||
"name": "markdown-editor", | ||
"version": "0.1.0", | ||
"version": "1.0.0", | ||
"description": "A react app to preview and edit Markdown", | ||
"private": true, | ||
"author": { | ||
"name": "Aromal Anil", | ||
"email": "[email protected]", | ||
"url": "https://aromalanil.me" | ||
}, | ||
"dependencies": { | ||
"@testing-library/jest-dom": "^4.2.4", | ||
"@testing-library/react": "^9.5.0", | ||
"@testing-library/user-event": "^7.2.1", | ||
"node-sass": "^4.13.1", | ||
"react": "^16.13.1", | ||
"react-dom": "^16.13.1", | ||
"react-scripts": "3.4.1" | ||
"react-scripts": "3.4.1", | ||
"react-split": "^2.0.7", | ||
"showdown": "^1.9.1" | ||
}, | ||
"scripts": { | ||
"start": "react-scripts start", | ||
|
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 was deleted.
Oops, something went wrong.
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,74 @@ | ||
//Custom Fonts | ||
@import url('https://fonts.googleapis.com/css2?family=Source+Code+Pro&display=swap'); | ||
@import url('https://fonts.googleapis.com/css2?family=Open+Sans&display=swap'); | ||
|
||
//Variable Decelerations | ||
$primary-color:#339989; | ||
$primary-accent:#7DE2D1; | ||
$primary-text:#131515; | ||
$text-accent:#2B2C28; | ||
$white:#FFFAFB; | ||
$source-code-font:'Open Sans', sans-serif; | ||
$open-sans-font:'Source Code Pro', monospace; | ||
|
||
// General Styling | ||
*{ | ||
margin: 0; | ||
padding: 0; | ||
box-sizing: border-box; | ||
} | ||
|
||
body{ | ||
color:$primary-text; | ||
font-family: $source-code-font; | ||
} | ||
|
||
.navbar{ | ||
background-color: $primary-color; | ||
color:$white; | ||
padding: 1rem 5vw; | ||
} | ||
|
||
.work-area{ | ||
width: 100vw; | ||
height: calc(100vh - 60px); | ||
margin: auto; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
|
||
} | ||
|
||
.wrapper-card{ | ||
width: 95%; | ||
height: 90%; | ||
display: flex; | ||
box-shadow: 0 4px 12px rgba(0,0,0,.24); | ||
} | ||
.markdown-edit,.markdown-preview{ | ||
padding: 1rem; | ||
display: flex; | ||
flex-direction: column; | ||
flex: 2rem 1fr; | ||
} | ||
|
||
.section-title{ | ||
text-transform: uppercase; | ||
} | ||
|
||
.markdown-edit{ | ||
width: 100%; | ||
textarea{ | ||
font-family: $source-code-font; | ||
width: 100%; | ||
resize: none; | ||
height: 100%; | ||
} | ||
} | ||
|
||
.markdown-preview{ | ||
width: 100%; | ||
.html-div{ | ||
overflow-y: scroll; | ||
} | ||
} |
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,17 @@ | ||
import React from "react"; | ||
|
||
function MarkdownEdit({ content, changeContent }) { | ||
const handleEditorChange = (event) => { | ||
event.preventDefault(); | ||
changeContent(event.target.value); | ||
}; | ||
|
||
return ( | ||
<div className="markdown-edit"> | ||
<h3 className="section-title">Markdown</h3> | ||
<textarea value={content} onChange={handleEditorChange} id="editor"></textarea> | ||
</div> | ||
); | ||
} | ||
|
||
export default MarkdownEdit; |
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,24 @@ | ||
import React, { useState, useEffect } from "react"; | ||
import showdown from "showdown"; | ||
|
||
function MarkdownPreview({ content }) { | ||
const [html, setHtml] = useState(getHtml(content)); | ||
|
||
useEffect(() => { | ||
setHtml(getHtml(content)); | ||
}, [content]); | ||
|
||
return ( | ||
<div className="markdown-preview"> | ||
<h3 className="section-title">Preview</h3> | ||
<div className="html-div" dangerouslySetInnerHTML={{ __html: html}}></div> | ||
</div> | ||
); | ||
} | ||
|
||
const getHtml = (markdown) => { | ||
let converter = new showdown.Converter(); | ||
return converter.makeHtml(markdown); | ||
}; | ||
|
||
export default MarkdownPreview; |
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,12 @@ | ||
import React from "react"; | ||
|
||
|
||
function NavBar() { | ||
return ( | ||
<nav className="navbar"> | ||
<h3>Markdown Editor</h3> | ||
</nav> | ||
); | ||
} | ||
|
||
export default NavBar; |
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,31 @@ | ||
import React, { useState } from "react"; | ||
import Split from "react-split"; | ||
import MarkdownEdit from "./MarkdownEdit"; | ||
import MarkdownPreview from "./MarkdownPreview"; | ||
|
||
|
||
function WorkArea() { | ||
const [markDown, setMarkDown] = useState("# Hello World"); | ||
|
||
return ( | ||
<div className="work-area"> | ||
<Split | ||
className="wrapper-card" | ||
sizes={[50, 50]} | ||
minSize={100} | ||
expandToMin={false} | ||
gutterSize={10} | ||
gutterAlign="center" | ||
snapOffset={30} | ||
dragInterval={1} | ||
direction="horizontal" | ||
cursor="col-resize" | ||
> | ||
<MarkdownEdit content={markDown} changeContent={setMarkDown} /> | ||
<MarkdownPreview content={markDown} /> | ||
</Split> | ||
</div> | ||
); | ||
} | ||
|
||
export default WorkArea; |
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.