From ede6453f904691f883ad400c356aa22e97046039 Mon Sep 17 00:00:00 2001 From: Alex Sanders Date: Wed, 31 Aug 2022 16:38:58 +0100 Subject: [PATCH] update logger preview script for csnx --- libs/@guardian/libs/.lintstagedrc.js | 2 +- .../libs/scripts/generateSvg.logger.teams.ts | 21 ++++++++----------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/libs/@guardian/libs/.lintstagedrc.js b/libs/@guardian/libs/.lintstagedrc.js index 0beb28f35..87373547c 100644 --- a/libs/@guardian/libs/.lintstagedrc.js +++ b/libs/@guardian/libs/.lintstagedrc.js @@ -1,7 +1,7 @@ const config = require('../../../.lintstagedrc.js'); module.exports = { - 'src/logger/**/*': + 'src/logger/**/*|scripts/generateSvg.logger.teams.*': 'node -r @swc-node/register scripts/generateSvg.logger.teams.ts', '*': 'node -r @swc-node/register scripts/update-readme.ts', ...config, diff --git a/libs/@guardian/libs/scripts/generateSvg.logger.teams.ts b/libs/@guardian/libs/scripts/generateSvg.logger.teams.ts index 463721568..4fbc51dfb 100755 --- a/libs/@guardian/libs/scripts/generateSvg.logger.teams.ts +++ b/libs/@guardian/libs/scripts/generateSvg.logger.teams.ts @@ -1,20 +1,15 @@ -import fs from 'fs'; -import { teamStyles } from '../src/logger/teamStyles'; - -fs.writeFileSync(__dirname + '/../static/logger.svg', generateSvg()); +import fs from 'node:fs'; +import { commonStyle, teamStyles } from '../src/logger/teamStyles'; function generateSvg(): string { - const filteredTeams = Object.entries(teamStyles).filter((team) => { - const [name] = team; - return name !== 'common'; - }); + const teams = Object.entries(teamStyles); const padding = 10; const lineHeight = 24; const width = 600; - const height = filteredTeams.length * lineHeight + padding * 2 + 60; + const height = teams.length * lineHeight + padding * 2 + 60; - const lines = filteredTeams.map((team, index) => { + const lines = teams.map((team, index) => { const [name, colours] = team; return `
@guardian @@ -72,8 +67,8 @@ function generateSvg(): string { } .common { - background-color: ${teamStyles.common.background}; - color: ${teamStyles.common.font}; + background-color: ${commonStyle.common.background}; + color: ${commonStyle.common.font}; } @@ -87,3 +82,5 @@ function generateSvg(): string { `; return svg; } + +fs.writeFileSync(__dirname + '/../static/logger.svg', generateSvg());