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 id="btn">
<p>click on grade level to randumly generate a realistic data</p>
<button id="k-b">K Begin</button>
<button id="k-e">K Middle+</button>
<button id="g1-m">G1</button>
<button id="g2-b">G2 Begin</button>
<button id="g2-e">G2 End</button>
</div>
<div id="power">
<button id="bookMagic">Book Magic</button>
<button id="inspiration">Inspiration</button>
<button id="mindReader">Mind Reader</button>
</div>
body {
padding: 0;
margin: 0;
}
@media screen and (max-height: 700px) {
body{
/* transform: scale(.7); */
}
}
canvas {
vertical-align: top;
}
#btn button {
font-size: 12pt;
position: relative;
display: inline;
width: 80pt;
height: 40pt;
padding: 3pt 5pt;
margin: 3pt;
line-height: 5pt;
background-color: #50E3C2;
border-radius: 100pt;
border: none;
}
#btn button:hover {
color: white;
background-color: #41D1BB;
}
#btn button:active {
background-color: #008575;
}
#btn {
width: 100%;
position: absolute;
bottom: 5%;
left: 10pt;
}
.skills {
font-size: 15pt;
width: 70pt;
height: 70pt;
background-color: #A0CC3A;
border-radius: 100pt;
border: none;
box-shadow: 0 4pt #7DA61F, inset 0 -2pt #7DA61F;
transform: translate(-35pt, -35pt);
}
.skills:hover {
color: #7DA61F;
}
.selected{
background-color: #fff;
border: 6pt solid #A0CC3A;
box-shadow: none;
}
.skills.inactive {
color: #E0E0A4;
background-color: #E9E9B8;
border: none;
box-shadow: none;
}
.skills.full {
color: #FFFFE4;
background-color: #AFDCBC;
border: none;
box-shadow: none;
}
.skills.full.selected{
color: #AFDCBC;
background-color: #FFFFE4;
border: 6pt solid #AFDCBC;
box-shadow: none;
}
#power {
position: absolute;
top: 10pt;
right: 10pt;
}
#power button {
font-size: 12pt;
position: relative;
display: inline;
width: 80pt;
height: 80pt;
padding: 3pt 5pt;
margin: 3pt;
line-height: 12pt;
border-radius: 100pt;
}
#power .selected {
border: 5pt solid;
}
#bookMagic {
color: #7C09FF;
background-color: #E2BAFF;
}
#bookMagic:hover {
color: white;
background-color: #CB98FF;
}
#bookMagic:active {
color: #CB98FF;
background-color: #7C09FF;
}
#inspiration {
color: #EB0076;
background-color: #FAC5D7;
}
#inspiration:hover {
color: white;
background-color: #F7ADC6;
}
#inspiration:active {
color: #F7ADC6;
background-color: #EB0076;
}
#mindReader {
color: #F23D00;
background-color: #F2C9A0;
}
#mindReader:hover {
color: white;
background-color: #F2B77C;
}
#mindReader:active {
color: #F2B77C;
background-color: #F23D00;
}
//the power button state is not fully implemented yet, it should act to be the same as skill buttons - tap again to deselect
//the background chart line state is not set up yet, some should be more transparent when the skill button is inactive
//!!!!!!!!!!!!!!!update: shouldn't divide skill states by grad level, should always be driven by data!!!!!!!!!!!!!!!!!!
var skill_num = 5//number of skill strings
var gap = 70;//gap between skill strings
var min_poly = 50;//size of the chart
var poly_num = 4;//number of pentagons
var highlight = null;
var currentPosition = null;
//skill values, 0 - 100
var ideas = 1; //alwas 0 for all K
var images = 1; //always 0 for K-BOY,MOY
var sounds = 1; //alwas 100 for G2
var letters = 1; //alwas 100 for G2-EOY
var words = 1; //always active
var kb = document.getElementById("k-b");
var ke = document.getElementById("k-e");
var g1m = document.getElementById("g1-m");
var g2b = document.getElementById("g2-b");
var g2e = document.getElementById("g2-e");
var bookMagic = document.getElementById("bookMagic");
var inspiration = document.getElementById("inspiration");
var mindReader = document.getElementById("mindReader");
var skill_ideas = document.getElementsByClassName("skill_ideas");
var skill_images = document.getElementsByClassName("skill_images");
var skill_sounds = document.getElementsByClassName("skill_sounds");
var skill_letters = document.getElementsByClassName("skill_letters");
var skill_length;
var positions;
var skillBtns = [];
var powerType = null;
var powerStroke = null;
var powerFill = null;
//power buttons
bookMagic.onclick = power1;
inspiration.onclick = power2;
mindReader.onclick = power3;
//posibility of growth chart by grade level
kb.onclick = btnKB;
ke.onclick = btnKE;
g1m.onclick = btnG1M;
g2b.onclick = btnG2B;
g2e.onclick = btnG2E;
function btnKB() {
ideas = 0; //always 0
images = 0; //always 0
sounds = random(50);
letters = random(50);
words = random(50);
inactiveSkill([0,1], 0);
}
function btnKE() {
ideas = 0; //always 0
images = random(30, 100);
sounds = random(30, 100);
letters = random(30, 100);
words = random(30, 100);
inactiveSkill([1], 0);
}
function btnG1M() {
ideas = random(100);
images = random(100);
sounds = random(100);
letters = random(100);
words = random(100);
inactiveSkill();
}
function btnG2B() {
ideas = random(50);
images = random(50);
sounds = 100;//always 100
letters = random(50);
words = random(50);
inactiveSkill([2], 1);
}
function btnG2E() {
ideas = random(100);
images = random(100);
sounds = 100;//always 100
letters = 100;//always 100
words = random(100);
inactiveSkill([2, 3], 1);
}
function setup() {
createCanvas(windowWidth, windowHeight);
skill_length = gap * (poly_num - 1) + min_poly;
for (var i = 0; i < skill_num; i++) {
push();
skill_icon(i);
pop();
}
}
// function windowResized() {
// resizeCanvas(windowWidth, windowHeight);
// }
function draw() {
background(230);
noFill();
stroke(170, 203,94);
strokeWeight(2);
//pentagons
for (var i = 0; i < poly_num; i++) {
push();
polygon(i);
pop();
}
//skill strings
for (var i = 0; i < skill_num; i++) {
push();
skill_line(i);
pop();
}
//dynamic teal growth
push();
positions = myGrowth(images, ideas, sounds, letters, words);
pop();
//highlight skill
if(highlight !== null) {
powerType = null;
push();
stroke(125, 166,31);
strokeWeight(8);
skill_line(highlight);
//center dot
noStroke();
fill(125, 166,31);
ellipse(0,0,15,15);
//skill growth value
fill(65, 209, 178);
stroke(255);
strokeWeight(4);
skillPoint(highlight, 20);
pop();
} else {
}
//need to add deselect
if (powerType !== null){
highlight = null;
powerChart();
}
}
function inactiveSkill(skillIndexes, whichState){
highlight = null;
var skillStates = ['inactive', 'full', 'selected']
for (var i = 0; i < skill_num; i++) {
for (var j = 0; j < skillStates.length; j++){
skillBtns[i].removeClass(skillStates[j]);
}
}
for (var i = 0; i < skillIndexes.length; i++) {
skillBtns[skillIndexes[i]].addClass(skillStates[whichState]);
}
}
function power1(){
// bookMagic.addClass('selected');
powerStroke = color(124, 9,255);
powerFill = color(218, 186, 255, 125);
powerType = 0;
}
function power2(){
powerStroke = color(255, 47,127);
powerFill = color(255, 207, 223, 125);
powerType = 1;
}
function power3(){
powerStroke = color(254, 85,0);
powerFill = color(255, 201, 150, 125);
powerType = 2;
}
function powerChart(){
push();
stroke(powerStroke);
strokeWeight(4);
fill(powerFill);
polygon(powerType);
pop();
}
function skill_icon(r) {
var angel = TWO_PI / skill_num * r;
var x = (skill_length + gap/3) * sin(angel) * -1 + width/2;
var y = (skill_length + gap/3) * cos(angel) * -1 + height/2;
var skillNameArray = ["images","ideas","sounds","letters","words"]
var currentButton = createButton(skillNameArray[r]);
currentButton.position(x, y);
currentButton.addClass('skills');
currentButton.mousePressed(selectSkill);
skillBtns.push(currentButton);
function selectSkill(){
if (!skillBtns[r].elt.classList.contains('inactive')) {
if (r == currentPosition) {
highlight = null;
currentPosition = null;
skillBtns[r].removeClass('selected');
} else {
highlight = r;
currentPosition = r;
skillBtns[r].addClass('selected');
removeState(r);
}
}
}
}
function removeState(notThisOne) {
for (var i=0;i<skill_num;i++) {
if (i != notThisOne) {
skillBtns[i].removeClass('selected');
}
}
}
function skillPoint(skillN, d) {
var x = positions[skillN][0];
var y = positions[skillN][1];
ellipse(x,y,d,d);
}
function myGrowth(g1, g2, g3, g4, g5){
var angel = TWO_PI / skill_num;
var gArray = [g1, g2, g3, g4, g5];
var mgArray = [];
for (i = 0; i < skill_num; i++) {
mgArray.push(map(gArray[i], 0, 100, 0, skill_length));
}
beginShape();
fill(80, 227, 194, 200);
stroke(33, 182, 160);
translate(width*0.5, height*0.5);
var xyPositions = [];
for (i = 0; i < skill_num; i++) {
var x = mgArray[i] * sin(angel * i) * -1;
var y = mgArray[i] * cos(angel * i) * -1;
vertex(x, y);
var mgXY = [x,y];
xyPositions.push(mgXY);
}
endShape(CLOSE);
return xyPositions;
}
function skill_line(r){
var angel = TWO_PI / skill_num * r;
var l = skill_length;
var lx = l * sin(angel) * -1;
var ly = l * cos(angel) * -1;
translate(width/2, height/2);
line (0,0,lx,ly);
}
function polygon(poly_line) {
//need to seprate each line of the shape for inactive skills
var x = 0;
var y = 0;
var radius = min_poly + gap * poly_line;
var angle = TWO_PI / skill_num;
beginShape();
translate(width*0.5, height*0.5);
for (var a = 0; a < TWO_PI; a += angle) {
var sx = x + cos(a) * radius;
var sy = y + sin(a) * radius;
vertex(sx, sy);
}
rotate(HALF_PI * -1);
endShape(CLOSE);
}
Also see: Tab Triggers