Hi All,
I’m on challenge number 2 of the Front End Development Libraries. I have everything working except I can’t figure out why using literals for code blocks in the Editor section does not render as a code block in the Preview section. Any ideas what I’m missing? Please see below for my code so far.
Thanks!
HTML
<!DOCTYPE html>
<html lang="en">
<body>
<head>
<title>Markdown Previewer</title>
</head>
<div id="root"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/4.2.4/marked.min.js" integrity="sha512-nwWBb9WFoP7Q0hkeTjUPmHkkYLnmYgYnZ8PvQVVL2XJ9RLCGuLqKe86bhmZ3CJXGU8F777uuPkDQTkZ2qAuyvA==" crossorigin="anonymous" referrerpolicy="no-referrer"> </script>
</body>
</html>
CSS
body {
background-color: #fc3903;
text-align: center;
margin: auto;
justify-content: center;
}
#editor-top {
background-color: #16a9f2;
width: 806px;
height: 2em;
margin: auto;
margin-bottom: 0;
margin-top: 2em;
border-radius: 5px 5px 0 0;
box-shadow: 0px 0px 20px black;
text-align: left;
}
#editor {
margin: auto;
margin-top: 0;
height: 20em;
width: 800px;
overflow-y: scroll;
resize: vertical;
background-color: #b3e9f5;
}
#preview {
text-align: center;
padding-top: 2em;
margin: auto;
width: 1000px;
height: auto;
min-height: 60em;
background-color: #b3e9f5;
box-shadow: 0px 0px 20px black;
}
#hidden {
display: none;
}
#preview-top {
background-color: #16a9f2;
width: 1000px;
height: 2em;
margin: auto;
margin-bottom: 0;
margin-top: 2em;
border-radius: 5px 5px 0 0;
box-shadow: 0px 0px 20px black;
text-align: left;
}
.top-image {
display: inline;
height: 50%;
padding-top: 8px;
padding-left: 10px;
}
.top-text {
display: inline;
font-weight: bold;
padding-left: 10px;
}
img {
max-width: 90%;
}
Javyscript
import React, { useState } from "https://cdn.skypack.dev/react";
import ReactDOM from "https://cdn.skypack.dev/react-dom";
import useStateInCustomProperties from "https://cdn.skypack.dev/use-state-in-custom-properties";
class ControlledInput extends React.Component {
constructor(props) {
super(props);
this.state = {
input: "",
messages: []
};
// Change code below this line
this.handleChange = this.handleChange.bind(this);
// Change code above this line
}
// Change code below this line
handleChange (event) {
this.setState({
input: event.target.value
});
}
render() {
return (
<div>
{ /* Change code below this line */}
<div id="editor-top"><img className="top-image" src="https://d33wubrfki0l68.cloudfront.net/bbfa33a202e8612d49b6c1ed05c1fdd8e4001566/bbdd1/img/fcc_secondary_small.svg"></img><p className="top-text">Editor</p></div>
<textarea id="editor" onChange={this.handleChange}></textarea>
{ /* Change code above this line */}
<h4>Controlled Input:</h4>
<div id="preview-top"><img className="top-image" src="https://d33wubrfki0l68.cloudfront.net/bbfa33a202e8612d49b6c1ed05c1fdd8e4001566/bbdd1/img/fcc_secondary_small.svg"></img><p className="top-text">Previewer</p></div>
<div id="preview" dangerouslySetInnerHTML= {{__html: marked.parse(this.state.input)}} />
</div>
);
}
};
ReactDOM.render(<ControlledInput/>, document.getElementById('root'))