Skip to content

Commit 2e43dbb

Browse files
committed
.
1 parent dc5c984 commit 2e43dbb

File tree

4 files changed

+127
-261
lines changed

4 files changed

+127
-261
lines changed

dist/index.js

Lines changed: 106 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"prepare": "husky || true"
3232
},
3333
"dependencies": {
34-
"@actions/core": "^1.11.1"
34+
"@actions/core": "^1.11.1",
35+
"jsx-dom-runtime": "^0.72.0"
3536
},
3637
"devDependencies": {
3738
"@biomejs/biome": "^1.9.4",

src/normalizers/teams.normalizer.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1+
import { jsx } from 'jsx-dom-runtime';
12
import type { Button, Field } from '../interfaces/input';
23
import type { TeamsPayload } from '../interfaces/teams-payload';
34

4-
function hex2img(color: string) {
5-
return `data:image/x-ms-bmp;base64,Qk06AAAAAAAAADYAAAAoAAAAAQAAAAEAAAABABgAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAA${btoa(
6-
String.fromCharCode(Number.parseInt(color[4] + color[5], 16)) +
7-
String.fromCharCode(Number.parseInt(color[2] + color[3], 16)) +
8-
String.fromCharCode(Number.parseInt(color[0] + color[1], 16)),
9-
)}AA%3D%3D`;
10-
}
11-
125
export const normalizeTeamsPayload = (
136
title: string,
147
text: string,
158
color: string,
169
fields: Field[],
1710
buttons: Button[],
1811
): TeamsPayload => {
12+
const pixel = jsx('canvas', { width: 1, height: 3 });
13+
const ctx = pixel.getContext('2d');
14+
15+
if (ctx) {
16+
ctx.fillStyle = `#${color}`;
17+
ctx.fillRect(0, 0, 1, 3);
18+
}
19+
1920
return {
2021
type: 'message',
2122
attachments: [
@@ -54,7 +55,7 @@ export const normalizeTeamsPayload = (
5455
width: 'Full',
5556
},
5657
backgroundImage: {
57-
url: hex2img(color),
58+
url: pixel.toDataURL('image/png'),
5859
fillMode: 'RepeatHorizontally',
5960
},
6061
},

0 commit comments

Comments
 (0)