Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="drum-machine">
  <div id="display"></div>
  <div class="drum-pad" id="Audio1">Q
    <audio class="clip" src="https://www.youtube.com/watch?v=hQC8COGQ4BM" id="Q"></audio>
  </div>
  <div class="drum-pad" id="Audio2">W
    <audio class="clip" src="https://www.youtube.com/watch?v=hQC8COGQ4BM" id="W"></audio>
  </div>
  <div class="drum-pad" id="Audio3">E
    <audio class="clip" src="https://www.youtube.com/watch?v=hQC8COGQ4BM" id="E"></audio>
  </div>
  <div class="drum-pad" id="Audio4">A
    <audio class="clip" src="https://www.youtube.com/watch?v=hQC8COGQ4BM" id="A"></audio>
  </div>
  <div class="drum-pad" id="Audio5">S
    <audio class="clip" src="https://www.youtube.com/watch?v=hQC8COGQ4BM" id="S"></audio>
  </div>
  <div class="drum-pad" id="Audio6">D
    <audio class="clip" src="https://www.youtube.com/watch?v=hQC8COGQ4BM" id="D"></audio>
  </div>
  <div class="drum-pad" id="Audio7">Z
    <audio class="clip" src="https://www.youtube.com/watch?v=hQC8COGQ4BM" id="Z"></audio>
  </div>
  <div class="drum-pad" id="Audio8">X
    <audio class="clip" src="https://www.youtube.com/watch?v=hQC8COGQ4BM" id="X"></audio>
  </div>
  <div class="drum-pad" id="Audio9">C
    <audio class="clip" src="https://www.youtube.com/watch?v=hQC8COGQ4BM" id="C"></audio>
  </div>
</div>
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css?family=Arvo|Rubik:400,400i,700");

:root {
   --serif: "Arvo", serif;
   --sans: "Rubik", sans-serif;

   --blue: #355263;
   --blue-dark: #1f313f;
   --yellow: #fdd24e;
   --white: #efefef;
   --grey: #d5d5d3;
}

*,
*::after,
*::before {
   padding: 0;
   margin: 0;
   box-sizing: inherit;
}

a:link,
a:visited {
   text-decoration: none;
   color: inherit;
}

button {
   border: none;
   color: inherit;
   background: none;
}

img {
   max-width: 100%;
}

html {
   min-height: 100vh;
   font-size: 62.5%;
   box-sizing: border-box;
   font-family: var(--sans);
}

.App {
   background-color: var(--grey);
   height: 100vh;

   display: flex;
}

.sidebar {
   height: 100vh;
   width: 8rem;
   background-color: var(--blue);
   display: flex;
   flex-direction: column;
   align-items: center;
   justify-content: space-between;

   & .logo {
      width: 4.8rem;
      height: 4.8rem;
      margin-top: 2rem;
   }

   & .brand {
      transform: rotate(-90deg) translateX(46%);
      white-space: nowrap;
      line-height: 8rem;
      color: var(--yellow);
      font-size: 2.4rem;
      letter-spacing: 3px;
      font-weight: normal;
      font-family: var(--sans);
      text-transform: uppercase;
   }
}

.container {
   height: 100vh;
   flex: 1 1 calc(50vw - 4rem);
   background-color: #fff;
   position: relative;
   background-color: var(--white);

   & #editor {
      width: 95%;
      height: calc(100vh - 14rem);
      resize: none;
      border: none;
      margin: 10rem 2.5% 0;
      padding: 2rem 2.5% 4rem;
      border-left: 0.5rem solid var(--grey);
   }

   & .label {
      position: absolute;
      color: var(--blue);
      background-color: var(--yellow);
      border-radius: 0.5rem;
      top: 2rem;
      left: 10%;
      height: 4.8rem;
      width: 80%;
      text-align: center;
      text-transform: uppercase;
      font-size: 1.8rem;
      line-height: 4.8rem;
      font-family: var(--sans);
      font-weight: normal;
      letter-spacing: 1px;
   }

   &:last-child {
      border-left: 1px solid var(--grey);
   }
}

.preview {
   width: 95%;
   height: calc(100vh - 14rem);
   margin: 10rem 2.5% 0;
   padding: 2rem 2.5% 4rem;
   font-family: var(--sans);
   font-size: 1.6rem;
   line-height: 1.6;
   color: var(--blue-dark);
   overflow: auto;

   & h1,
   & h2,
   & h3,
   & h4,
   & h5,
   & h6 {
      margin-top: 24px;
      margin-bottom: 16px;
      font-weight: 600;
      line-height: 1.25;
   }

   & h1 {
      font-size: 2em;
      padding-bottom: 0.3em;
      border-bottom: 1px solid var(--grey);
   }

   & h2 {
      font-size: 1.5em;
   }

   & h3 {
      font-size: 1.2em;
   }

   & a {
      color: #0366d6;

      &:hover {
         text-decoration: underline;
      }
   }

   & p {
      margin-bottom: 1em;
   }

   & blockquote {
      padding: 1em;
      background-color: #f6f8fa;
      border-left: 0.25em solid var(--blue);
      margin-bottom: 1em;
      border-radius: 0.5rem;

      & p:last-child {
         margin-bottom: 0;
      }
   }

   & ul,
   & ol {
      padding-left: 2em;

      & li + li {
         margin-top: 0.25em;
      }
   }

   & code {
      padding: 0.2em 0.4em;
      margin: 0;
      font-size: 85%;
      background-color: var(--yellow);
      border-radius: 3px;
   }

   & pre {
      padding: 16px;
      margin-bottom: 1.5em;
      overflow: auto;
      font-size: 85%;
      line-height: 1.45;
      background-color: #f6f8fa;
      border-radius: 0.5rem;
      word-wrap: normal;
      border-left: 0.25em solid var(--yellow);

      & > code {
         padding: 0;
         margin: 0;
         font-size: 100%;
         line-height: 1.5;
         word-break: normal;
         white-space: pre;
         background: transparent;
         border: 0;
         display: inline;
         max-width: auto;
         overflow: visible;
      }
   }

   & hr {
      border: none;
      border-bottom: 1px solid var(--grey);
      margin: 1.5em auto;
   }

   & img {
      margin-top: 1em;
   }

   & table {
      border-collapse: collapse;
      margin-bottom: 1em;

      & td,
      & th {
         border: 1px solid var(--grey);
         padding: 0.2em 0.4em;
      }
   }
}

              
            
!

JS

              
                import React from "https://cdn.skypack.dev/react";
import ReactDOM from "https://cdn.skypack.dev/react-dom";
class MarkdownPreviewer extends React.Component {
   state = {
      rawInput: placeholder
   };

   onChange(raw) {
      this.setState({ rawInput: raw });
   }

   render() {
      window.marked.setOptions({
         breaks: true
      });

      return (
         <div className="App">
            <header className="sidebar">
               <img
                  src="https://amr-adel.github.io/fcc-markdown-previewer/static/media/logo.da62a73a.svg"
                  alt="markdown previewer logo"
                  className="logo"
               />
               <h1 className="brand">Markdown previewer</h1>
            </header>

            <div className="container">
               <h2 className="label">editor</h2>
               <textarea
                  name="editor"
                  id="editor"
                  value={this.state.rawInput}
                  onChange={e => this.onChange(e.target.value)}
               />
            </div>

            <article className="container">
               <h2 className="label">preview</h2>
               <div
                  className="preview"
                  id="preview"
                  dangerouslySetInnerHTML={{
                     __html: window.marked(this.state.rawInput)
                  }}
               />
            </article>
         </div>
      );
   }
}

const placeholder = `# Markdown Previewer

[![Markdown Previewer](https://raw.githubusercontent.com/amr-adel/fcc-markdown-previewer/master/public/demo.jpg "Markdown Previewer")](https://amr-adel.github.io/fcc-markdown-previewer/)

## FreeCodeCamp | Front End Libraries Projects

A *FreeCodeCamp* challenge on using front end libraries to build a markdown previewer with the below user stories to be fulfilled:

> **Required**
> 1. I can see a \`textarea\` element with a corresponding \`id="editor"\`.
> 2.  I can see an element with a corresponding \`id="preview"\`.
> 3. When I enter text into the \`#editor\` element, the \`#preview\` element is updated as I type to display the content of the textarea.
> 4. When I enter GitHub flavored markdown into the \`#editor\` element, the text is rendered as HTML in the \`#preview\` element as I type (HINT: You don't need to parse Markdown yourself - you can import the Marked library for this: https://cdnjs.com/libraries/marked).
> 5. When my markdown previewer first loads, the default text in the \`#editor\` field should contain valid markdown that represents at least one of each of the following elements: a header (H1 size), a sub header (H2 size), a link, inline code, a code block, a list item, a blockquote, an image, and bolded text.
> 6. When my markdown previewer first loads, the default markdown in the \`#editor\` field should be rendered as HTML in the \`#preview\` element.

> **Optional Bonus**
> 1. When I click a link rendered by my markdown previewer, the link is opened up in a new tab (HINT: read the Marked.js docs for this one!).
> 2. When I click a link rendered by my markdown previewer, the link is opened up in a new tab (HINT: read the Marked.js docs for this one!).

---

\`\`\`                      
   <p>Hello world! This is HTML CODE BLOCK.</p>          
\`\`\`

---

#### More about the challenge [Build a Markdown Previewer](https://learn.freecodecamp.org/front-end-libraries/front-end-libraries-projects/build-a-markdown-previewer).
#### See it in action [HERE](https://amr-adel.github.io/fcc-markdown-previewer/).`;

ReactDOM.render(<MarkdownPreviewer />, document.getElementById("root"));

              
            
!
999px

Console