Skip to content

Commit 6d57a06

Browse files
committed
backend(Card): added a new ontWeight query param
1 parent 49a1417 commit 6d57a06

File tree

11 files changed

+33
-8
lines changed

11 files changed

+33
-8
lines changed

.prettierrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
"tabWidth": 2,
44
"semi": true,
55
"singleQuote": false,
6-
"endOfLine": "crlf"
6+
"endOfLine": "lf"
77
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ With this site, you can customize your card.
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`) |
6060
| **borderRadius** | `?borderRadius=12.5` | 4.5 | Value between 0 and 50. |
61+
| **fontWeight** | `?fontWeight=normal` | semibold | The thickness of the title. (`thin`, `normal`, `semibold`, `bold`) |
6162
| **lineCount** | `?lineCount=2` | 1 | The number of lines you want to add to your card. |
6263
| **line{n}** | `?line1=typescript,typescript,2D79C7` | - | The current line of the badge, where {n} is a number. *`(1 <= n <= lineCount)`* |
6364

client/src/App.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,3 @@ const App = () => {
2121
};
2222

2323
export default App;
24-

client/src/components/input/NumberInput.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,3 @@ const NumberInput: FC<InputProps> = (props) => {
6969
};
7070

7171
export default NumberInput;
72-

client/src/components/input/SelectInput.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,3 @@ const SelectInput: FC<SelectInputProps> = (props) => {
4444
};
4545

4646
export default SelectInput;
47-

client/src/components/input/TrueFalseInput.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,3 @@ const TrueFalseInput: FC<TrueFalseInputProps> = (props) => {
4646
};
4747

4848
export default TrueFalseInput;
49-

client/src/sections/Options.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,3 @@ const Options: FC<OptionsProps> = (props) => {
174174
};
175175

176176
export default Options;
177-

src/cards/card.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { getThemeByName } from "./themes";
2-
import { Badge, BadgeAlign, Theme } from "./types";
2+
import { Badge, BadgeAlign, FontWeight, Theme } from "./types";
33

44
export default class Card {
55
private title: string;
@@ -8,6 +8,7 @@ export default class Card {
88
private badgeAlign: BadgeAlign;
99
private showBorder: boolean;
1010
private borderRadius: number;
11+
private fontWeight: FontWeight;
1112

1213
private lines: Map<number, Badge[]>;
1314

@@ -17,6 +18,7 @@ export default class Card {
1718
this.badgeAlign = "left";
1819
this.showBorder = true;
1920
this.borderRadius = 4.5;
21+
this.fontWeight = FontWeight.SEMIBOLD;
2022

2123
this.lineCount = 1;
2224
this.lines = new Map<number, Badge[]>();
@@ -76,4 +78,20 @@ export default class Card {
7678
public setBorderRadius = (borderRadius: number): void => {
7779
this.borderRadius = borderRadius;
7880
};
81+
82+
public getFontWeight = (): FontWeight => this.fontWeight;
83+
84+
public setFontWeight = (weight: string): void => {
85+
switch (weight.toLowerCase().trim()) {
86+
case "thin":
87+
this.fontWeight = FontWeight.THIN;
88+
break;
89+
case "bold":
90+
this.fontWeight = FontWeight.BOLD;
91+
break;
92+
case "normal":
93+
this.fontWeight = FontWeight.NORMAL;
94+
break;
95+
}
96+
};
7997
}

src/cards/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,10 @@ export interface Badge {
1212
}
1313

1414
export type BadgeAlign = "left" | "center" | "right";
15+
16+
export const enum FontWeight {
17+
THIN = 200,
18+
NORMAL = 400,
19+
SEMIBOLD = 600,
20+
BOLD = 800,
21+
}

src/controllers/cards-controller.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ export const getCard = async (req: Request, res: Response) => {
1818
const align = req.query.align?.toString() || "left";
1919
const showBorder = req.query.showBorder?.toString() || "true";
2020
const borderRadius = req.query.borderRadius?.toString() || "4.5";
21+
const fontWeight = req.query.fontWeight?.toString() || "semibold";
2122

2223
card.setTitle(title);
2324
card.setTheme(getThemeByName(theme));
2425
card.setLineCount(validateLineCount(lineCount));
2526
card.setBadgeAlign(validateAlign(align));
2627
card.setShowBorder(showBorder !== "false");
2728
card.setBorderRadius(validateBorderRadius(borderRadius));
29+
card.setFontWeight(fontWeight);
2830

2931
// run a loop card.getLineCount() times
3032
for (let i = 1; i <= card.getLineCount(); i++) {

0 commit comments

Comments
 (0)