« get me outta code hell

data steps: generateAlbumInfoPage & relations implementation - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/generateColorStyleRules.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-03-19 17:57:27 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-03-19 17:57:27 -0300
commita213861e467ec99b2a197c4c54f9034a4d9f1516 (patch)
tree03b8b2e3affb17ab26dc88feaf2b4dc627f273ed /src/content/dependencies/generateColorStyleRules.js
parent41c22a553d43fbcc04b7a17ec6f83583ed7f3443 (diff)
data steps: generateAlbumInfoPage & relations implementation
Diffstat (limited to 'src/content/dependencies/generateColorStyleRules.js')
-rw-r--r--src/content/dependencies/generateColorStyleRules.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/content/dependencies/generateColorStyleRules.js b/src/content/dependencies/generateColorStyleRules.js
new file mode 100644
index 00000000..02c3380e
--- /dev/null
+++ b/src/content/dependencies/generateColorStyleRules.js
@@ -0,0 +1,42 @@
+export default {
+  extraDependencies: [
+    'getColors',
+  ],
+
+  data(color) {
+    return {color};
+  },
+
+  generate(data, {
+    getColors,
+  }) {
+    if (!color) return '';
+
+    const {
+      primary,
+      dark,
+      dim,
+      dimGhost,
+      bg,
+      bgBlack,
+      shadow,
+    } = getColors(data.color);
+
+    const variables = [
+      `--primary-color: ${primary}`,
+      `--dark-color: ${dark}`,
+      `--dim-color: ${dim}`,
+      `--dim-ghost-color: ${dimGhost}`,
+      `--bg-color: ${bg}`,
+      `--bg-black-color: ${bgBlack}`,
+      `--shadow-color: ${shadow}`,
+      ...additionalVariables,
+    ];
+
+    return [
+      `:root {`,
+      ...variables.map((line) => `    ${line};`),
+      `}`,
+    ].join('\n');
+  },
+};