Skip to content

Instantly share code, notes, and snippets.

@robertuniqid
Created August 24, 2020 21:42
Show Gist options
  • Save robertuniqid/1126c0cab70117f4b73b1cb437806bc9 to your computer and use it in GitHub Desktop.
Save robertuniqid/1126c0cab70117f4b73b1cb437806bc9 to your computer and use it in GitHub Desktop.
eLearnCommerce - Sample Color Generator
let words = ' yes\n' +
' no\n' +
' maybe\n' +
' false\n' +
' true\n';
words = words.split( "\n" );
let c = {};
jQuery.each( words, function(index, word ) {
word = word.trim();
c[ word ] = ec_string_to_rgb( word );
});
jQuery( "body" ).append( '<div id="sample-colors"></div><style>#sample-colors { display:flex; flex-wrap:wrap;position: absolute;\n' +
'top: 0;\n' +
'left: 0;\n' +
'z-index: 999999; } #sample-colors > div { display : flex; align-content: center; justify-content: center;align-items: center; } </style>' );
jQuery.each( c, function( word, rgb ) {
jQuery( "#sample-colors" ).append( '<div style="width:120px;height:120px;background: rgb(' + rgb[0] + ',' + rgb[1] + ',' + rgb[2] + ')">' + word + '</div>' );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment