|
|
@ -1,11 +1,18 @@ |
|
|
|
|
|
|
|
const { getColor } = require('./themes') |
|
|
|
const { qs } = require('../utils') |
|
|
|
const { qs } = require('../utils') |
|
|
|
|
|
|
|
|
|
|
|
module.exports = function initButtons (input) { |
|
|
|
module.exports = function initButtons (input) { |
|
|
|
let container = qs('#action-buttons') |
|
|
|
let container = qs('#action-buttons') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// current color palette
|
|
|
|
|
|
|
|
let palette = [] |
|
|
|
|
|
|
|
|
|
|
|
// button labels
|
|
|
|
// button labels
|
|
|
|
let labels = [] |
|
|
|
let labels = [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// button colors
|
|
|
|
|
|
|
|
let colors = {} |
|
|
|
|
|
|
|
|
|
|
|
// button elements
|
|
|
|
// button elements
|
|
|
|
let buttons = [] |
|
|
|
let buttons = [] |
|
|
|
|
|
|
|
|
|
|
@ -54,9 +61,15 @@ module.exports = function initButtons (input) { |
|
|
|
for (let i = 0; i < labels.length; i++) { |
|
|
|
for (let i = 0; i < labels.length; i++) { |
|
|
|
let label = labels[i].trim() |
|
|
|
let label = labels[i].trim() |
|
|
|
let button = buttons[i] |
|
|
|
let button = buttons[i] |
|
|
|
|
|
|
|
let color = colors[i] |
|
|
|
|
|
|
|
|
|
|
|
button.textContent = label || '\u00a0' // label or nbsp
|
|
|
|
button.textContent = label || '\u00a0' // label or nbsp
|
|
|
|
|
|
|
|
|
|
|
|
if (!label) button.classList.add('inactive') |
|
|
|
if (!label) button.classList.add('inactive') |
|
|
|
else button.classList.remove('inactive') |
|
|
|
else button.classList.remove('inactive') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Number.isFinite(color)) button.style.background = getColor(color, palette) |
|
|
|
|
|
|
|
else button.style.background = null |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -68,6 +81,20 @@ module.exports = function initButtons (input) { |
|
|
|
set labels (value) { |
|
|
|
set labels (value) { |
|
|
|
labels = value |
|
|
|
labels = value |
|
|
|
update() |
|
|
|
update() |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
get colors () { |
|
|
|
|
|
|
|
return colors |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
set colors (value) { |
|
|
|
|
|
|
|
colors = value |
|
|
|
|
|
|
|
update() |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
get palette () { |
|
|
|
|
|
|
|
return palette |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
set palette (value) { |
|
|
|
|
|
|
|
palette = value |
|
|
|
|
|
|
|
update() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|