« get me outta code hell

generateColorStyleRules.js « dependencies « content « src - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/generateColorStyleRules.js
blob: fbc325998691e7518227636bddeb8156e2d1e5e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
export default {
  contentDependencies: [
    'generateColorStyleVariables',
  ],

  relations(relation, color) {
    const relations = {};

    if (color) {
      relations.variables =
        relation('generateColorStyleVariables', color);
    }

    return relations;
  },

  generate(relations) {
    if (!relations.variables) return '';

    return [
      `:root {`,
      // This is pretty hilariously hacky.
      ...relations.variables.split(';').map(line => line + ';'),
      `}`,
    ].join('\n');
  },
};