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.
<div class="container">
<h1 class="page-header">So, you want to hire a web person.</h1>
<p class="lead">This is a nice form to help you accurately communicate the role you are hiring for, and to help you articulate the needs within your company.</p>
<h3>Title Calculator</h3>
<form action="" id="jobTitlesForm">
<ol>
<li id="generalistLogic">
<h4>Are you hiring for a very specific role?</h4>
<div class="help-block">e.g. for performance improvements (specific) vs. front-end developer (general)</div>
<div class="radio">
<label for="specialist">
<input name="generalist" id="specialist" type="radio"> Yes, specific role
</label>
</div>
<div class="radio">
<label for="generalist">
<input name="generalist" id="generalist" type="radio"> No, they will do lots of things
</label>
</div>
</li>
<li id="expLevel">
<h4>What is the paygrade?</h4>
<div class="radio">
<label for="entryLevel">
<input value="Junior" name="level" id="entryLevel" type="radio"> < $50k
</label>
</div>
<div class="radio">
<label for="midLevel">
<input value="Mid-Level" name="level" id="midLevel" type="radio"> $50k - $90k
</label>
</div>
<div class="radio">
<label for="seniorLevel">
<input value="Senior" name="level" id="seniorLevel" type="radio"> $90k +
</label>
</div>
</li>
<li id="designerBool">
<h4>What skills does this role mainly require?</h4>
<div class="radio">
<label for="designerTrue">
<input name="designer" id="designerTrue" type="radio"> Design
</label>
</div>
<!-- Should there be another option here? Hybrid? Strategist? -->
<div class="radio">
<label for="designerFalse">
<input name="designer" id="designerFalse" type="radio"> Development
</label>
</div>
</li>
<li id="chooseSkillSet">
<h4>Select the skill set that best describes the role.</h4>
<select name="skillSetSelect" class="form-control" id="skillSetSelect">
<!-- List generated based on above selections -->
</select>
</li>
</ol>
</form>
<!-- /#jobTitleForm -->
<div class="well">
<small class="text-uppercase">Job Title</small>
<h3>
<span class="greyed" id="generalistResult"></span>
<span id="expLevelResult"></span>
<span id="skillsResult"></span>
<span id="designerResult"></span>
</h3>
</div>
<h3>Description Calculator</h3>
<form action="" id="jobDescriptionForm">
<h4>What's in your stack?</h4>
<p>[some kind of picker here, options determined by above answers]</p>
<h4>Describe three specific, example tasks the candidate is expected to do.</h4>
<div class="help-block">
<p><strong>Bad: </strong>Enhance our UI with JavaScript.</p>
<p><strong>Good:</strong> Our site has a rotating feed of tweets from live events. We want it to be so that the most recent tweet shows as soon as it is posted rather than added to the end of the queue.</p>
</div>
<textarea type="text" rows="3" class="form-control" id="task"></textarea>
<h4>Link to a file of code or a repo the new hire would be working with.</h4>
<p class="help-block">This will give candidates a good idea of the desired level of skill in a specific language.</p>
<input type="text" class="form-control">
<h4>Company Information</h4>
<p class="help-block">Describe what your company does, its culture, and work environment. Keep the corporate fluff to a minimum.</p>
<textarea type="text" rows="3" class="form-control" id="companyInfo"></textarea>
</form>
<!-- /#jobDescriptionForm -->
<div class="well">
<small class="text-uppercase">Description</small>
</div>
</div>
<!-- /container -->
body {
margin-bottom: 30px;
}
h4 {
margin-top: 30px;
}
.container {
max-width: 700px;
}
.greyed {
color: #999;
}
form {
margin-bottom: 30px;
}
var skillSetArr = [];
// Storing some data
var skills = {
designer: {
general: ["Product", "Front-end", "Visual"],
special: ["IA", "UX", "Graphic", "Content", "Animation"]
},
developer: {
general: ["Front-end", "Back-end"],
special: ["AngularJS", "WordPress", "Rails", "Django"]
}
}
// Job Title Constructor Object Thing
// Designer/hybrid/dev needs to be consolidated into one value
var JobTitle = function(isDesigner, isHybrid, isDeveloper, expLevel, isGeneralist, skillSet) {
this.isDesigner = isDesigner;
this.isDesigner = isHybrid;
this.isDeveloper = isDeveloper;
this.expLevel = expLevel;
this.isGeneralist = isGeneralist;
this.skillSet = skillSet;
}
// Update the skills array with some spaghetti logic
// Ideally would only want this to run after the designer/dev question has been answered, I think.
JobTitle.prototype.updateSkills = function() {
if (this.isDesigner) {
if (this.isGeneralist) {
updateSkillSet(skills.designer.general);
} else {
updateSkillSet(skills.designer.special);
}
} else if (this.isHybrid) {
updateSkillSet(skills.hybrid);
} else {
if (this.isGeneralist) {
updateSkillSet(skills.developer.general);
} else {
updateSkillSet(skills.developer.special);
}
}
}
// Function to run various callbacks when associated field changes
JobTitle.prototype.onFieldChange = function(fieldId, callback) {
var field = document.getElementById(fieldId);
// Update each field with the callback when it changes
// Oh, wow, is this a closure IRL? Nice work, Larv.
field.addEventListener('change', function(e) {
return function() {
callback.apply(); // Do I need apply here?
title.updateSkills.apply();
}
}(this));
}
// Create the job title object
var title = new JobTitle();
// Update each field when it changes
// Not great ID names, fwiw
// This could be more concise, probably
title.onFieldChange("designerBool", updateDesigner);
title.onFieldChange("generalistLogic", updateGeneralist);
title.onFieldChange("expLevel", updateExpLevel);
// --
// Updater Functions
// --
// Are they super spaghetti?
// Logic for designer
// Is there a way to not hardcode these form values?
function updateDesigner() {
updateResult("skillsResult", "");
// Update the job title text and set a variable
if (document.getElementById("designerTrue").checked) {
this.isHybrid = false;
this.isDesigner = true;
this.isDeveloper = false;
document.getElementById("designerResult").innerHTML = "Designer";
} else if (document.getElementById("designerFalse").checked) {
this.isHybrid = false;
this.isDeveloper = true;
this.isDesigner = false;
document.getElementById("designerResult").innerHTML = "Developer";
} else if (document.getElementById("designerHybrid").checked) {
this.isDeveloper = true;
this.isDesigner = false;
this.isHybrid = true;
document.getElementById("designerResult").innerHTML = "Hybrid";
}
}
// Generalist Logic
function updateGeneralist() {
updateResult("skillsResult", "");
if (document.getElementById("generalist").checked) {
// Update the job title
this.isGeneralist = true;
updateResult("generalistResult", "Generalist");
} else if (document.getElementById("specialist").checked) {
// Update the job title
this.isGeneralist = false;
updateResult("generalistResult", "Specialist");
}
}
// Update the experience level
function updateExpLevel() {
var container = document.getElementById("expLevel");
var radios = container.querySelectorAll('input'); // Get all radios
for (var i = 0; i < radios.length; i++) {
if (radios[i].checked) {
updateResult("expLevelResult", radios[i].value);
}
};
}
// Update the dropdown according to array of skills defined about
function updateSkillSet(skillSetArr) {
// Clear the options - cleaner way to do this?
var skillSelect = document.getElementById("skillSetSelect");
skillSelect.innerHTML = '';
// Add one blank option
var defaultOption = document.createElement('option');
defaultOption.text = defaultOption.value = "Select a Skill";
skillSelect[skillSelect.options.length] = new Option("Select a Skill");
// Create new options for each skill in array
for (var i = 0; i < skillSetArr.length; i++) {
var option = document.createElement('option');
option.text = option.value = skillSetArr[i];
skillSelect[skillSelect.options.length] = new Option(skillSetArr[i]);
var val = skillSetArr[i];
var opts = skillSelect.options;
};
// Update the job title text when the selection is made
skillSelect.addEventListener('change', function() {
var value = skillSelect[skillSelect.selectedIndex].value;
updateResult("skillsResult", value);
});
}
// Utility function to replace innerHTML of results
// Is this abstracting more than necessary?
function updateResult(id, text) {
document.getElementById(id).innerHTML = text;
}
Also see: Tab Triggers