From cfb203ae6778e0e6922143bb35ed1b055d617184 Mon Sep 17 00:00:00 2001 From: mkrause Date: Thu, 19 Dec 2024 00:02:21 +0100 Subject: [PATCH] Remove old code. --- scripts/import.ts | 52 ----------------------------------------------- 1 file changed, 52 deletions(-) diff --git a/scripts/import.ts b/scripts/import.ts index 409980b..5ab39a8 100755 --- a/scripts/import.ts +++ b/scripts/import.ts @@ -293,58 +293,6 @@ const runImportColorsSemantic = async (args: ScriptArgs) => { } else { await fs.writeFile(pathOutputSass, addGenerationComment(generatedSass), 'utf-8'); } - - /* - // Read tokens from stdin - type Token = { light: string, dark?: undefined | string }; - type Tokens = Record; - const tokens: Tokens = {}; - for await (const line of createInterface({ input: process.stdin })) { - if (line.trim() === '') { continue; } - - const matches = line.trim().match(/^--([a-z0-9-]+):\s*(.+)\s*;$/); - if (!matches) { - throw new Error(`Invalid token input:\n${line}\n`); - } - const [_match, tokenName, tokenValue] = matches; - if (tokenName === undefined || tokenValue === undefined) { throw new Error(`Should not happen`); } - - if (tokens[tokenName]) { - tokens[tokenName].dark = tokenValue; - } else { - tokens[tokenName] = { light: tokenValue }; - } - } - - const parseExpr = (expr: string) => { - // Replace color variables with their Sass equivalent - return expr.replaceAll(/var\(--([a-z0-9-]+-\d{1,4})\)/g, '$$color-$1'); - }; - - const outputLight = []; - const outputDark = []; - const outputTheme = []; - for (const [tokenName, token] of Object.entries(tokens)) { - if (typeof token.dark === 'undefined') { - throw new Error(`Missing dark variable for '${tokenName}'`); - } - - outputLight.push(`$light-${tokenName}: ${parseExpr(token.light)} !default;`); - outputDark.push(`$dark-${tokenName}: ${parseExpr(token.dark)} !default;`); - outputTheme.push(`$theme-${tokenName}: #{ld($light-${tokenName}, $dark-${tokenName})} !default;`); - } - - logger.log(dedent` - // Light theme - ${outputLight.join('\n')} - - // Dark theme - ${outputDark.join('\n')} - - // Dynamic theme - ${outputTheme.join('\n')} - `); - */ };