A Pen by Joe Graham on CodePen.
Created
June 10, 2017 04:26
-
-
Save anonymous/0d5b013b1cf5d9e2cdbbe194cd27e414 to your computer and use it in GitHub Desktop.
xrZBGQ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="colorbars"></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const bgcolors = [ | |
[ | |
'#0000cc', | |
'#0000ff', | |
'#0066ff', | |
'#3399ff', | |
'#66ccff' | |
], | |
[ | |
'#800000', | |
'#ff0000', | |
'#ff6600', | |
'#ff751a', | |
'#ff8533' | |
], | |
[ | |
'#003300', | |
'#006600', | |
'#009900', | |
'#00cc00', | |
'#00ff00' | |
] | |
]; | |
const createElem = (elemName) => { | |
return document.createElement(elemName); | |
}; | |
const createColumn = () => { | |
return createElem('span'); | |
}; | |
const createRow = () => { | |
return createElem('div'); | |
} | |
const setupRows = ({columnElement, bgColor}) => { | |
const rowElement = createRow(); | |
rowElement.style.backgroundColor = bgColor; | |
rowElement.className = 'rowitem'; | |
columnElement.appendChild(rowElement); | |
}; | |
const setupCols = (colData) => { | |
const colorbarsDiv = document.querySelector('#colorbars'); | |
const columnElement = createColumn(); | |
columnElement.className = 'colitem'; | |
colorbarsDiv.appendChild(columnElement); | |
_.forEach(colData, (bgColor) => { | |
setupRows({ columnElement, bgColor }); | |
}); | |
}; | |
const setupGrid = () => { | |
_.forEach(bgcolors, setupCols); | |
}; | |
setupGrid(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.min.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#colorbars { | |
margin-top: 1%; | |
margin-left: 5%; | |
width: 600px; | |
height: 250px; | |
display: flex; | |
flex-direction: row; | |
} | |
.colitem { | |
display: flex; | |
flex-direction: column; | |
flex-grow: 1; | |
margin-left: 5%; | |
} | |
.rowitem { | |
flex-grow: 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://codepen.io/josgraha/pen/xrZBGQ