first commit
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
// ═══════════════════════════════════════════════════════
|
||||
// Color Converter
|
||||
// ═══════════════════════════════════════════════════════
|
||||
async function convertColor() {
|
||||
const color = document.getElementById('colorInput').value.trim();
|
||||
if (!color) return setStatus('colorStatus','error','Enter a color.');
|
||||
const d = await apiPost('/api/color/convert', { color });
|
||||
if (d.success) {
|
||||
document.getElementById('colorPreview').style.background = d.hex;
|
||||
document.getElementById('colorPicker').value = d.hex;
|
||||
const c = document.getElementById('colorResults');
|
||||
c.innerHTML = [
|
||||
['HEX', d.hex], ['RGB', d.rgb], ['HSL', d.hsl]
|
||||
].map(([l, v]) => `<div class="result-row"><div class="label">${l}</div><div class="value" onclick="copyText(this.textContent)">${v}</div></div>`).join('');
|
||||
setStatus('colorStatus','success','Converted ✓');
|
||||
} else setStatus('colorStatus','error', d.error);
|
||||
}
|
||||
|
||||
// Keyboard shortcut
|
||||
document.getElementById('colorInput').addEventListener('keydown', e => { if(e.key==='Enter') convertColor(); });
|
||||
|
||||
Reference in New Issue
Block a user