Skip to content

Commit d6a11a6

Browse files
committed
backend(themes): add badge and titleColor query parameters
1 parent 72bdb93 commit d6a11a6

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/cards/card-builder.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,28 @@ export default class CardBuilder {
122122
return this;
123123
}
124124

125+
public badgeColor(badge = ""): CardBuilder {
126+
if (isHexColor(badge)) {
127+
this.card.setTheme({
128+
...this.card.getTheme(),
129+
badgeColor: badge,
130+
});
131+
}
132+
133+
return this;
134+
}
135+
136+
public titleColor(title = ""): CardBuilder {
137+
if (isHexColor(title)) {
138+
this.card.setTheme({
139+
...this.card.getTheme(),
140+
titleColor: title,
141+
});
142+
}
143+
144+
return this;
145+
}
146+
125147
public lines(
126148
cb: (line: number, addBadge: (b: Badge) => void) => void
127149
): CardBuilder {

src/controllers/cards-controller.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export const getCard = async (req: Request, res: Response) => {
1919
width,
2020
bg,
2121
border,
22+
badge,
23+
titleColor,
2224
} = req.query;
2325

2426
const card = new CardBuilder()
@@ -43,6 +45,8 @@ export const getCard = async (req: Request, res: Response) => {
4345
})
4446
.bgColor(bg?.toString())
4547
.borderColor(border?.toString())
48+
.badgeColor(badge?.toString())
49+
.titleColor(titleColor?.toString())
4650
.build();
4751

4852
res.setHeader("Content-Type", "image/svg+xml");

0 commit comments

Comments
 (0)