forked from
tokono.ma/diffuse
A music player that connects to your cloud/distributed storage.
1/**
2 * @import { Facet } from "~/definitions/types.d.ts";
3 */
4
5/**
6 * @param {Facet} facet
7 * @returns {string}
8 *
9 * @example Returns accent-twist-4 for prelude kind and accent-twist-2 for others
10 * ```js
11 * import { color } from "~/common/facets/category.js";
12 *
13 * const prelude = color({ $type: "sh.diffuse.output.facet", id: "1", name: "x", kind: "prelude" });
14 * if (prelude !== "var(--accent-twist-4)") throw new Error("prelude should return accent-twist-4");
15 *
16 * const interactive = color({ $type: "sh.diffuse.output.facet", id: "1", name: "x", kind: "interactive" });
17 * if (interactive !== "var(--accent-twist-2)") throw new Error("interactive should return accent-twist-2");
18 *
19 * const undef = color({ $type: "sh.diffuse.output.facet", id: "1", name: "x" });
20 * if (undef !== "var(--accent-twist-2)") throw new Error("undefined kind should return accent-twist-2");
21 * ```
22 */
23export function color(facet) {
24 switch (facet.kind) {
25 case "prelude":
26 return "var(--accent-twist-4)";
27 default:
28 return "var(--accent-twist-2)";
29 }
30}
31
32/**
33 * @param {Facet} facet
34 * @returns {string}
35 *
36 * @example Returns 'feature' for prelude kind and 'interface' for others
37 * ```js
38 * import { name } from "~/common/facets/category.js";
39 *
40 * if (name({ $type: "sh.diffuse.output.facet", id: "1", name: "x", kind: "prelude" }) !== "feature") throw new Error("prelude should return 'feature'");
41 * if (name({ $type: "sh.diffuse.output.facet", id: "1", name: "x", kind: "interactive" }) !== "interface") throw new Error("interactive should return 'interface'");
42 * if (name({ $type: "sh.diffuse.output.facet", id: "1", name: "x" }) !== "interface") throw new Error("undefined kind should return 'interface'");
43 * ```
44 */
45export function name(facet) {
46 // return facet.kind ?? "interactive";
47 switch (facet.kind) {
48 case "prelude":
49 return "feature";
50 default:
51 return "interface";
52 }
53}