From f596941f3a2dfd8df7e1b3ed4a326de1e4b9e1ef Mon Sep 17 00:00:00 2001 From: Lewis Crichton Date: Sat, 9 Sep 2023 19:48:32 +0100 Subject: [PATCH] feat: checkbox type to bools in compiled output --- src/utils/themes/usercss/compiler.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/utils/themes/usercss/compiler.ts b/src/utils/themes/usercss/compiler.ts index 7785e42ae..7f3329ce8 100644 --- a/src/utils/themes/usercss/compiler.ts +++ b/src/utils/themes/usercss/compiler.ts @@ -75,6 +75,14 @@ export async function compileUsercss(fileName: string) { for (const [k, v] of Object.entries(vars)) { varsToPass[k] = Settings.userCssVars[id]?.[k] ?? v.default; + if (v.type === "checkbox" && ["less", "stylus"].includes(preprocessor)) { + // For Less and Stylus, we convert from 0/1 to false/true as it works with their if statement equivalents. + // Stylus doesn't really need this to be fair (0/1 are falsy/truthy), but for consistency's sake it's best + // if we do. + // + // In default and USO, it has no special meaning, so we'll just leave it as a number. + varsToPass[k] = varsToPass[k] === "1" ? "true" : "false"; + } } try {