Skip to content

Instantly share code, notes, and snippets.

@mk30
Created May 11, 2017 21:37
Show Gist options
  • Save mk30/b82cdc284d46e800cfcbf5c59d9a0034 to your computer and use it in GitHub Desktop.
Save mk30/b82cdc284d46e800cfcbf5c59d9a0034 to your computer and use it in GitHub Desktop.
function colors (onclick) {
var pkeys = Object.keys(state.paletteMap)
var prows = []
for (var i = 0; i < pkeys.length; i += 10) {
prows.push(pkeys.slice(i,i+10))
}
return html`<div class="colors">
${prows.map(function (row) {
return html`<div>
${row.map(function (src) {
var dst = state.paletteMap[src]
return html`<button style="background-color:#${dst}"
class=${dst === state.activeColor ? 'selected' : ''}
onclick=${function (ev) { onclick(dst,ev) }}></button>`
})}
</div>`
})}
</div>`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment