« get me outta code hell

content, test: linkThing: tooltip -> tooltipStyle - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/linkThing.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-01-13 19:11:28 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-01-13 21:19:10 -0400
commita3dca62ee1cd0c1da0a8952bbbf62fb55ce7319f (patch)
treed8377c4ae82027146548b06a06ab18a5ca6bb8f0 /src/content/dependencies/linkThing.js
parenteb8670ee11fd0a68c02ef96227b4475f08157ace (diff)
content, test: linkThing: tooltip -> tooltipStyle
Diffstat (limited to 'src/content/dependencies/linkThing.js')
-rw-r--r--src/content/dependencies/linkThing.js29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/content/dependencies/linkThing.js b/src/content/dependencies/linkThing.js
index 2c3b036..4c38c51 100644
--- a/src/content/dependencies/linkThing.js
+++ b/src/content/dependencies/linkThing.js
@@ -36,9 +36,9 @@ export default {
       default: false,
     },
 
-    tooltip: {
-      validate: v => v.anyOf(v.isBoolean, v.isHTML),
-      default: false,
+    tooltipStyle: {
+      validate: v => v.is('none', 'browser'),
+      default: 'none',
     },
 
     color: {
@@ -69,10 +69,19 @@ export default {
     const path =
       slots.path ?? data.path;
 
-    const name =
+    const showShortName =
       (slots.preferShortName
-        ? data.nameShort ?? data.name ?? null
-        : data.name ?? null);
+        ? data.nameShort && data.nameShort !== data.name
+        : false);
+
+    const name =
+      (showShortName
+        ? data.nameShort
+        : data.name);
+
+    if (slots.tooltipStyle === 'browser') {
+      attributes.add('title', data.name);
+    }
 
     const content =
       (html.isBlank(slots.content)
@@ -91,19 +100,11 @@ export default {
       attributes.add(colorStyle);
     }
 
-    let tooltip = null;
-    if (slots.tooltip === true) {
-      tooltip = name;
-    } else if (typeof slots.tooltip === 'string') {
-      tooltip = slots.tooltip;
-    }
-
     return relations.linkTemplate
       .slots({
         path: slots.anchor ? [] : path,
         href: slots.anchor ? '' : null,
         content,
-        tooltip,
         attributes,
         hash: slots.hash,
         linkless: slots.linkless,