fix: readded gap between x-ray preview comment icons. (#1915)

* fix: readded gap between x-ray preview comment icons.

* feat: keep size 400px

---------

Co-authored-by: Eric Fennis <eric.fennis@gmail.com>
This commit is contained in:
Jakob Guddas
2024-03-06 21:00:26 +01:00
committed by GitHub
parent d67ef7b0ca
commit d255c6ac4e

View File

@@ -14,19 +14,17 @@ const changedFiles = changedFilesPathString
.filter((file, idx, arr) => arr.indexOf(file) === idx); .filter((file, idx, arr) => arr.indexOf(file) === idx);
const getImageTagsByFiles = (files, getBaseUrl, width) => const getImageTagsByFiles = (files, getBaseUrl, width) =>
files files.map((file) => {
.map((file) => { const svgContent = fs.readFileSync(path.join(process.cwd(), file), 'utf-8');
const svgContent = fs.readFileSync(path.join(process.cwd(), file), 'utf-8'); const strippedAttrsSVG = svgContent.replace(/<svg[^>]*>/, '<svg>');
const strippedAttrsSVG = svgContent.replace(/<svg[^>]*>/, '<svg>'); const minifiedSvg = minifySvg(strippedAttrsSVG);
const minifiedSvg = minifySvg(strippedAttrsSVG);
const base64 = Buffer.from(minifiedSvg).toString('base64'); const base64 = Buffer.from(minifiedSvg).toString('base64');
const url = getBaseUrl(file); const url = getBaseUrl(file);
const widthAttr = width ? `width="${width}"` : ''; const widthAttr = width ? `width="${width}"` : '';
return `<img title="${file}" alt="${file}" ${widthAttr} src="${url}/${base64}.svg"/>`; return `<img title="${file}" alt="${file}" ${widthAttr} src="${url}/${base64}.svg"/>`;
}) });
.join('');
const svgFiles = readSvgDirectory(ICONS_DIR).map((file) => `icons/${file}`); const svgFiles = readSvgDirectory(ICONS_DIR).map((file) => `icons/${file}`);
@@ -35,29 +33,32 @@ const iconsFilteredByName = (search) => svgFiles.filter((file) => file.includes(
const cohesionRandomImageTags = getImageTagsByFiles( const cohesionRandomImageTags = getImageTagsByFiles(
shuffle(svgFiles).slice(0, changedFiles.length), shuffle(svgFiles).slice(0, changedFiles.length),
() => `${BASE_URL}/stroke-width/2`, () => `${BASE_URL}/stroke-width/2`,
); ).join('');
const cohesionSquaresImageTags = getImageTagsByFiles( const cohesionSquaresImageTags = getImageTagsByFiles(
shuffle(iconsFilteredByName('square')).slice(0, changedFiles.length), shuffle(iconsFilteredByName('square')).slice(0, changedFiles.length),
() => `${BASE_URL}/stroke-width/2`, () => `${BASE_URL}/stroke-width/2`,
); ).join('');
const changeFiles1pxStrokeImageTags = getImageTagsByFiles( const changeFiles1pxStrokeImageTags = getImageTagsByFiles(
changedFiles, changedFiles,
() => `${BASE_URL}/stroke-width/1`, () => `${BASE_URL}/stroke-width/1`,
); ).join('');
const changeFiles2pxStrokeImageTags = getImageTagsByFiles( const changeFiles2pxStrokeImageTags = getImageTagsByFiles(
changedFiles, changedFiles,
() => `${BASE_URL}/stroke-width/2`, () => `${BASE_URL}/stroke-width/2`,
); ).join('');
const changeFiles3pxStrokeImageTags = getImageTagsByFiles( const changeFiles3pxStrokeImageTags = getImageTagsByFiles(
changedFiles, changedFiles,
() => `${BASE_URL}/stroke-width/3`, () => `${BASE_URL}/stroke-width/3`,
); ).join('');
const changeFilesLowDPIImageTags = getImageTagsByFiles(changedFiles, () => `${BASE_URL}/dpi/24`); const changeFilesLowDPIImageTags = getImageTagsByFiles(
changedFiles,
() => `${BASE_URL}/dpi/24`,
).join(' ');
const changeFilesXRayImageTags = getImageTagsByFiles( const changeFilesXRayImageTags = getImageTagsByFiles(
changedFiles, changedFiles,
@@ -67,7 +68,7 @@ const changeFilesXRayImageTags = getImageTagsByFiles(
return `${BASE_URL}/${iconName}`; return `${BASE_URL}/${iconName}`;
}, },
400, 400,
); ).join(' ');
const commentMarkup = `\ const commentMarkup = `\
### Added or changed icons ### Added or changed icons