JavaScript preprocessors can help make authoring JavaScript easier and more convenient. For instance, CoffeeScript can help prevent easy-to-make mistakes and offer a cleaner syntax and Babel can bring ECMAScript 6 features to browsers that only support ECMAScript 5.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
HTML Settings
Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
<div id="app"></div>
<!-- <script src="https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js"></script>
-->
body {
font-family: 'Nanum Gothic', sans-serif;
color: #444;
background: url(https://raw.githubusercontent.com/paul-duvall/website_images/master/mountains.jpg);
background-size: cover;
}
h1 {
text-align: center;
font-weight: 700;
}
p {
width: 90%;
margin: 0 auto;
line-height: 25px;
}
.wrapper {
display: flex;
justify-content: center;
align-items: center;
height: 90vh;
}
.quote {
width: 75%;
margin: 0 auto;
font-size: 22px;
font-weight: 700;
line-height: 35px;
}
#quote-box {
border-radius: 10px;
width: 700px;
height: 400px;
padding: 10px;
display: flex;
flex-direction: column;
justify-content: space-between;
background: white;
opacity: 0.65;
}
#author {
text-align: right;
font-family: 'Great Vibes', cursive;
font-size: 30px;
margin-top: 15px;
}
.buttons {
margin: 0 auto;
margin-bottom: 15px;
}
#new-quote {
padding: 12px 27px;
font-size: 16px;
color: #333;
border: 2px solid #333;
background: white;
margin-right: 75px;
border-radius: 10px;
transition: all .2s ease-in;
}
#tweet-quote {
border: 2px solid #333;
padding: 12px 24px;
text-decoration: none;
font-size: 16px;
color: #333;
border-radius: 10px;
transition: all .3s ease-in;
}
#new-quote:hover, #tweet-quote:hover {
background: #333;
color: white;
}
class App extends React.Component {
constructor(props){
super(props);
this.handleGenerateQuote = this.handleGenerateQuote.bind(this);
this.state = {
quote: '',
author: undefined,
quotes: [
{
quote: "It never ceases to amaze me: we all love ourselves more than other people, but care more about their opinion than our own.",
author: "Marcus Aurelius"
},
{
quote: "Choose not to be harmed — and you won’t feel harmed. Don’t feel harmed — and you haven’t been.",
author: "Marcus Aurelius"
},
{
quote: "No person has the power to have everything they want, but it is in their power not to want what they don’t have, and to cheerfully put to good use what they do have.",
author: "Seneca"
},
{
quote: "Nothing, to my way of thinking, is a better proof of a well ordered mind than a man’s ability to stop just where he is and pass some time in his own company.",
author: "Seneca"
},
{
quote: "Don’t seek for everything to happen as you wish it would, but rather wish that everything happens as it actually will—then your life will flow well.",
author: "Epictetus"
},
{
quote: "I begin to speak only when I’m certain what I’ll say isn’t better left unsaid.",
author: "Cato"
},
{
quote: "When we are no longer able to change a situation, we are challenged to change ourselves.",
author: "Viktor Frankl"
},
{
quote: "Curb your desire—don’t set your heart on so many things and you will get what you need.",
author: "Epictetus"
},
{
quote: "First say to yourself what you would be; and then do what you have to do.",
author: "Epictetus"
},
{
quote: "How does it help…to make troubles heavier by bemoaning them?",
author: "Seneca"
},
{
quote: "I judge you unfortunate because you have never lived through misfortune. You have passed through life without an opponent—no one can ever know what you are capable of, not even you.",
author: "Seneca"
},
{
quote: "Life is very short and anxious for those who forget the past, neglect the present, and fear the future.",
author: "Seneca"
},
{
quote: "If anyone can refute me—show me I’m making a mistake or looking at things from the wrong perspective—I’ll gladly change. It’s the truth I’m after, and the truth never harmed anyone.",
author: "Marcus Aurelius"
},
{
quote: "It’s time you realized that you have something in you more powerful and miraculous than the things that affect you and make you dance like a puppet.",
author: "Marcus Aurelius"
},
{
quote: "The best revenge is not to be like your enemy.",
author: "Marcus Aurelius"
}
]
};
}
componentDidMount() {
this.handleGenerateQuote();
}
handleGenerateQuote(){
const randomNumber = Math.floor(Math.random() * this.state.quotes.length);
this.setState({
quote: this.state.quotes[randomNumber].quote,
author: this.state.quotes[randomNumber].author
});
}
render() {
return (
<div class="wrapper">
<div id="quote-box">
<Header />
<CurrentQuote quote={this.state.quote} author={this.state.author} />
<Buttons handleGenerateQuote={this.handleGenerateQuote} quote={this.state.quote} author={this.state.author}/>
</div>
</div>
);
}
}
const Header = () => {
return (
<div>
<h1>The Stoic Quote Machine</h1>
<p>The Stoics knew what's what. If you're struggling to find your way in life, use this insightful device to generate a quote that will undoubtedly get you through the day.</p>
</div>
);
};
const CurrentQuote = (props) => {
return (
<div class="quote">
<div id="text">"{props.quote}"</div>
<div id="author">- {props.author}</div>
</div>
);
};
const Buttons = (props) => {
return (
<div class="buttons">
<button id="new-quote" onClick={props.handleGenerateQuote}>New Quote</button>
<a id="tweet-quote" href={'https://twitter.com/intent/tweet?text=' + props.quote} target="_blank">Tweet Quote</a>
</div>
);
}
ReactDOM.render(<App/>, document.getElementById('app'));
Also see: Tab Triggers