feat: Vorschaubild für Farbschemata hochladen und anzeigen
This commit is contained in:
@@ -74,13 +74,14 @@ export function addColorToSchema(hsl) {
|
||||
}
|
||||
}
|
||||
|
||||
export function saveSchema(name, farben) {
|
||||
export function saveSchema(name, farben, bild) {
|
||||
const data = load();
|
||||
const existing = data.schemata.find(s => s.name === name);
|
||||
if (existing) {
|
||||
existing.farben = farben;
|
||||
if (bild !== undefined) existing.bild = bild || null;
|
||||
} else {
|
||||
data.schemata.push({ name, farben });
|
||||
data.schemata.push({ name, farben, bild: bild || null });
|
||||
}
|
||||
save(data);
|
||||
renderSammlung();
|
||||
@@ -227,8 +228,20 @@ export function renderSammlung() {
|
||||
const header = document.createElement('div');
|
||||
header.style.cssText = 'display:flex;justify-content:space-between;align-items:center;margin-bottom:0.5rem';
|
||||
|
||||
// Thumbnail + Name nebeneinander
|
||||
const nameRow = document.createElement('div');
|
||||
nameRow.style.cssText = 'display:flex;align-items:center;gap:0.6rem';
|
||||
|
||||
if (schema.bild) {
|
||||
const thumb = document.createElement('div');
|
||||
thumb.className = 'schema-thumb';
|
||||
thumb.style.backgroundImage = 'url(' + schema.bild + ')';
|
||||
nameRow.appendChild(thumb);
|
||||
}
|
||||
|
||||
const nameEl = document.createElement('strong');
|
||||
nameEl.textContent = schema.name;
|
||||
nameRow.appendChild(nameEl);
|
||||
|
||||
const delBtn = document.createElement('button');
|
||||
delBtn.className = 'action-btn';
|
||||
@@ -236,7 +249,7 @@ export function renderSammlung() {
|
||||
delBtn.style.fontSize = '0.75rem';
|
||||
delBtn.addEventListener('click', () => deleteSchema(schema.name));
|
||||
|
||||
header.appendChild(nameEl);
|
||||
header.appendChild(nameRow);
|
||||
header.appendChild(delBtn);
|
||||
|
||||
const swatchesDiv = document.createElement('div');
|
||||
|
||||
Reference in New Issue
Block a user