Add custom toolbox card covers
All checks were successful
Deploy Sokko G / deploy (push) Successful in 18s
All checks were successful
Deploy Sokko G / deploy (push) Successful in 18s
This commit is contained in:
parent
25889a23ba
commit
06de3a3a6e
13 changed files with 7480 additions and 38 deletions
|
|
@ -38,6 +38,7 @@ const TOOLBOX_ICON_FILES = [
|
|||
"mining.png",
|
||||
"parachute.png",
|
||||
"puzzle.png",
|
||||
"reflexion.png",
|
||||
"shield.png",
|
||||
"sword.png",
|
||||
"target.png",
|
||||
|
|
@ -53,6 +54,11 @@ export function normalizeToolboxIcon(icon) {
|
|||
return TOOLBOX_ICON_FILES.includes(file) ? `${TOOLBOX_ICON_BASE}${file}` : DEFAULT_TOOLBOX_ICON;
|
||||
}
|
||||
|
||||
export function normalizeToolboxCustomCover(customCover) {
|
||||
const value = String(customCover || "").trim();
|
||||
return /^data:image\/(?:jpeg|jpg|png|webp);base64,[a-z0-9+/]+=*$/i.test(value) ? value : "";
|
||||
}
|
||||
|
||||
function normalizeToolboxModule(module) {
|
||||
if (!module || typeof module !== "object" || !module.type) return null;
|
||||
const title = String(module.title || "").trim();
|
||||
|
|
@ -123,6 +129,7 @@ export function normalizeToolbox(toolbox) {
|
|||
id: toolbox.id || uid("tbx"),
|
||||
name: String(toolbox.name || "Nouvelle toolbox").trim() || "Nouvelle toolbox",
|
||||
icon: normalizeToolboxIcon(toolbox.icon),
|
||||
customCover: normalizeToolboxCustomCover(toolbox.customCover),
|
||||
moduleColumns: Number(toolbox.moduleColumns) === 1 ? 1 : 2,
|
||||
modules,
|
||||
moduleOrder: normalizeModuleOrder(toolbox.moduleOrder, modules),
|
||||
|
|
@ -144,6 +151,7 @@ export function compactToolboxForStorage(toolbox) {
|
|||
};
|
||||
if (normalized.moduleColumns === 1) compact.moduleColumns = 1;
|
||||
if (normalized.icon !== DEFAULT_TOOLBOX_ICON) compact.icon = normalized.icon;
|
||||
if (normalized.customCover) compact.customCover = normalized.customCover;
|
||||
if (normalized.tutorial === true) compact.tutorial = true;
|
||||
return compact;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue