Skip to content

Commit 1da35d4

Browse files
committed
backend: add a new hideBg query parameter
1 parent f919e00 commit 1da35d4

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ None of the fields are required. Every query parameter has a default value displ
5757
| **theme** | `?theme=github_dark` | github | The theme of the card. You can browse between the themes [here](docs/THEMES.md). |
5858
| **align** | `?align=center` | left | The alignment of the badges. (`left`, `center`, `right`) |
5959
| **showBorder** | `?showBorder=false` | true | Display the border around the card or not. (`true`, `false`) |
60+
| **hideBg** | `?hideBg=true` | false | If true, sets the background to transparent. (`true`, `false`) |
6061
| **borderRadius** | `?borderRadius=12.5` | 4.5 | Number between 0 and 50. |
6162
| **fontFamily** | `?fontFamily=consolas` | Segoe UI | The font family of the title. If the specified family doesn't exist, the default is used. |
6263
| **fontSize** | `?fontSize=20` | 18 | The size of the title. Accepts a number between 15 and 30. |

src/cards/card-builder.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,17 @@ export default class CardBuilder {
144144
return this;
145145
}
146146

147+
public hideBackground(hb = "false"): CardBuilder {
148+
if (hb.toString() === "true") {
149+
this.card.setTheme({
150+
...this.card.getTheme(),
151+
backgroundColor: "#00000000",
152+
});
153+
}
154+
155+
return this;
156+
}
157+
147158
public lines(
148159
cb: (line: number, addBadge: (b: Badge) => void) => void
149160
): CardBuilder {

src/controllers/cards-controller.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const getCard = async (req: Request, res: Response) => {
2121
border,
2222
badge,
2323
titleColor,
24+
hideBg,
2425
} = req.query;
2526

2627
const card = new CardBuilder()
@@ -47,6 +48,7 @@ export const getCard = async (req: Request, res: Response) => {
4748
.borderColor(border?.toString())
4849
.badgeColor(badge?.toString())
4950
.titleColor(titleColor?.toString())
51+
.hideBackground(hideBg?.toString())
5052
.build();
5153

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

0 commit comments

Comments
 (0)