#color-compare-space.disabled
#color-compare-close
.horizontal-compare
.color.first-color(onclick="displayCopyPaste(this)")
.color.second-color(onclick="displayCopyPaste(this)")
.color.third-color(onclick="displayCopyPaste(this)")
.vertical-compare
.color.first-color(onclick="displayCopyPaste(this)")
.color.second-color(onclick="displayCopyPaste(this)")
.color.third-color(onclick="displayCopyPaste(this)")
#nav-block
nav#collection-space
p Saved
p#clear(onclick="clearColors()") clear
header
button#nav-btn
#nav-image
label(for="nav-btn") SAVED
a#logo(href="#") SUPER
span.orange
| RANDOM
span.red
| COLOR
| GENERATOR
.holder()
#save-button(onclick="saveColors()")
| Save Colors
.colored(onclick="generator()")
.colored(onclick="generator()" id="first" data-first="true")
div
| Click here to generate color
.colored(onclick="generator()")
View Compiled
@import url(https://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700);
* {
box-sizing: border-box;
}
body {
width: 100vw;
min-height: 100vh;
overflow: hidden;
font-family: 'Open Sans';
position: relative;
z-index: 0;
display: block;
transition: transform 0.35s ease-in-out;
}
body.active {
transform: translateX(270px);
}
header {
height: 75px;
max-height: 75px;
width: 100vw;
background-color: #e9e9e9;
display: flex;
flex-direction: row;
position: fixed;
z-index: 10;
box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.5);
}
header #logo {
font-weight: 600;
font-size: 30px;
text-align: center;
width: 100%;
margin: 0;
margin-top: 15px;
color: #34495e;
align-self: baseline;
text-decoration: none;
}
header #logo .orange {
color: #e67e22;
}
header #logo .red {
color: #e74c3c;
}
.holder {
height: 100vh;
padding-top: 75px;
width: 100vw;
display: block;
position: relative;
overlow: hidden;
z-index: 2;
bottom: 0;
left: 0;
right: 0;
background-color: #f39c12;
}
.holder #save-button {
height: 40px;
width: 200px;
font-size: 20px;
color: white;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
position: absolute;
z-index: 9;
top: 75px;
cursor: cell;
}
.holder .colored {
width: 100%;
height: 33.33%;
color: rgba(255, 255, 255, 0.35);
background-color: #f39c12;
font-size: 55px;
position: relative;
z-index: 3;
cursor: pointer;
font-size: 45px;
color: rgba(255, 255, 255, 0.3);
font-weight: 300;
display: flex;
flex-direction: column;
justify-content: center;
-ms-align-items: center;
align-items: center;
box-shadow: 0px 0px 10px transparent;
transition: color 0.25s, transform 0.25s ease-in-out, box-shadow 0.3s ease-in-out, background-color 0.5s;
}
.holder .colored::selection {
background-color: transparent;
}
.holder .colored:hover {
z-index: 4;
color: white;
transform: scale(1.1);
transition: color 0.25s, transform 0.25s ease-in-out, box-shadow 0.3s ease-in-out;
box-shadow: 0px 0px 25px rgba(0, 0, 0, 0.5);
}
#nav-btn {
float: left;
vertical-align: baseline;
}
label[for="nav-btn"] {
float: left;
vertical-align: baseline;
font-size: 20px;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
cursor: pointer;
}
#nav-btn {
height: 40px;
width: 40px;
border: 0;
outline: 0;
align-self: baseline;
top: -8px;
position: relative;
z-index: 10;
background-color: #e9e9e9;
margin-top: 8px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
cursor: pointer;
border-radius: 30px;
}
#nav-btn:active,
#nav-btn:focus {
border: 0;
ouline: 0;
}
#nav-btn #nav-image {
height: 2px;
width: 30px;
background-color: #111;
position: relative;
display: block;
transition: 0.2s ease-in-out;
}
#nav-btn #nav-image::after,
#nav-btn #nav-image::before {
transition: 0.2s ease-in-out;
position: absolute;
content: ' ';
background-color: #111;
height: 2px;
width: 30px;
display: block;
}
#nav-btn #nav-image::after {
top: 10px;
left: 0;
right: 0;
}
#nav-btn #nav-image::before {
height: 2px;
top: -10px;
left: 0;
right: 0;
}
#nav-btn.active #nav-image {
transition: 0.2s ease-in-out;
background-color: rgba(255, 255, 255, 0);
}
#nav-btn.active #nav-image::after {
top: 0;
transform: rotateZ(45deg);
transition: 0.2s ease-in-out;
}
#nav-btn.active #nav-image::before {
top: 0;
transform: rotateZ(-45deg);
transition: 0.2s ease-in-out;
}
#nav-block {
width: 270px;
height: 100vh;
background-color: #e9e9e9;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
position: fixed;
overflow-y: scroll;
overflow-x: hidden;
text-transform: uppercase;
left: -270px;
top: 0;
z-index: 20;
box-shadow: inset -10px 0px 15px rgba(0, 0, 0, 0.2);
}
#nav-block::-webkit-scrollbar {
width: 5px;
height: 5px;
background-color: transparent;
background-position: center right;
background-repeat: no-repeat;
background-size: cover;
opacity: 0;
transition: 0.4s ease;
}
#nav-block::-webkit-scrollbar-track {
background-color: transparent;
-webkit-box-shadow: inset 0 0 6px transparent;
}
#nav-block::-webkit-scrollbar-thumb {
background-color: #777;
transition: opacity 0.3s ease;
border-radius: 5px;
}
#nav-block::-webkit-scrollbar-thumb:hover {
transition: opacity 0.3s ease;
background-color: #ccc;
}
#nav-block nav {
width: 100%;
display: block;
position: relative;
}
#nav-block nav p {
font-size: 25px;
text-align: center;
font-weight: 600;
color: #333;
}
#nav-block nav p#clear {
color: #777;
font-size: 20px;
cursor: pointer;
}
#nav-block nav .collection {
width: 100%;
height: 55px;
color: white;
position: relative;
margin: 0 auto;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
#nav-block nav .collection .color,
#nav-block nav .collection .display-palette {
padding: 15px;
height: 35px;
width: 35px;
position: relative;
display: block;
float: left;
margin: 5px;
transition: margin 0.25s;
cursor: pointer;
color: transparent;
border-radius: 25px;
}
#nav-block nav .collection .color:hover,
#nav-block nav .collection .display-palette:hover {
margin: 0px 10px 0px 10px;
transform: scale(1.1);
}
#nav-block nav .collection .display-palette {
background-color: #fff;
width: 50px;
color: #c9c9c9;
font-weight: 700;
padding: 7px;
text-align: center;
}
@media (max-width: 768px) {
label[for="nav-btn"] {
display: none !important;
}
header {
height: 50px;
}
header #logo {
font-size: 15px !important;
}
}
#color-compare-space {
width: 100vw;
min-height: 100vh;
display: block;
position: absolute;
z-index: 25;
opacity: 1;
pointer-events: auto;
background-color: rgba(255, 255, 255, 0.75);
transition: all 0.2s;
}
#color-compare-space.disabled {
opacity: 0;
pointer-events: none;
}
#color-compare-space #color-compare-close {
position: fixed;
width: 35px;
height: 35px;
top: 20px;
left: 20px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
cursor: pointer;
}
#color-compare-space #color-compare-close::after,
#color-compare-space #color-compare-close::before {
width: 35px;
height: 2px;
content: '';
position: absolute;
background-color: #222;
display: block;
transition: transform 0.15s;
}
#color-compare-space #color-compare-close::after {
transform: rotateZ(45deg);
}
#color-compare-space #color-compare-close::before {
transform: rotateZ(-45deg);
}
#color-compare-space #color-compare-close:hover::after {
transform: rotateZ(45deg) scale(1.35);
}
#color-compare-space #color-compare-close:hover::before {
transform: rotateZ(-45deg) scale(1.35);
}
#color-compare-space .horizontal-compare {
width: 80vw;
margin: 20px 10vw;
height: 30vh;
background-color: transparent;
position: relative;
display: flex;
flex-wrap: nowrap;
flex-direction: row;
}
#color-compare-space .horizontal-compare .color {
width: 33%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin: 0;
padding: 0;
color: white;
font-size: 25px;
}
#color-compare-space .vertical-compare {
width: 80vw;
margin: 20px 10vw;
height: 50vh;
background-color: transparent;
position: relative;
display: flex;
flex-wrap: nowrap;
flex-direction: column;
}
#color-compare-space .vertical-compare .color {
width: 100%;
height: 32%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
#color-compare-space .color {
margin: 0;
padding: 0;
color: white;
font-size: 25px;
transition: transform 0.35s;
cursor: pointer;
}
#color-compare-space .color:hover {
transform: scale(1.025);
}
function generator() {
var colorBlocks = document.getElementsByClassName("colored"),
superRandomCharacters = '1234567890abcdef'.split(''),
superRandomColor = function() {
var color = "#";
for (var i = 0; i < 6; i++)
color += superRandomCharacters[Math.floor(Math.random() * 16)];
return color;
},
random = [superRandomColor(), superRandomColor(), superRandomColor()];
for (var i = 0; i < colorBlocks.length; i++) {
colorBlocks[i].style.backgroundColor = random[i];
colorBlocks[i].innerHTML = random[i];
}
var firstColor = _("first");
firstColor.dataset.first = false;
}
window.onload = function() {
var navBtn = _("nav-btn"),
navBlock = _("nav-block"),
colorCompareSpace = _("color-compare-space"),
colorCompareClose = _("color-compare-close"),
body = document.body;
navBtn.addEventListener("click", function() {
toggleClass(navBtn, "active");
toggleClass(navBlock, "active");
toggleClass(body, "active");
});
colorCompareClose.addEventListener("click", function() {
toggleClass(colorCompareSpace, "disabled");
});
}
function displayCopyPaste(div) {
var colorValue = div.innerHTML;
window.prompt("Copy and press Enter", colorValue)
}
function displayPalette(div) {
var displaySpace = _("color-compare-space");
displaySpace.className = "";
var navBtn = _("nav-btn"),
navBlock = _("nav-block"),
body = document.body;
toggleClass(navBtn, "active");
toggleClass(navBlock, "active");
toggleClass(body, "active");
var collectionArray = div.parentElement.children;
var elColorH = collectionArray[1].innerHTML,
elColorH2 = collectionArray[2].innerHTML,
elColorH3 = collectionArray[3].innerHTML;
var elColorArrayHex = [elColorH, elColorH2, elColorH3];
var elColorR = collectionArray[1].style.backgroundColor,
elColorR2 = collectionArray[2].style.backgroundColor,
elColorR3 = collectionArray[3].style.backgroundColor;
var elColorArrayRgb = [elColorR, elColorR2, elColorR3];
var first = document.getElementsByClassName("first-color"),
second = document.getElementsByClassName("second-color"),
third = document.getElementsByClassName("third-color");
for (i = 0; i < first.length; i++) {
first[i].style.backgroundColor = elColorArrayRgb[0];
first[i].innerHTML = elColorArrayHex[0];
}
for (i = 0; i < second.length; i++) {
second[i].style.backgroundColor = elColorArrayRgb[1];
second[i].innerHTML = elColorArrayHex[1];
}
for (i = 0; i < third.length; i++) {
third[i].style.backgroundColor = elColorArrayRgb[2];
third[i].innerHTML = elColorArrayHex[2];
}
}
var collections = []
function saveColors() {
var colorBlocks = document.getElementsByClassName("colored"),
colSpace = _("collection-space"),
firstColor = _("first");
var color1 = colorBlocks[0].textContent,
color2 = colorBlocks[1].textContent,
color3 = colorBlocks[2].textContent;
if (firstColor.dataset.first != "true") {
collections.push({
collection: [color1, color2, color3]
});
console.log(collections);
var collectionBlock = document.createElement('div');
collectionBlock.className = "collection";
var color = document.createElement('div');
color.className = "color";
color.setAttribute("onclick", "displayCopyPaste(this)");
var color2 = document.createElement('div');
color2.className = "color";
color2.setAttribute("onclick", "displayCopyPaste(this)");
var color3 = document.createElement('div');
color3.className = "color";
color3.setAttribute("onclick", "displayCopyPaste(this)");
var displayPaletteBlock = document.createElement('div');
displayPaletteBlock.className = "display-palette";
displayPaletteBlock.setAttribute("onclick", "displayPalette(this)");
displayPaletteBlock.innerHTML = "all";
for (i = 0; i < collections.length; i++) {
colSpace.appendChild(collectionBlock);
//cN = colorName
for (cN = 0; cN < collections[i].collection.length; cN++) {
color.innerHTML = collections[i].collection[0];
color.style.backgroundColor = collections[i].collection[0];
color2.innerHTML = collections[i].collection[1];
color2.style.backgroundColor = collections[i].collection[1];
color3.innerHTML = collections[i].collection[2];
color3.style.backgroundColor = collections[i].collection[2];
}
collectionBlock.appendChild(displayPaletteBlock);
collectionBlock.appendChild(color);
collectionBlock.appendChild(color2);
collectionBlock.appendChild(color3);
}
}
}
//Just a helpful function.
function _(el) {
return document.getElementById(el);
}
//A function to clear colors off in the saves column
function clearColors() {
var colSpace = _("collection-space");
colSpace.innerHTML = "<p>Saved</p><p id='clear' onclick='clearColors()'>clear</p>";
collections = []
}
function toggleClass(el, _class) {
if (el && el.className && el.className.indexOf(_class) >= 0) {
var pattern = new RegExp('\\s*' + _class + '\\s*');
el.className = el.className.replace(pattern, ' ');
} else if (el) {
el.className = el.className + ' ' + _class;
} else {
console.log("Element not found :(")
}
}
This Pen doesn't use any external CSS resources.