« get me outta code hell

content: generateGridActionLinks - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/generateGridActionLinks.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-07-26 11:13:29 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-07-26 11:21:51 -0300
commitbdb4276ffae1c978ec1d1a6e462faf8c117e20a9 (patch)
tree432a10d27672fce3940649307e1ab126003e49b6 /src/content/dependencies/generateGridActionLinks.js
parent2a255b6c2e5970a523f9e2d6cf2b4d51dea97f06 (diff)
content: generateGridActionLinks
Diffstat (limited to 'src/content/dependencies/generateGridActionLinks.js')
-rw-r--r--src/content/dependencies/generateGridActionLinks.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/content/dependencies/generateGridActionLinks.js b/src/content/dependencies/generateGridActionLinks.js
new file mode 100644
index 00000000..09399f17
--- /dev/null
+++ b/src/content/dependencies/generateGridActionLinks.js
@@ -0,0 +1,22 @@
+import {empty} from '../../util/sugar.js';
+
+export default {
+  extraDependencies: ['html'],
+
+  slots: {
+    actionLinks: {validate: v => v.sparseArrayOf(v.isHTML)},
+  },
+
+  generate(slots, {html}) {
+    if (empty(slots.actionLinks)) {
+      return html.blank();
+    }
+
+    return (
+      html.tag('div', {class: 'grid-actions'},
+        slots.actionLinks
+          .filter(Boolean)
+          .map(link => link
+            .slot('attributes', {class: ['grid-item', 'box']}))));
+  },
+};