From d3af33d2f7b013a8ccddcb6cb213f0b3ae4d8b3f Mon Sep 17 00:00:00 2001 From: seock1000 Date: Wed, 25 Jun 2025 22:26:53 +0900 Subject: [PATCH 1/2] [FEAT] Add Plant Theme --- app/page.tsx | 2 +- lib/svg-generator.ts | 17 +++++++++++++++- lib/themes.ts | 46 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 2 deletions(-) diff --git a/app/page.tsx b/app/page.tsx index 258c0d1..1525f01 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -60,4 +60,4 @@ export default function Home() { ); } -const TAGS = [{ label: "hair" }, { label: "fire" }]; +const TAGS = [{ label: "hair" }, { label: "fire" }, { label: "plant" }]; diff --git a/lib/svg-generator.ts b/lib/svg-generator.ts index 91e2bfb..b2a997f 100644 --- a/lib/svg-generator.ts +++ b/lib/svg-generator.ts @@ -10,6 +10,9 @@ export async function generateThemedSVG(username: string, themeKey: string) { const cellSize = 14; const background = theme.background || "#ffffff"; + const backgroundPattern = theme.backgroundPattern; + const patternId = `pattern_${themeKey}`; + const baseDot = theme.showBaseDot ?? false; const elements = weeks.flatMap((week, weekIndex) => @@ -44,9 +47,21 @@ export async function generateThemedSVG(username: string, themeKey: string) { }), ); + const defs = backgroundPattern + ? `${backgroundPattern.replace( + /]*)>/, + `` + )}` + : ""; + + const fillValue = backgroundPattern ? `url(#${patternId})` : background; + console.log("defs:", defs); + console.log("fillValue:", fillValue); + const svg = ` - + ${defs} + ${theme.emoji || ""} ${username}'s ${theme.label} ${elements.join("\n")} diff --git a/lib/themes.ts b/lib/themes.ts index dfa7973..dbdcdc3 100644 --- a/lib/themes.ts +++ b/lib/themes.ts @@ -7,6 +7,7 @@ export interface ThemeStyle { label: string; emoji?: string; background?: string; + backgroundPattern?: string; showBaseDot?: boolean; } @@ -61,9 +62,54 @@ export const FireTheme: ThemeStyle = { }, }; +export const PlantTheme: ThemeStyle = { + label: "Plant", + emoji: "🌿", + background: "#f0fdf4", + backgroundPattern: ` + + + + + + + + + + + + + `, + showBaseDot: true, + getEmoji: (level: CommitLevel): string | null => { + switch (level) { + case "none": + return null; + case "low": + return "🫘"; // 씨앗 + case "medium": + return "🌱"; // 새싹 + case "high": + return "🌿"; // 풀잎 + case "max": + return "🌻"; // 꽃 + default: + return null; + } + }, + colorMap: { + none: "#f0fdf4", + low: "#bbf7d0", + medium: "#86efac", + high: "#4ade80", + max: "#f472b6", + }, +}; + export const themes: Record = { hair: HairTheme, fire: FireTheme, + plant: PlantTheme, }; export function getCommitLevel(commitCount: number): CommitLevel { From c1ec07120c5e5ee80e49275b7af6f9ad5ed8186a Mon Sep 17 00:00:00 2001 From: seock1000 Date: Wed, 25 Jun 2025 22:50:24 +0900 Subject: [PATCH 2/2] [FIX] modify review point --- lib/svg-generator.ts | 11 ++++------- lib/themes.ts | 7 ------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/lib/svg-generator.ts b/lib/svg-generator.ts index b2a997f..eed95ee 100644 --- a/lib/svg-generator.ts +++ b/lib/svg-generator.ts @@ -48,15 +48,12 @@ export async function generateThemedSVG(username: string, themeKey: string) { ); const defs = backgroundPattern - ? `${backgroundPattern.replace( - /]*)>/, - `` - )}` + ? `${backgroundPattern.replace( + /]*?)>/g, + `` + )}` : ""; - const fillValue = backgroundPattern ? `url(#${patternId})` : background; - console.log("defs:", defs); - console.log("fillValue:", fillValue); const svg = ` diff --git a/lib/themes.ts b/lib/themes.ts index dbdcdc3..76b750b 100644 --- a/lib/themes.ts +++ b/lib/themes.ts @@ -97,13 +97,6 @@ export const PlantTheme: ThemeStyle = { return null; } }, - colorMap: { - none: "#f0fdf4", - low: "#bbf7d0", - medium: "#86efac", - high: "#4ade80", - max: "#f472b6", - }, }; export const themes: Record = {