Skip to content

AI turns documents or topics into real, native PowerPoint decks—with native shapes, transitions and animations, data-backed charts and tables on demand, audio narration from speaker notes, and support for your own .pptx templates. · by Hugo He

feat(confirm-ui): live swatch feedback for custom HEX color overrides

hugohe3a1d6ca4b4d19
diff --git a/skills/ppt-master/scripts/confirm_ui/static/app.js b/skills/ppt-master/scripts/confirm_ui/static/app.js
index b1f97c75..58f9b47b 100644
--- a/skills/ppt-master/scripts/confirm_ui/static/app.js
+++ b/skills/ppt-master/scripts/confirm_ui/static/app.js
@@ -500,12 +500,29 @@
var sec = section(5, "sec_color");
var grid = el("div", "color-grid");
var hexInputs = {};
-
+ var hexSwatches = {};
+ var cardSwatchRefs = []; // idx -> {role: swatchEl}, for live override feedback
+ var selectedIdx = -1;
+
+ function normHex(val) {
+ var v = (val || "").trim();
+ if (!/^#?([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(v)) return null;
+ return v.charAt(0) === "#" ? v : "#" + v;
+ }
+ function paintSwatch(elem, val) {
+ var n = normHex(val);
+ elem.style.background = n || "transparent";
+ elem.classList.toggle("hex-swatch-empty", !n);
+ }
function applyHexInputs(pal) {
- PALETTE_ROLES.forEach(function (role) { if (hexInputs[role]) hexInputs[role].value = pal[role] || ""; });
+ PALETTE_ROLES.forEach(function (role) {
+ if (hexInputs[role]) hexInputs[role].value = pal[role] || "";
+ if (hexSwatches[role]) paintSwatch(hexSwatches[role], pal[role]);
+ });
}
function selectCard(idx) {
var c = cands[idx] || {};
+ selectedIdx = idx;
STATE.color = { name: c.name || "", palette: Object.assign({}, normPalette(c)) };
grid.querySelectorAll(".color-card").forEach(function (card, i) { card.classList.toggle("selected", i === idx); });
applyHexInputs(STATE.color.palette);
@@ -513,15 +530,18 @@
cands.forEach(function (c, idx) {
var pal = normPalette(c);
+ var refs = {};
var card = el("div", "color-card");
var sw = el("div", "swatches");
PALETTE_ROLES.forEach(function (role) {
if (!pal[role]) return;
var col = el("div", "swatch-col");
var s = el("div", "swatch"); s.style.background = pal[role];
+ refs[role] = s;
col.appendChild(s); col.appendChild(el("div", "swatch-role", t("role_" + role)));
sw.appendChild(col);
});
+ cardSwatchRefs[idx] = refs;
card.appendChild(sw);
card.appendChild(el("div", "color-name", localized(c, "name") || (t("option_prefix") + " " + (idx + 1))));
if (localized(c, "note")) card.appendChild(el("div", "color-note", localized(c, "note")));
@@ -536,14 +556,25 @@
PALETTE_ROLES.forEach(function (role) {
var wrap = el("div", "hex-cell");
wrap.appendChild(el("div", "hex-cell-label", t("role_" + role)));
+ var line = el("div", "hex-input-line");
+ var sw = el("div", "hex-swatch hex-swatch-empty");
var inp = document.createElement("input");
inp.type = "text"; inp.placeholder = "#";
inp.addEventListener("input", function () {
if (!STATE.color) STATE.color = { name: "custom", palette: {} };
if (!STATE.color.palette) STATE.color.palette = {};
STATE.color.palette[role] = inp.value;
+ paintSwatch(sw, inp.value);
+ // Reflect a valid override straight onto the selected card so the
+ // user sees the change in context, not just in the input row.
+ var n = normHex(inp.value);
+ if (n && selectedIdx >= 0 && cardSwatchRefs[selectedIdx] && cardSwatchRefs[selectedIdx][role]) {
+ cardSwatchRefs[selectedIdx][role].style.background = n;
+ }
});
- hexInputs[role] = inp; wrap.appendChild(inp); row.appendChild(wrap);
+ hexInputs[role] = inp; hexSwatches[role] = sw;
+ line.appendChild(sw); line.appendChild(inp);
+ wrap.appendChild(line); row.appendChild(wrap);
});
override.appendChild(row);
sec.appendChild(override);
diff --git a/skills/ppt-master/scripts/confirm_ui/static/style.css b/skills/ppt-master/scripts/confirm_ui/static/style.css
index da0dc9bb..f10396e9 100644
--- a/skills/ppt-master/scripts/confirm_ui/static/style.css
+++ b/skills/ppt-master/scripts/confirm_ui/static/style.css
@@ -245,6 +245,7 @@ body {
.hex-row { display: flex; gap: 10px; flex-wrap: wrap; }
.hex-cell { display: flex; flex-direction: column; gap: 4px; }
.hex-cell-label { font-size: 11px; color: var(--muted); }
+.hex-input-line { display: flex; align-items: center; gap: 6px; }
.hex-cell input {
width: 92px;
border: 1px solid var(--line);
@@ -253,6 +254,19 @@ body {
font-family: ui-monospace, monospace;
font-size: 12.5px;
}
+/* Live preview of the value typed into the HEX box. */
+.hex-swatch {
+ flex: none;
+ width: 20px; height: 20px;
+ border-radius: 5px;
+ border: 1px solid var(--line);
+}
+.hex-swatch.hex-swatch-empty {
+ /* Subtle checker so an empty / invalid value reads as "no color" */
+ background:
+ linear-gradient(45deg, var(--line) 25%, transparent 25%, transparent 75%, var(--line) 75%) 0 0 / 10px 10px,
+ var(--card);
+}
/* ---- typography CJK / Latin previews ---- */
.font-sample-line { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }