diff --git a/code.js b/code.js index d641e3e..aa76d74 100644 --- a/code.js +++ b/code.js @@ -39,6 +39,7 @@ name: "Priority", type: "dropdown", options: ["Critical", "High", "Medium", "Low"], + optionColors: ["#FEE2E2", "#FFEDD5", "#FEF9C3", "#DCFCE7"], width: 110 }, { @@ -55,31 +56,27 @@ { id: "row-def-3", cells: {} } ]; var CHIP_PALETTE = [ - { bg: "#FFE566", text: "#1E293B" }, + { bg: "#FEF9C3", text: "#854D0E" }, // yellow - { bg: "#FFB347", text: "#1E293B" }, + { bg: "#FFEDD5", text: "#9A3412" }, // orange - { bg: "#FF8888", text: "#1E293B" }, + { bg: "#FEE2E2", text: "#991B1B" }, // red - { bg: "#FFB3D9", text: "#1E293B" }, + { bg: "#FCE7F3", text: "#9D174D" }, // pink - { bg: "#C8A8F5", text: "#1E293B" }, + { bg: "#EDE9FE", text: "#5B21B6" }, // purple - { bg: "#93C5FD", text: "#1E293B" }, + { bg: "#DBEAFE", text: "#1E40AF" }, // blue - { bg: "#67E8F9", text: "#1E293B" }, + { bg: "#CFFAFE", text: "#155E75" }, // cyan - { bg: "#86EFAC", text: "#1E293B" }, + { bg: "#DCFCE7", text: "#166534" }, // green - { bg: "#D9F99D", text: "#1E293B" }, + { bg: "#ECFCCB", text: "#3F6212" }, // lime - { bg: "#E2E8F0", text: "#1E293B" } + { bg: "#F1F5F9", text: "#475569" } // gray ]; - var CHIP_OVERRIDES = { - "Critical": { bg: "#FFEDD5", text: "#9A3412" } - // orange - }; function relativeLuminance(hex) { const r = parseInt(hex.slice(1, 3), 16) / 255; const g = parseInt(hex.slice(3, 5), 16) / 255; @@ -94,10 +91,10 @@ var _a; const i = col.options.indexOf(val); const custom = i !== -1 ? (_a = col.optionColors) == null ? void 0 : _a[i] : void 0; - if (custom) - return { bg: custom, text: textColorFor(custom) }; - if (CHIP_OVERRIDES[val]) - return CHIP_OVERRIDES[val]; + if (custom) { + const palette = CHIP_PALETTE.find((p) => p.bg === custom); + return { bg: custom, text: palette ? palette.text : textColorFor(custom) }; + } return i === -1 ? CHIP_PALETTE[0] : CHIP_PALETTE[i % CHIP_PALETTE.length]; } function uid() { @@ -115,8 +112,7 @@ const deleteRow = (id) => setRows(rows.filter((r) => r.id !== id)); const moveRow = (i, dir) => { const j = i + dir; - if (j < 0 || j >= rows.length) - return; + if (j < 0 || j >= rows.length) return; const r = [...rows]; [r[i], r[j]] = [r[j], r[i]]; setRows(r); @@ -459,25 +455,21 @@