Skip to content

Commit

Permalink
update logger preview script for csnx
Browse files Browse the repository at this point in the history
  • Loading branch information
sndrs committed Aug 31, 2022
1 parent add41d2 commit ede6453
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion libs/@guardian/libs/.lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
21 changes: 9 additions & 12 deletions libs/@guardian/libs/scripts/generateSvg.logger.teams.ts
Original file line number Diff line number Diff line change
@@ -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 `<div class="line">
<span class="label common">@guardian</span>
Expand Down Expand Up @@ -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};
}
</style>
<foreignObject x="0" y="0" width="${width}" height="${height}">
Expand All @@ -87,3 +82,5 @@ function generateSvg(): string {
</svg>`;
return svg;
}

fs.writeFileSync(__dirname + '/../static/logger.svg', generateSvg());

0 comments on commit ede6453

Please sign in to comment.