mirror of
https://github.com/reiyua/github-profile-trophy-reiyua-mirror.git
synced 2026-11-17 06:02:09 +11:00
Add transparent features
This commit is contained in:
parent
ea4ba8aeac
commit
3c15ab566f
4 changed files with 19 additions and 2 deletions
10
index.ts
10
index.ts
|
|
@ -25,6 +25,14 @@ export default async (req: ServerRequest) => {
|
|||
"margin-h",
|
||||
CONSTANTS.DEFAULT_MARGIN_H,
|
||||
);
|
||||
const noBackground = params.getBooleanValue(
|
||||
"no-bg",
|
||||
CONSTANTS.DEFAULT_NO_BACKGROUND,
|
||||
);
|
||||
const noFrame = params.getBooleanValue(
|
||||
"no-frame",
|
||||
CONSTANTS.DEFAULT_NO_FRAME,
|
||||
);
|
||||
const titles: Array<string> = params.getAll("title").flatMap((r) =>
|
||||
r.split(",")
|
||||
).map((r) => r.trim());
|
||||
|
|
@ -64,6 +72,8 @@ export default async (req: ServerRequest) => {
|
|||
CONSTANTS.DEFAULT_PANEL_SIZE,
|
||||
marginWidth,
|
||||
paddingHeight,
|
||||
noBackground,
|
||||
noFrame,
|
||||
).render(userInfo, theme),
|
||||
headers: new Headers(
|
||||
{
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ export class Card {
|
|||
private panelSize: number,
|
||||
private marginWidth: number,
|
||||
private marginHight: number,
|
||||
private noBackground: boolean,
|
||||
private noFrame: boolean,
|
||||
) {
|
||||
this.width = panelSize * this.maxColumn + this.marginWidth * (this.maxColumn - 1);
|
||||
}
|
||||
|
|
@ -92,7 +94,7 @@ export class Card {
|
|||
const currentRow = Math.floor(i / this.maxColumn);
|
||||
const x = this.panelSize * currentColumn + this.marginWidth * currentColumn;
|
||||
const y = this.panelSize * currentRow + this.marginHight * currentRow;
|
||||
return sum + trophy.render(theme, x, y, this.panelSize);
|
||||
return sum + trophy.render(theme, x, y, this.panelSize, this.noBackground, this.noFrame);
|
||||
},
|
||||
"",
|
||||
);
|
||||
|
|
|
|||
|
|
@ -63,6 +63,8 @@ export class Trophy {
|
|||
x = 0,
|
||||
y = 0,
|
||||
panelSize = CONSTANTS.DEFAULT_PANEL_SIZE,
|
||||
noBackground = CONSTANTS.DEFAULT_NO_BACKGROUND,
|
||||
noFrame = CONSTANTS.DEFAULT_NO_FRAME,
|
||||
): string {
|
||||
const { BACKGROUND: PRIMARY, TITLE: SECONDARY, TEXT, NEXT_RANK_BAR } = theme;
|
||||
const nextRankBar = getNextRankBar(
|
||||
|
|
@ -88,7 +90,8 @@ export class Trophy {
|
|||
height="${panelSize - 1}"
|
||||
stroke="#e1e4e8"
|
||||
fill="${PRIMARY}"
|
||||
stroke-opacity="1"
|
||||
stroke-opacity="${noFrame ? '0' : '1'}"
|
||||
fill-opacity="${noBackground ? '0' : '1'}"
|
||||
/>
|
||||
${getTrophyIcon(theme, this.rank)}
|
||||
<text x="50%" y="18" text-anchor="middle" font-family="Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji" font-weight="bold" font-size="13" fill="${SECONDARY}">${this.title}</text>
|
||||
|
|
|
|||
|
|
@ -62,6 +62,8 @@ export const CONSTANTS = {
|
|||
DEFAULT_MAX_ROW: 3,
|
||||
DEFAULT_MARGIN_W: 0,
|
||||
DEFAULT_MARGIN_H: 0,
|
||||
DEFAULT_NO_BACKGROUND: false,
|
||||
DEFAULT_NO_FRAME: false,
|
||||
};
|
||||
|
||||
export enum RANK {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue