HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
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.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<body class='themeFive'>
<div class="backgroundImage"></div>
<div class="backgroundOverlay"></div>
<nav id="navbar">
<header>FCC Project Documentation</header>
<!-- here's some update-->
<div>
<a href="#Random_Quote_Machine" class="nav-link">Random Quote Machine</a>
<div class="nav-space"></div>
<a href="#Markdown_Editor" class="nav-link">Markdown Editor</a>
<div class="nav-space"></div>
<a href="#Drum_Machine" class="nav-link">Drum Machine</a>
<div class="nav-space"></div>
<a href="#Pomodoro_Clock" class="nav-link">Pomodoro Clock</a>
<div class="nav-space"></div>
<a href="#Calculator" class="nav-link">Calculator</a>
</div>
</nav>
<main class="outerDiv " id="main-doc">
<section class="main-section" id="Random_Quote_Machine">
<header>Random Quote Machine</header>
<p>This was the first project for the Front End Libraries certification. The work is pretty simple. I only had to find an API that was accessable over CORS. I elected not to use Redux for any state management. </p>
<p>As first projects go, the experience was good. I had a bit of work figuring out how to use jQuery to do an async api call. I never did get into promises, which is work for future projects. I also began to stratch the surface with Bootstrap though not to any significant degree. </p>
<p>What follows is the first Mixin I wrote. It's very basic and I find that I don't use it anymore, probably because I've not had any problems with border raidus across browsers yet. </p>
<pre><code>
@mixin border-radius($x){
-webkit-border-radius: $x;
-moz-border-radius: $x;
-ms-border-radius: $x;
border-radius: $x;
}
</code></pre>
<p>The technology list employed in this project includes:</p>
<ul>
<li>HTML5</li>
<li>CSS and SCSS</li>
<li>ES6</li>
<li>React</li>
</ul>
</section>
<section class="main-section" id="Markdown_Editor">
<header>Markdown Editor</header>
<p>This was my second project along the road to Front End Library certification. My understanding of React was expanded greatly in this project and it's where I built my first reusable component with my Windowing capabilities. </p>
<p>Initially I just used the React state management for most of the interactivity, but re-engineered the project to use Redux after the Drum Machine project. </p>
<p>The most interesting parts of the project actually came during the re-engineering effort. It was during this period that I extracted out the expand/shrink fucntions out of CSS and moved it into the Redux state machine cycle. I had the idea that I could dispatch an event on one window that all windows would observe, then pass a state object that either expands the window or hides the window (when maximizing), or puts all the windows back to the orignial state. </p>
<pre><code>WindowComponent = connect(
function mapStateToProps(state, ownProps){
let fullSize = state.windows[ownProps.id].fullSize;
let styleClass = "";
if(!state.windows.fullSize){
styleClass = "window col-md-" + state.windows[ownProps.id].width
}else{
if(fullSize){
styleClass = "window col-md-12"
}else{
styleClass = "window windowHide"
}
}
let toReturn = {
width: state.windows[ownProps.id].width,
fullSize: fullSize,
styleClass: styleClass
}
return toReturn
},
function mapDispatchToProps(dispatch){
return{
resizeWindow: (id, width) => {
dispatch(createResizeAction(id, width))
}
}
}, null, {forwardRef: true}
)(WindowComponent)
</code></pre>
</section>
<section class="main-section" id="Drum_Machine">
<header>Drum Machine</header>
<p>paragraph 1</p>
<p>paragraph 2</p>
<code>code section</code>
<ul><li>list element</li></ul>
</section>
<section class="main-section" id="Pomodoro_Clock">
<header>Pomodoro Clock</header>
<p>At this point I still hadn't implented any state managment with Redux. I struggled to understand the API and the information within the course work was so bare bones that it really just pointed in a direction and expected me to go and do further research. </p>
<p>I set about to pick up the pieces I had been ignoring in the previsous projects. It was in this phase when the API finally clicked for me. I think it finally clicked for me when I was reading on Higher Order Compoents (HOC) as it relates to currying and all of a sudden the React.Component.connect method made sense to me. It was the result of this that I was able to use the connect method to create HOCs that I could configure through the state object. Below is an example of one such HOC. </p>
<pre><code>
const TimingButton = (props)=>{
let className = "fa-"+props.label+"-circle"
return(
<button className="button lengthButton "
id={props.name}
disabled={props.timing}
onClick={props.action}>
<i className={"fas " + className}></i>
</button>
)};
const SessionDecrementButton = connect(
state =>({timing: state.timing, label: "minus"}),
dispatch => ({action: () => { dispatch({type:DEC_SESSION})}})
)(TimingButton)
const SessionIncrementButton = connect(
state =>({timing: state.timing, label: "plus"}),
dispatch => ({action: () => { dispatch({type:INC_SESSION})}})
)(TimingButton)
</code></pre>
<p>As you can see the TimingButton is wrapped by the HOC generated by the connect function which ties a specific dispatch to the clicking of the button. </p>
<p>as well as optimizing the my Component connections to Redux to minimize component updates. </p>
<ul><li>list element</li></ul>
</section>
<section class="main-section" id="Calculator">
<header>Calculator</header>
<p>paragraph 1</p>
<p>paragraph 2</p>
<code>code section</code>
<ul><li>list element</li></ul>
</section>
</main>
</body>
<script src="https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js"></script>
<script>
window.onload = () => {
document.getElementById("main-doc").scrollTo(1,1);
}
</script>
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.1/styles/default.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.1/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
body,
html {
margin: 0px;
height: 100%;
font-family: "Raleway", sans-serif;
touch-action: manipulation;
font-family: 'Open Sans', sans-serif;
overflow: hidden;
}
.backgroundImage {
height: 100%;
width: 100%;
position: fixed;
top: 0;
left: 0;
z-index: -3;
}
.backgroundOverlay {
height: 100%;
width: 100%;
position: fixed;
top: 0;
left: 0;
z-index: -2;
}
nav {
position: fixed;
top: 0;
left: 0;
right: 0;
display: flex;
flex-direction: column;
z-index: 10;
background-color: white;
color: var(--shade1);
}
header {
font-size: 30px;
}
nav > header {
padding-left: 45px;
}
nav > div {
overflow-x: scroll;
height: 100px;
border-radius: 10px;
padding-left: 15px;
padding-right: 15px;
margin-right: 2px;
margin-left: 2px;
font-size: 18pt;
box-shadow: inset 0 0 5px rgba(0, 0, 0, .8);
line-height: 2.1em
}
nav > div > a{
color: var(--shade1);
text-decoration: none;
}
nav > div > a:hover {
color: rgba(255, 255, 255, .3);
}
.nav-space {
height: 2px;
width: 100%;
align-self: center;
background-color: var(--shade1);
}
.outerDiv {
height: calc(99% - 150px);
margin: 150px 5px 2px 5px ;
overflow-x: scroll;
padding-left: .5em;
padding-right: .5em;
background-color: var(--background1);
}
.outerDiv header {
color: var(--shade2);
}
.outerDiv p {
font-size: 20px;
}
.outerDiv code {
background-color: var(--background2);
display: block;
padding: 2px 5px 2px 5px;
border: 1px solid rgba(0, 0, 0, .2);
}
.outerDiv li {
}
.formContainer {
background:rgba(255,255,255,0.8);
font-size: 1.5em;
color: var(--textShade);
}
@media (min-width: 818px){
.outerDiv {
height: 100%;
margin: 2px 5px 2px 300px;
}
nav{
right: auto;
width: 290px;
height: 100%;
padding-left: 5px;
}
nav > header {
padding-left: 5px;
margin-top: 33px;
}
nav > div {
height: auto;
font-size: 20px;
box-shadow: none;
}
}
.themeOne {
--shade1: #f4f1af;
--shade2: #e7e283;
--shade3: #dbd55b;
--shade4: #dedede;
--textShade: #385a6e;
}
.themeFour {
--shade1: #e6e6e6;
--shade2: #dedede;
--shade3: #d1d1d1;
--shade4: #c7c7c7;
--grey1: #dedede;
}
.themeFive {
--shade1: #466b8c;
--shade2: #8c5f46;
--shade3: #8c8346;
--shade4: #79468c;
--background1: #dedede;
--background2: #f4f1af;
}
}
// !! IMPORTANT README:
// You may add additional external JS and CSS as needed to complete the project, however the current external resource MUST remain in place for the tests to work. BABEL must also be left in place.
/***********
INSTRUCTIONS:
- Select the project you would
like to complete from the dropdown
menu.
- Click the "RUN TESTS" button to
run the tests against the blank
pen.
- Click the "TESTS" button to see
the individual test cases.
(should all be failing at first)
- Start coding! As you fulfill each
test case, you will see them go
from red to green.
- As you start to build out your
project, when tests are failing,
you should get helpful errors
along the way!
************/
// PLEASE NOTE: Adding global style rules using the * selector, or by adding rules to body {..} or html {..}, or to all elements within body or html, i.e. h1 {..}, has the potential to pollute the test suite's CSS. Try adding: * { color: red }, for a quick example!
// Once you have read the above messages, you can delete all comments.
Also see: Tab Triggers