Pen Settings



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


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


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.


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.


                <script src=""></script>
<link href="" rel="stylesheet">

<div id="app"></app>


                html, body {
  height: 100%;
body {
  background: #999;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: Helvetica Neue;
  text-align: center;

h1 {
  font-size: 2em;
  display: inline-block;
  margin: 0 auto;

#quote-box {

  margin: 1em 0 0 0;
    margin: 0 auto;
  background-color: white;
  max-width: 30em;
  text-color: black;
  text-align: left;
  -webkit-box-shadow: 10px 10px 5px 0px rgba(158,158,158,1);
  -moz-box-shadow: 10px 10px 5px 0px rgba(158,158,158,1);
  box-shadow: 10px 10px 5px 0px rgba(158,158,158,1);
  border: 1px solid black;
#text {
  font-size: 2.0em;
  font-family: Serif;
  padding: .5em .5em 0 .5em;

#author {
  font-size: 1.2em;
  font-family: Serif;
  margin: .5em 0 1em 0;
  padding: 0 .5em 0 .5em;
  text-align: right;

button {
   padding: 0 1em 0 1em;
  margin: 0 1em 1em 1em;
  position: relative;

#tweet-quote {
  margin: 0 .5em 1em .5em;
  position: relative;


                //import data from '';
//import data from '';
class Application extends React.Component {
	constructor(props) {
		this.state = {
			error: null,
			isLoaded: false,
			quotesData: [],
			quotesLength: 0,
			currQuote: "The initial quote will be blank.",
			currAuthor: "The initial author will be blank."
    this.getRandomQuote = this.getRandomQuote.bind(this);
    this.tweetQuote = this.tweetQuote.bind(this);
	componentDidMount() {
		//console.log ("Component Did Mount: ");
		fetch('').then(response => {
			return response.json();
		}).then(myJson => {
			//console.log (JSON.stringify(myJson))
			myJson = (JSON.stringify(myJson));
			if (typeof myJson === 'string') {
				myJson = JSON.parse(myJson);
					quotesData: myJson,
					quotesLength: myJson.quotes.length,
					currQuote: "This is the new quote.",
					currAuthor: "This is the new author."
				//console.log ("The array length is: " + this.state.quotesLength);
				//console.log(myJson); //Too much data.
				//console.log(myJson.quotes[1].quote); //This works
				//console.log(myJson.quotes[1].author); //This works
				//console.log(this.state.quotesData); //Too much data.
				//console.log(this.state.currQuote); //This works
				//console.log(this.state.currAuthor); //This works
			} else {
				console.log("Error loading JSON file.")
	getRandomQuote() {
		//console.log ("The array length is: " + this.state.quotesLength);
		var randomNum = Math.floor((Math.random() * this.state.quotesLength) + 1);
			currQuote: this.state.quotesData.quotes[randomNum].quote,
			currAuthor: this.state.quotesData.quotes[randomNum].author,
  tweetQuote() {
    //var uri = this.state.currQuote + " - " + this.state.currAuthor;
    //var res = encodeURIComponent(uri);           
    //"" + res);
    //return false;
	render() {
    var uri = this.state.currQuote + " - " + this.state.currAuthor;
    var res = encodeURIComponent(uri); 
		//console.log ("Render: ");
		return ( <div id="content">
                <h1>Random Quote Machine</h1>
                <div id="quote-box">
                  <div id="text">“{this.state.currQuote}”</div>
                  <div id="author">-{this.state.currAuthor}</div>
                  <button id="new-quote" onClick={this.getRandomQuote}>New Quote</button>
                  <a id="tweet-quote" href="" target="_blank"></a>
                  <a id="tweet-quote2" onClick={this.tweetQuote} href="#">Tweet Quote</a> 
                  <a id="tweet-quote3" href={'' + res} target="_blank"> #3</a>
            </div> );
ReactDOM.render( < Application / > , document.getElementById('app'));