|
@@ -94,6 +94,15 @@ U.element("targetSelect", ({ randomButton }, form) => {
|
|
|
randomButton.addEventListener("click", randomizeTargetColor);
|
|
|
});
|
|
|
|
|
|
+const getColorButtonStyle = (hex) => {
|
|
|
+ const { h, s, l } = d3.hsl(hex);
|
|
|
+ return `
|
|
|
+ color: ${getContrastingTextColor(hex)};
|
|
|
+ --button-bg: ${hex};
|
|
|
+ --button-bg-hover: ${d3.hsl(h, s, clamp(0.25, l * 1.25, 0.9)).formatHex()};
|
|
|
+ `;
|
|
|
+};
|
|
|
+
|
|
|
targetColor.subscribe((hex, { previous }) => {
|
|
|
const style = document.querySelector(":root").style;
|
|
|
style.setProperty("--background", hex);
|
|
@@ -102,19 +111,13 @@ targetColor.subscribe((hex, { previous }) => {
|
|
|
if (previous) {
|
|
|
const prevButton = document.createElement("button");
|
|
|
prevButton.innerText = previous;
|
|
|
- const { h, s, l } = d3.hsl(previous);
|
|
|
- prevButton.style = `
|
|
|
- color: ${getContrastingTextColor(previous)};
|
|
|
- --button-bg: ${previous};
|
|
|
- --button-bg-hover: ${d3.hsl(h, s, clamp(0.25, l * 1.25, 0.9)).formatHex()};
|
|
|
- `;
|
|
|
+ prevButton.classList = "color-select";
|
|
|
+ prevButton.style = getColorButtonStyle(previous);
|
|
|
prevButton.addEventListener("click", () => (targetColor.value = previous));
|
|
|
document.getElementById("prevColors").prepend(prevButton);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
-randomizeTargetColor();
|
|
|
-
|
|
|
// ---- Metric Controls ----
|
|
|
function addMetricForm(formName, legendText, initialKind, initialMetric, mountPoint) {
|
|
|
const metricKind = U.obs(initialKind);
|
|
@@ -252,3 +255,5 @@ U.reactive(() => {
|
|
|
sortUseInverseClusterSize.value,
|
|
|
].every((v) => !v);
|
|
|
});
|
|
|
+
|
|
|
+randomizeTargetColor();
|