Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 35 additions & 38 deletions code.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
name: "Priority",
type: "dropdown",
options: ["Critical", "High", "Medium", "Low"],
optionColors: ["#FEE2E2", "#FFEDD5", "#FEF9C3", "#DCFCE7"],
width: 110
},
{
Expand All @@ -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;
Expand All @@ -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() {
Expand All @@ -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);
Expand Down Expand Up @@ -459,25 +455,21 @@
<script>
// \u2500\u2500 Chip palette (must match code.tsx) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
const CHIP_PALETTE = [
{ bg: '#FFE566', text: '#1E293B' }, // yellow
{ bg: '#FFB347', text: '#1E293B' }, // orange
{ bg: '#FF8888', text: '#1E293B' }, // red
{ bg: '#FFB3D9', text: '#1E293B' }, // pink
{ bg: '#C8A8F5', text: '#1E293B' }, // purple
{ bg: '#93C5FD', text: '#1E293B' }, // blue
{ bg: '#67E8F9', text: '#1E293B' }, // cyan
{ bg: '#86EFAC', text: '#1E293B' }, // green
{ bg: '#D9F99D', text: '#1E293B' }, // lime
{ bg: '#E2E8F0', text: '#1E293B' }, // gray
{ bg: '#FEF9C3', text: '#854D0E' }, // yellow
{ bg: '#FFEDD5', text: '#9A3412' }, // orange
{ bg: '#FEE2E2', text: '#991B1B' }, // red
{ bg: '#FCE7F3', text: '#9D174D' }, // pink
{ bg: '#EDE9FE', text: '#5B21B6' }, // purple
{ bg: '#DBEAFE', text: '#1E40AF' }, // blue
{ bg: '#CFFAFE', text: '#155E75' }, // cyan
{ bg: '#DCFCE7', text: '#166534' }, // green
{ bg: '#ECFCCB', text: '#3F6212' }, // lime
{ bg: '#F1F5F9', text: '#475569' }, // gray
]

const CHIP_OVERRIDES = {
'Critical': '#FFEDD5',
}

const FIGJAM_PALETTE = [
'#FFE566', '#FFB347', '#FF8888', '#FFB3D9', '#C8A8F5',
'#93C5FD', '#67E8F9', '#86EFAC', '#D9F99D', '#E2E8F0',
'#FEF9C3', '#FFEDD5', '#FEE2E2', '#FCE7F3', '#EDE9FE',
'#DBEAFE', '#CFFAFE', '#DCFCE7', '#ECFCCB', '#F1F5F9',
]

let columns = []
Expand Down Expand Up @@ -511,6 +503,11 @@
return 0.2126 * toLinear(r) + 0.7152 * toLinear(g) + 0.0722 * toLinear(b)
}

function chipTextColor(hex) {
const palette = CHIP_PALETTE.find(p => p.bg === hex)
return palette ? palette.text : textColorForHex(hex)
}

function textColorForHex(hex) {
return relativeLuminance(hex) > 0.35 ? '#1E293B' : '#FFFFFF'
}
Expand Down Expand Up @@ -574,7 +571,7 @@
previewChipLabel.textContent = 'Preview:'

const chipPreview = document.createElement('span')
chipPreview.style.cssText = 'font-size:11px;font-weight:500;padding:3px 8px;border-radius:4px;background:' + currentColor + ';color:' + textColorForHex(currentColor) + ';'
chipPreview.style.cssText = 'font-size:11px;font-weight:500;padding:3px 8px;border-radius:4px;background:' + currentColor + ';color:' + chipTextColor(currentColor) + ';'
chipPreview.textContent = optLabel

hexInput.addEventListener('input', function () {
Expand Down Expand Up @@ -815,7 +812,7 @@

col.options.forEach((opt, oi) => {
const key = col.id + '-' + oi
const currentColor = (col.optionColors && col.optionColors[oi]) || CHIP_OVERRIDES[opt] || CHIP_PALETTE[oi % CHIP_PALETTE.length].bg
const currentColor = (col.optionColors && col.optionColors[oi]) || CHIP_PALETTE[oi % CHIP_PALETTE.length].bg
const isOpen = openPickerKey === key

const container = document.createElement('div')
Expand Down
Loading