add ability to set title of all cards

This commit is contained in:
Domai 2023-06-13 12:30:37 +02:00
parent 9168dc0ff8
commit c3bac21c32
No known key found for this signature in database
GPG key ID: 8F0CBA9FA6CBDB53
4 changed files with 14 additions and 9 deletions

View file

@ -15,6 +15,7 @@ export interface query {
icon_color?: string
text_color?: string
cache_seconds?: string
title?: string
// Mater
bg_color?: string
@ -34,6 +35,7 @@ export default async (req: Request<unknown, unknown, unknown, query>, res: Respo
icon_color,
text_color,
cache_seconds,
title,
// Master
bg_color,
@ -59,11 +61,12 @@ export default async (req: Request<unknown, unknown, unknown, query>, res: Respo
hide_border: parseBoolean(hide_border),
hide_rank: parseBoolean(hide_rank),
line_height: parseNumber(line_height),
title,
title_color,
icon_color,
text_color,
bg_color,
theme
theme,
}).render()
))
} catch (err) {

View file

@ -20,6 +20,7 @@ export interface query {
theme?: keyof typeof themes
cache_seconds?: string
layout?: string
title?: string
}
export default async (req: Request<unknown, unknown, unknown, query>, res: Response) => {
@ -35,7 +36,8 @@ export default async (req: Request<unknown, unknown, unknown, query>, res: Respo
language_count,
theme,
cache_seconds,
layout
layout,
title,
} = req.query
prepareResponse(res)
@ -53,6 +55,7 @@ export default async (req: Request<unknown, unknown, unknown, query>, res: Respo
layout,
text_color,
theme,
title,
title_color,
bg_color,
hide_border: parseBoolean(hide_border),

View file

@ -18,6 +18,7 @@ interface ProfileCardOptions extends CardOptions {
line_height?: number
icon_color?: string
text_color?: string
title?: string
}
export default class ProfileCard extends Card {
@ -39,9 +40,8 @@ export default class ProfileCard extends Card {
private recentXp: number,
private options: ProfileCardOptions
) {
super(
options
)
super(options)
// This Element
this.stats = {
@ -64,7 +64,7 @@ export default class ProfileCard extends Card {
options.hide_rank ? 0 : 120
)
this.title = `${encodeHTML(this.username)}${
this.title = this.options.title ?? `${encodeHTML(this.username)}${
['x', 's'].includes(this.username.slice(-1)) ? '\'' : '\'s'
} Code::Stats Profile`

View file

@ -10,6 +10,7 @@ interface TopLanguagesOptions extends CardOptions {
card_width?: number
layout?: string
text_color?: string
title?: string
}
export default class TopLanguagesCard extends Card {
@ -21,12 +22,10 @@ export default class TopLanguagesCard extends Card {
) {
super(options)
this.langs = this.langs
.filter((item) => !(options.hide || []).includes(item.name))
.slice(0, options.language_count || 5)
this.height = 45 + (this.langs.length + 1) * 40
this.width = 300
if (options.card_width && !isNaN(options.card_width)) {
@ -34,7 +33,7 @@ export default class TopLanguagesCard extends Card {
}
const textColor = getColor('text_color', options.text_color, options.theme)
this.title = 'Most Used Languages'
this.title = this.options.title ?? 'Most Used Languages'
this.css = CompactTextNode.getCSS(textColor as string)
}