Created
June 10, 2017 04:26
-
-
Save anonymous/0d5b013b1cf5d9e2cdbbe194cd27e414 to your computer and use it in GitHub Desktop.
Revisions
-
There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ <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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,58 @@ 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ <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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ #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; } 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ xrZBGQ ------ A [Pen](https://codepen.io/josgraha/pen/xrZBGQ) by [Joe Graham](http://codepen.io/josgraha) on [CodePen](http://codepen.io/). [License](https://codepen.io/josgraha/pen/xrZBGQ/license).