« get me outta code hell

content: linkThing: add color: false slot option - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-04-15 19:47:04 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-04-15 19:47:04 -0300
commit60e85440588fa9c52ae2d856c1e53126935222a4 (patch)
tree51a0382fed29dff27ad9c17b5730c97a1a6eaf77
parent27a1df82ac455a44965cbcaef3e3bd1765d95942 (diff)
content: linkThing: add color: false slot option
This behaves like the old codebase, disabling automatically
grabbing the color from the thing being linked.
-rw-r--r--src/content/dependencies/linkThing.js14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/content/dependencies/linkThing.js b/src/content/dependencies/linkThing.js
index fea68ae5..1e648ee6 100644
--- a/src/content/dependencies/linkThing.js
+++ b/src/content/dependencies/linkThing.js
@@ -37,9 +37,14 @@ export default {
 
         tooltip: {
           validate: v => v.oneOf(v.isBoolean, v.isString),
+          default: false,
+        },
+
+        color: {
+          validate: v => v.oneOf(v.isBoolean, v.isColor),
+          default: true,
         },
 
-        color: relations.linkTemplate.getSlotDescription('color'),
         attributes: relations.linkTemplate.getSlotDescription('attributes'),
         hash: relations.linkTemplate.getSlotDescription('hash'),
       },
@@ -56,7 +61,12 @@ export default {
           content = name;
         }
 
-        const color = slots.color ?? data.color ?? null;
+        let color = null;
+        if (slots.color === true) {
+          color = data.color ?? null;
+        } else if (typeof slots.color === 'string') {
+          color = slots.color;
+        }
 
         let tooltip = null;
         if (slots.tooltip === true) {