« get me outta code hell

content, css, client: generateTextWithTooltip - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/linkContribution.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-01-13 19:05:57 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-01-13 20:55:51 -0400
commit3c8ee4341f682edb419f9193e07f214d96209384 (patch)
tree5a3d18728d8fda6b124db25d811fecaec5055125 /src/content/dependencies/linkContribution.js
parent35720bd44ef2d6d2a2de4ca4946bfc9ee108d4a8 (diff)
content, css, client: generateTextWithTooltip
Diffstat (limited to 'src/content/dependencies/linkContribution.js')
-rw-r--r--src/content/dependencies/linkContribution.js78
1 files changed, 40 insertions, 38 deletions
diff --git a/src/content/dependencies/linkContribution.js b/src/content/dependencies/linkContribution.js
index f3d6e4f..0b0884e 100644
--- a/src/content/dependencies/linkContribution.js
+++ b/src/content/dependencies/linkContribution.js
@@ -2,6 +2,7 @@ import {empty} from '#sugar';
 
 export default {
   contentDependencies: [
+    'generateTextWithTooltip',
     'generateTooltip',
     'linkArtist',
     'linkExternalAsIcon',
@@ -15,6 +16,9 @@ export default {
     relations.artistLink =
       relation('linkArtist', contribution.who);
 
+    relations.textWithTooltip =
+      relation('generateTextWithTooltip');
+
     relations.tooltip =
       relation('generateTooltip');
 
@@ -49,7 +53,30 @@ export default {
     const hasExternalIcons = !!(slots.showIcons && relations.artistIcons);
 
     const parts = ['misc.artistLink'];
-    const options = {artist: relations.artistLink};
+    const options = {};
+
+    options.artist =
+      (hasExternalIcons && slots.iconMode === 'tooltip'
+        ? relations.textWithTooltip.slots({
+            text: relations.artistLink,
+            tooltip:
+              relations.tooltip.slots({
+                attributes:
+                  {class: ['icons', 'icons-tooltip']},
+
+                contentAttributes:
+                  {[html.joinChildren]: ''},
+
+                content:
+                  relations.artistIcons
+                    .map(icon =>
+                      icon.slots({
+                        context: 'artist',
+                        withText: true,
+                      })),
+              }),
+          })
+        : relations.artistLink);
 
     if (hasContribution) {
       parts.push('withContribution');
@@ -67,46 +94,21 @@ export default {
               .map(icon => icon.slot('context', 'artist'))));
     }
 
-    let content = language.formatString(...parts, options);
-
-    if (hasExternalIcons && slots.iconMode === 'tooltip') {
-      content = [
-        content,
-        relations.tooltip.slots({
-          attributes:
-            {class: ['icons', 'icons-tooltip']},
-
-          contentAttributes:
-            {[html.joinChildren]: ''},
+    const contributionPart =
+      language.formatString(...parts, options);
 
-          content:
-            relations.artistIcons
-              .map(icon =>
-                icon.slots({
-                  context: 'artist',
-                  withText: true,
-                })),
-        }),
-      ];
+    if (!hasContribution && !hasExternalIcons) {
+      return contributionPart;
     }
 
-    if (hasContribution || hasExternalIcons) {
-      content =
-        html.tag('span', {class: 'contribution'},
-          {[html.noEdgeWhitespace]: true},
-          {[html.joinChildren]: ''},
+    return (
+      html.tag('span', {class: 'contribution'},
+        {[html.noEdgeWhitespace]: true},
 
-          hasExternalIcons &&
-          slots.iconMode === 'tooltip' &&
-            {class: 'has-tooltip'},
+        parts.length > 1 &&
+        slots.preventWrapping &&
+          {class: 'nowrap'},
 
-          parts.length > 1 &&
-          slots.preventWrapping &&
-            {class: 'nowrap'},
-
-          content);
-    }
-
-    return content;
-  }
+        contributionPart));
+  },
 };