Skip to content

Instantly share code, notes, and snippets.

@outoftime
Last active March 12, 2018 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save outoftime/d2974fd96e3d8e0861322ad76cfca099 to your computer and use it in GitHub Desktop.
Save outoftime/d2974fd96e3d8e0861322ad76cfca099 to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=d2974fd96e3d8e0861322ad76cfca099
<!DOCTYPE html>
<html>
<head>
<title>Color Picker</title>
</head>
<body>
<h2>Click a color</h2>
<div class="color-pickers">
<div class="color-picker" id="red"></div>
<div class="color-picker" id="blue"></div>
<div class="color-picker" id="yellow"></div>
<div class="color-picker" id="green"></div>
<div class="color-picker" id="orange"></div>
</div>
</body>
</html>

Color Picker

Step 1: Drill

Using the provided starter HTML and CSS, make a color picker tool that works like this.

When you have finished this step, submit a snapshot.

Step 2: Brevity

Now a new challenge: change your code so that it works the same, but only contains the word click one time.

You should end up with about six lines of JavaScript code. (There is no specific rule about this, though)

Submit again.

Spicy Bonus

Delete all the .color-picker <div> tags from the HTML. Add them back in with JavaScript.

{"enabledLibraries":["jquery"],"hiddenUIComponents":["console", "editor.css"]}
h2 {
text-align: center;
}
.color-pickers {
display: flex;
height: 20vh;
}
.color-picker {
flex: 0 1 100%;
cursor: pointer;
}
#red {
background-color: red;
}
#blue {
background-color: blue;
}
#yellow {
background-color: yellow;
}
#green {
background-color: green;
}
#orange {
background-color: orange;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment