From ee65477bb9ae68fdf3046c940e00903287c6c86e Mon Sep 17 00:00:00 2001 From: suba <84484832+suba327777@users.noreply.github.com> Date: Fri, 3 May 2024 18:01:41 +0900 Subject: [PATCH 01/23] update: output svg file name --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index c1c02dc..0649c59 100644 --- a/main.go +++ b/main.go @@ -17,7 +17,7 @@ func main() { // ファイルパスを設定 directory := "./output" - filePath := "./output/output.svg" + filePath := "./output/mountain.svg" // ディレクトリが存在しない場合は作成 if _, err := os.Stat(directory); os.IsNotExist(err) { From de547f97cdc23dbfb263d083e8bb1037f8185e76 Mon Sep 17 00:00:00 2001 From: suba <84484832+suba327777@users.noreply.github.com> Date: Fri, 3 May 2024 18:39:51 +0900 Subject: [PATCH 02/23] add: theme default --- ui/theme.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 ui/theme.go diff --git a/ui/theme.go b/ui/theme.go new file mode 100644 index 0000000..cc0b382 --- /dev/null +++ b/ui/theme.go @@ -0,0 +1,32 @@ +package ui + +type Theme struct { + Name string + TitleColor string + IconColor string + MountainColor string + TextColor string + BgColor string + BorderColor string +} + +var Themes = []Theme{ + { + Name: "default", + TitleColor: "#FFFFFF", + IconColor: "#FFFFFF", + MountainColor: "#ADFF2F", + TextColor: "#FFFFFF", + BgColor: "#141321", + BorderColor: "#FFFFFF", + }, +} + +func getTheme(name string) Theme { + for _, theme := range Themes { + if theme.Name == name { + return theme + } + } + return Themes[0] +} From 2a7f6e37417115814f7a890b6245b6567f88cddc Mon Sep 17 00:00:00 2001 From: suba <84484832+suba327777@users.noreply.github.com> Date: Sat, 4 May 2024 12:57:21 +0900 Subject: [PATCH 03/23] update: when theme changes, the corresponding section should also be changed. --- ui/card.go | 59 ++++++++++++++++++++++++++++-------------------------- ui/icon.go | 47 ++++++++++++++++++++++++++++--------------- 2 files changed, 62 insertions(+), 44 deletions(-) diff --git a/ui/card.go b/ui/card.go index 24a2907..eec2e03 100644 --- a/ui/card.go +++ b/ui/card.go @@ -2,54 +2,54 @@ package ui import ( "fmt" + "os" ) -func startSVG(width, height int, viewBox string) string { - return fmt.Sprintf(``, width, height, viewBox) +func startSVG() string { + return fmt.Sprintf(``) } -func rect(width, height int, bgColor string) string { - return fmt.Sprintf(``, width, height, bgColor) +func rect(bgColor, borderColor string) string { + return fmt.Sprintf(``, bgColor, borderColor) } -func title(username string, mountain string) string { +func title(mountainIcon, textColor, username string) string { return fmt.Sprintf(` %s - %s + %s - `, mountain, username) + `, mountainIcon, textColor, username) } -func leftInfo(dailyCommitsMonthCount, endOfMonth, commitsYearCount int, tree, climber string) string { +func leftInfo(dailyCommitsMonthCount, endOfMonth, commitsYearCount int, treeIcon, climberIcon, textColor string) string { return fmt.Sprintf(` %s - commit day - per month - %d/%d + commit day + per month + %d/%d - %s - Total Commits - (2024) - %d + %s Total Commits + (2024) + %d - `, tree, dailyCommitsMonthCount, endOfMonth, climber, commitsYearCount) + `, treeIcon, textColor, textColor, textColor, dailyCommitsMonthCount, endOfMonth, climberIcon, textColor, textColor, textColor, commitsYearCount) } -func rightInfo(grass string) string { +func rightInfo(bgColor, grass string) string { return fmt.Sprintf(` - + %s - `, grass) + `, bgColor, grass) } func endSVG() string { @@ -57,17 +57,20 @@ func endSVG() string { } func GenerateCard(username string, dailyCommitsSince1MonthCount, dailyCommitsMonthCount, endOfMonth, commitsYearCount int) string { - width := 340 - height := 200 - viewBox := fmt.Sprintf("0 0 %d %d", width, height) - bgColor := "#141321" + themeName := os.Getenv("THEME") + theme := getTheme(themeName) + + mountainIcon := changeMountainColor(theme.MountainColor) + climberIcon := changeClimberColor(theme.IconColor) + treeIcon := changeTreeColor(theme.IconColor) + changeTriangleColor(theme.MountainColor) grassMountain := generateMountain(dailyCommitsSince1MonthCount) - svg := startSVG(width, height, viewBox) - svg += rect(width, height, bgColor) - svg += title(username, Mountain) - svg += leftInfo(dailyCommitsMonthCount, endOfMonth, commitsYearCount, Tree, Climber) - svg += rightInfo(grassMountain) + svg := startSVG() + svg += rect(theme.BgColor, theme.BorderColor) + svg += title(mountainIcon, theme.TextColor, username) + svg += leftInfo(dailyCommitsMonthCount, endOfMonth, commitsYearCount, treeIcon, climberIcon, theme.TextColor) + svg += rightInfo(theme.BgColor, grassMountain) svg += endSVG() return svg diff --git a/ui/icon.go b/ui/icon.go index 4704489..4b36ec3 100644 --- a/ui/icon.go +++ b/ui/icon.go @@ -1,22 +1,17 @@ package ui -import "fmt" - -const ( - Mountain = `` - Climber = `` - Tree = `` - Backpack = `` +import ( + "fmt" + "strings" ) -func generateTrianglePath(x, y int) string { - return fmt.Sprintf(` +var Mountain = `` +var Climber = `` +var Tree = `` +var Triangle = ` - `, x, y) -} - -func generateStarPath(x, y int) string { - return fmt.Sprintf(` + ` +var Star = ` - `, x, y) + ` +var Flag = `` + +func changeMountainColor(mountainColor string) string { + return strings.ReplaceAll(Mountain, `fill="#ADFF2F"`, fmt.Sprintf(`fill="%s"`, mountainColor)) +} +func changeTriangleColor(mountainColor string) { + strings.ReplaceAll(Mountain, `fill="#ADFF2F"`, fmt.Sprintf(`fill="%s"`, mountainColor)) +} +func changeClimberColor(iconColor string) string { + return strings.ReplaceAll(Climber, `fill="#FFFFFF"`, fmt.Sprintf(`fill="%s"`, iconColor)) +} +func changeTreeColor(iconColor string) string { + return strings.ReplaceAll(Tree, `fill="#FFFFFF"`, fmt.Sprintf(`fill="%s"`, iconColor)) } +func generateTrianglePath(x, y int) string { + return strings.ReplaceAll(Triangle, `x="10" y="10"`, fmt.Sprintf(`x="%d" y="%d"`, x, y)) +} +func generateStarPath(x, y int) string { + return strings.ReplaceAll(Star, `x="10" y="10"`, fmt.Sprintf(`x="%d" y="%d"`, x, y)) + +} func generateFlagPath(x, y int) string { - return fmt.Sprintf(``, x, y) + return strings.ReplaceAll(Flag, `x="10" y="10"`, fmt.Sprintf(`x="%d" y="%d"`, x, y)) } From 9869219ef9777565ef979d8860780f7e2fee323e Mon Sep 17 00:00:00 2001 From: suba <84484832+suba327777@users.noreply.github.com> Date: Sat, 4 May 2024 15:05:16 +0900 Subject: [PATCH 04/23] fix: reflect in theme --- ui/card.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ui/card.go b/ui/card.go index eec2e03..2ff5840 100644 --- a/ui/card.go +++ b/ui/card.go @@ -41,15 +41,15 @@ func leftInfo(dailyCommitsMonthCount, endOfMonth, commitsYearCount int, treeIcon `, treeIcon, textColor, textColor, textColor, dailyCommitsMonthCount, endOfMonth, climberIcon, textColor, textColor, textColor, commitsYearCount) } -func rightInfo(bgColor, grass string) string { +func rightInfo(bgColor, borderColor, grass string) string { return fmt.Sprintf(` - + %s - `, bgColor, grass) + `, bgColor, borderColor, grass) } func endSVG() string { @@ -68,9 +68,9 @@ func GenerateCard(username string, dailyCommitsSince1MonthCount, dailyCommitsMon svg := startSVG() svg += rect(theme.BgColor, theme.BorderColor) - svg += title(mountainIcon, theme.TextColor, username) + svg += title(mountainIcon, theme.TitleColor, username) svg += leftInfo(dailyCommitsMonthCount, endOfMonth, commitsYearCount, treeIcon, climberIcon, theme.TextColor) - svg += rightInfo(theme.BgColor, grassMountain) + svg += rightInfo(theme.BgColor, theme.BorderColor, grassMountain) svg += endSVG() return svg From 9678c1de509a38694c30724e507ac8ed28bf8ba0 Mon Sep 17 00:00:00 2001 From: suba <84484832+suba327777@users.noreply.github.com> Date: Sat, 4 May 2024 15:31:06 +0900 Subject: [PATCH 05/23] add: sun icon --- ui/icon.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ui/icon.go b/ui/icon.go index 4b36ec3..14c8628 100644 --- a/ui/icon.go +++ b/ui/icon.go @@ -42,6 +42,7 @@ var Star = ` ` +var Sun = `` var Flag = `` func changeMountainColor(mountainColor string) string { @@ -62,7 +63,9 @@ func generateTrianglePath(x, y int) string { } func generateStarPath(x, y int) string { return strings.ReplaceAll(Star, `x="10" y="10"`, fmt.Sprintf(`x="%d" y="%d"`, x, y)) - +} +func generateSunPath(x, y int) string { + return strings.ReplaceAll(Sun, `x="10" y="10"`, fmt.Sprintf(`x="%d" y="%d"`, x, y)) } func generateFlagPath(x, y int) string { return strings.ReplaceAll(Flag, `x="10" y="10"`, fmt.Sprintf(`x="%d" y="%d"`, x, y)) From 89ded781d13cedc3fd622079a4ff603821f82a49 Mon Sep 17 00:00:00 2001 From: suba <84484832+suba327777@users.noreply.github.com> Date: Sat, 4 May 2024 15:31:19 +0900 Subject: [PATCH 06/23] add: default theme --- ui/card.go | 2 +- ui/mountain.go | 16 +++++++++++++--- ui/theme.go | 9 +++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/ui/card.go b/ui/card.go index 2ff5840..6b95b7a 100644 --- a/ui/card.go +++ b/ui/card.go @@ -64,7 +64,7 @@ func GenerateCard(username string, dailyCommitsSince1MonthCount, dailyCommitsMon climberIcon := changeClimberColor(theme.IconColor) treeIcon := changeTreeColor(theme.IconColor) changeTriangleColor(theme.MountainColor) - grassMountain := generateMountain(dailyCommitsSince1MonthCount) + grassMountain := generateMountain(31, theme.Name) svg := startSVG() svg += rect(theme.BgColor, theme.BorderColor) diff --git a/ui/mountain.go b/ui/mountain.go index 4be9844..0c7ff10 100644 --- a/ui/mountain.go +++ b/ui/mountain.go @@ -22,7 +22,7 @@ func mountainColor(todayCommit int) string { return fmt.Sprintf(``, color) } -func generateMountain(count int) string { +func generateMountain(count int, themeName string) string { var results strings.Builder x := 0 @@ -57,11 +57,21 @@ func generateMountain(count int) string { } else if i == 29 { x -= 50 y -= 5 - results.WriteString(generateStarPath(x, y)) + switch themeName { + case "default": + results.WriteString(generateSunPath(x, y)) + case "dark": + results.WriteString(generateStarPath(x, y)) + } } else if i == 30 { x -= 30 y += 20 - results.WriteString(generateStarPath(x, y)) + switch themeName { + case "default": + + case "dark": + results.WriteString(generateStarPath(x, y)) + } } else if i == 31 { x += 30 y -= 30 diff --git a/ui/theme.go b/ui/theme.go index cc0b382..032214f 100644 --- a/ui/theme.go +++ b/ui/theme.go @@ -13,6 +13,15 @@ type Theme struct { var Themes = []Theme{ { Name: "default", + TitleColor: "#434d58", + IconColor: "#2f80ed", + MountainColor: "#ADFF2F", + TextColor: "#434d58", + BgColor: "#FFFFeF", + BorderColor: "#e4e2e2", + }, + { + Name: "dark", TitleColor: "#FFFFFF", IconColor: "#FFFFFF", MountainColor: "#ADFF2F", From 9203920af2186b91d7fb6904d5c59625e449689a Mon Sep 17 00:00:00 2001 From: suba <84484832+suba327777@users.noreply.github.com> Date: Sat, 4 May 2024 16:46:08 +0900 Subject: [PATCH 07/23] fix: typo --- ui/card.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/card.go b/ui/card.go index 6b95b7a..a360ae9 100644 --- a/ui/card.go +++ b/ui/card.go @@ -64,7 +64,7 @@ func GenerateCard(username string, dailyCommitsSince1MonthCount, dailyCommitsMon climberIcon := changeClimberColor(theme.IconColor) treeIcon := changeTreeColor(theme.IconColor) changeTriangleColor(theme.MountainColor) - grassMountain := generateMountain(31, theme.Name) + grassMountain := generateMountain(dailyCommitsSince1MonthCount, theme.Name) svg := startSVG() svg += rect(theme.BgColor, theme.BorderColor) From 703b49ccd8e6e80b22410533d6a43e1f82928f72 Mon Sep 17 00:00:00 2001 From: suba <84484832+suba327777@users.noreply.github.com> Date: Sat, 4 May 2024 17:19:53 +0900 Subject: [PATCH 08/23] refactor: remove comment --- ui/mountain.go | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/ui/mountain.go b/ui/mountain.go index 0c7ff10..b338cba 100644 --- a/ui/mountain.go +++ b/ui/mountain.go @@ -1,27 +1,9 @@ package ui import ( - "fmt" "strings" ) -// wip -func mountainColor(todayCommit int) string { - var color string - if todayCommit >= 20 { - color = "#00cc00" - } else if todayCommit >= 10 { - green := 204 + (todayCommit-10)*5 - color = fmt.Sprintf("#%02x%02x%02x", 255, green, 0) - } else if todayCommit >= 1 { - green := 153 + todayCommit*5 - color = fmt.Sprintf("#%02x%02x%02x", 255, green, 0) - } else { - color = "#ffffff" - } - return fmt.Sprintf(``, color) -} - func generateMountain(count int, themeName string) string { var results strings.Builder From 1c5d617aac86540302e616ca94305a616820ff53 Mon Sep 17 00:00:00 2001 From: suba <84484832+suba327777@users.noreply.github.com> Date: Fri, 10 May 2024 13:43:33 +0900 Subject: [PATCH 09/23] update: output directory path name --- main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 0649c59..03f5a32 100644 --- a/main.go +++ b/main.go @@ -16,8 +16,8 @@ func main() { } // ファイルパスを設定 - directory := "./output" - filePath := "./output/mountain.svg" + directory := "./mountain-output" + filePath := "./mountain-output/mountain.svg" // ディレクトリが存在しない場合は作成 if _, err := os.Stat(directory); os.IsNotExist(err) { From 9ca6d3c8b3894bf46fa1ddb54df0d2839ef74c0e Mon Sep 17 00:00:00 2001 From: suba <84484832+suba327777@users.noreply.github.com> Date: Fri, 10 May 2024 14:05:27 +0900 Subject: [PATCH 10/23] fix: fn name --- ui/card.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/card.go b/ui/card.go index a360ae9..608395c 100644 --- a/ui/card.go +++ b/ui/card.go @@ -60,10 +60,10 @@ func GenerateCard(username string, dailyCommitsSince1MonthCount, dailyCommitsMon themeName := os.Getenv("THEME") theme := getTheme(themeName) - mountainIcon := changeMountainColor(theme.MountainColor) + mountainIcon := changeMountainColor(theme.MountainIconColor) climberIcon := changeClimberColor(theme.IconColor) treeIcon := changeTreeColor(theme.IconColor) - changeTriangleColor(theme.MountainColor) + changeTriangleColor(theme.MountainIconColor) grassMountain := generateMountain(dailyCommitsSince1MonthCount, theme.Name) svg := startSVG() From 0b987ca27b829fb3dafc070a5581540e1329e421 Mon Sep 17 00:00:00 2001 From: suba <84484832+suba327777@users.noreply.github.com> Date: Fri, 10 May 2024 14:31:23 +0900 Subject: [PATCH 11/23] add: triangleMountainColor --- ui/theme.go | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/ui/theme.go b/ui/theme.go index 032214f..7a8174e 100644 --- a/ui/theme.go +++ b/ui/theme.go @@ -1,33 +1,36 @@ package ui type Theme struct { - Name string - TitleColor string - IconColor string - MountainColor string - TextColor string - BgColor string - BorderColor string + Name string + TitleColor string + IconColor string + MountainIconColor string + TriangleMountainColor string + TextColor string + BgColor string + BorderColor string } var Themes = []Theme{ { - Name: "default", - TitleColor: "#434d58", - IconColor: "#2f80ed", - MountainColor: "#ADFF2F", - TextColor: "#434d58", - BgColor: "#FFFFeF", - BorderColor: "#e4e2e2", + Name: "default", + TitleColor: "#434d58", + IconColor: "#2f80ed", + MountainIconColor: "#ADFF2F", + TriangleMountainColor: "#ADFF2F", + TextColor: "#434d58", + BgColor: "#FFFFeF", + BorderColor: "#e4e2e2", }, { - Name: "dark", - TitleColor: "#FFFFFF", - IconColor: "#FFFFFF", - MountainColor: "#ADFF2F", - TextColor: "#FFFFFF", - BgColor: "#141321", - BorderColor: "#FFFFFF", + Name: "dark", + TitleColor: "#FFFFFF", + IconColor: "#FFFFFF", + MountainIconColor: "#ADFF2F", + TriangleMountainColor: "#ADFF2F", + TextColor: "#FFFFFF", + BgColor: "#141321", + BorderColor: "#FFFFFF", }, } From e46865132a8297d63da9b43ed64d869320ee9392 Mon Sep 17 00:00:00 2001 From: suba <84484832+suba327777@users.noreply.github.com> Date: Fri, 10 May 2024 14:32:18 +0900 Subject: [PATCH 12/23] update: triangle color fn arg --- ui/card.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/card.go b/ui/card.go index 608395c..e249f38 100644 --- a/ui/card.go +++ b/ui/card.go @@ -63,7 +63,7 @@ func GenerateCard(username string, dailyCommitsSince1MonthCount, dailyCommitsMon mountainIcon := changeMountainColor(theme.MountainIconColor) climberIcon := changeClimberColor(theme.IconColor) treeIcon := changeTreeColor(theme.IconColor) - changeTriangleColor(theme.MountainIconColor) + changeTriangleColor(theme.TriangleMountainColor) grassMountain := generateMountain(dailyCommitsSince1MonthCount, theme.Name) svg := startSVG() From 045c4d2f3315f789745d824d624aa5ce466e9d30 Mon Sep 17 00:00:00 2001 From: suba <84484832+suba327777@users.noreply.github.com> Date: Fri, 10 May 2024 14:37:44 +0900 Subject: [PATCH 13/23] update:change color fn arg --- ui/icon.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ui/icon.go b/ui/icon.go index 14c8628..d818bfb 100644 --- a/ui/icon.go +++ b/ui/icon.go @@ -45,11 +45,11 @@ var Star = `` var Flag = `` -func changeMountainColor(mountainColor string) string { - return strings.ReplaceAll(Mountain, `fill="#ADFF2F"`, fmt.Sprintf(`fill="%s"`, mountainColor)) +func changeMountainColor(mountainIconColor string) string { + return strings.ReplaceAll(Mountain, `fill="#ADFF2F"`, fmt.Sprintf(`fill="%s"`, mountainIconColor)) } -func changeTriangleColor(mountainColor string) { - strings.ReplaceAll(Mountain, `fill="#ADFF2F"`, fmt.Sprintf(`fill="%s"`, mountainColor)) +func changeTriangleColor(triangleMountainColor string) { + strings.ReplaceAll(Mountain, `fill="#ADFF2F"`, fmt.Sprintf(`fill="%s"`, triangleMountainColor)) } func changeClimberColor(iconColor string) string { return strings.ReplaceAll(Climber, `fill="#FFFFFF"`, fmt.Sprintf(`fill="%s"`, iconColor)) From 0415670ecf5e917bb448a6d2e99b0e41eee0be18 Mon Sep 17 00:00:00 2001 From: suba <84484832+suba327777@users.noreply.github.com> Date: Fri, 10 May 2024 18:05:56 +0900 Subject: [PATCH 14/23] fix: generate mountain fn args --- ui/card.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ui/card.go b/ui/card.go index e249f38..957f5ac 100644 --- a/ui/card.go +++ b/ui/card.go @@ -63,8 +63,7 @@ func GenerateCard(username string, dailyCommitsSince1MonthCount, dailyCommitsMon mountainIcon := changeMountainColor(theme.MountainIconColor) climberIcon := changeClimberColor(theme.IconColor) treeIcon := changeTreeColor(theme.IconColor) - changeTriangleColor(theme.TriangleMountainColor) - grassMountain := generateMountain(dailyCommitsSince1MonthCount, theme.Name) + grassMountain := generateMountain(31, theme.Name, theme.TriangleMountainColor) svg := startSVG() svg += rect(theme.BgColor, theme.BorderColor) From fe86a88e0751bd66edd6a314889db5009b668a92 Mon Sep 17 00:00:00 2001 From: suba <84484832+suba327777@users.noreply.github.com> Date: Fri, 10 May 2024 18:06:46 +0900 Subject: [PATCH 15/23] update: to be able to color triangle --- ui/icon.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ui/icon.go b/ui/icon.go index d818bfb..3d913b8 100644 --- a/ui/icon.go +++ b/ui/icon.go @@ -48,9 +48,6 @@ var Flag = ` Date: Fri, 10 May 2024 18:07:41 +0900 Subject: [PATCH 16/23] update: add to triangleMountainColor arguments --- ui/mountain.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ui/mountain.go b/ui/mountain.go index b338cba..ac664ce 100644 --- a/ui/mountain.go +++ b/ui/mountain.go @@ -4,7 +4,7 @@ import ( "strings" ) -func generateMountain(count int, themeName string) string { +func generateMountain(count int, themeName, triangleMountainColor string) string { var results strings.Builder x := 0 @@ -15,27 +15,27 @@ func generateMountain(count int, themeName string) string { if i == 8 { x -= 130 y -= 18 - results.WriteString(generateTrianglePath(x, y)) + results.WriteString(generateTrianglePath(x, y, triangleMountainColor)) } else if i == 14 { x -= 110 y -= 15 - results.WriteString(generateTrianglePath(x, y)) + results.WriteString(generateTrianglePath(x, y, triangleMountainColor)) } else if i == 19 { x -= 90 y -= 15 - results.WriteString(generateTrianglePath(x, y)) + results.WriteString(generateTrianglePath(x, y, triangleMountainColor)) } else if i == 23 { x -= 70 y -= 15 - results.WriteString(generateTrianglePath(x, y)) + results.WriteString(generateTrianglePath(x, y, triangleMountainColor)) } else if i == 26 { x -= 50 y -= 15 - results.WriteString(generateTrianglePath(x, y)) + results.WriteString(generateTrianglePath(x, y, triangleMountainColor)) } else if i == 28 { x -= 30 y -= 15 - results.WriteString(generateTrianglePath(x, y)) + results.WriteString(generateTrianglePath(x, y, triangleMountainColor)) } else if i == 29 { x -= 50 y -= 5 @@ -59,7 +59,7 @@ func generateMountain(count int, themeName string) string { y -= 30 results.WriteString(generateFlagPath(x, y)) } else { - results.WriteString(generateTrianglePath(x, y)) + results.WriteString(generateTrianglePath(x, y, triangleMountainColor)) } } From 35c00ac887c8797e7155097b48a1fe9d33665a7c Mon Sep 17 00:00:00 2001 From: suba <84484832+suba327777@users.noreply.github.com> Date: Fri, 10 May 2024 18:33:25 +0900 Subject: [PATCH 17/23] update: common icon path fn --- ui/icon.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/ui/icon.go b/ui/icon.go index 3d913b8..f2d99f8 100644 --- a/ui/icon.go +++ b/ui/icon.go @@ -60,12 +60,7 @@ func generateTrianglePath(x, y int, triangleMountainColor string) string { triangle = strings.ReplaceAll(triangle, `fill="#ADFF2F"`, fmt.Sprintf(`fill="%s"`, triangleMountainColor)) return triangle } -func generateStarPath(x, y int) string { - return strings.ReplaceAll(Star, `x="10" y="10"`, fmt.Sprintf(`x="%d" y="%d"`, x, y)) -} -func generateSunPath(x, y int) string { - return strings.ReplaceAll(Sun, `x="10" y="10"`, fmt.Sprintf(`x="%d" y="%d"`, x, y)) -} -func generateFlagPath(x, y int) string { - return strings.ReplaceAll(Flag, `x="10" y="10"`, fmt.Sprintf(`x="%d" y="%d"`, x, y)) + +func generateBonusIconPath(x, y int, svgIcon string) string { + return strings.ReplaceAll(fmt.Sprintf("%s", svgIcon), `x="10" y="10"`, fmt.Sprintf(`x="%d" y="%d"`, x, y)) } From 1daf1f0d43c2830c22285a4b3e59932f56b5465a Mon Sep 17 00:00:00 2001 From: suba <84484832+suba327777@users.noreply.github.com> Date: Fri, 10 May 2024 18:33:40 +0900 Subject: [PATCH 18/23] update: common icon path fn --- ui/mountain.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ui/mountain.go b/ui/mountain.go index ac664ce..35ffb10 100644 --- a/ui/mountain.go +++ b/ui/mountain.go @@ -41,9 +41,9 @@ func generateMountain(count int, themeName, triangleMountainColor string) string y -= 5 switch themeName { case "default": - results.WriteString(generateSunPath(x, y)) + results.WriteString(generateBonusIconPath(x, y, Sun)) case "dark": - results.WriteString(generateStarPath(x, y)) + results.WriteString(generateBonusIconPath(x, y, Star)) } } else if i == 30 { x -= 30 @@ -52,12 +52,12 @@ func generateMountain(count int, themeName, triangleMountainColor string) string case "default": case "dark": - results.WriteString(generateStarPath(x, y)) + results.WriteString(generateBonusIconPath(x, y, Star)) } } else if i == 31 { x += 30 y -= 30 - results.WriteString(generateFlagPath(x, y)) + results.WriteString(generateBonusIconPath(x, y, Flag)) } else { results.WriteString(generateTrianglePath(x, y, triangleMountainColor)) } From 7824ace04fcb465cb9e5252337143eea06c9760f Mon Sep 17 00:00:00 2001 From: suba <84484832+suba327777@users.noreply.github.com> Date: Fri, 10 May 2024 18:42:54 +0900 Subject: [PATCH 19/23] update: common changeIconColor fn --- ui/card.go | 8 ++++---- ui/icon.go | 12 +++--------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/ui/card.go b/ui/card.go index 957f5ac..cd8d568 100644 --- a/ui/card.go +++ b/ui/card.go @@ -60,10 +60,10 @@ func GenerateCard(username string, dailyCommitsSince1MonthCount, dailyCommitsMon themeName := os.Getenv("THEME") theme := getTheme(themeName) - mountainIcon := changeMountainColor(theme.MountainIconColor) - climberIcon := changeClimberColor(theme.IconColor) - treeIcon := changeTreeColor(theme.IconColor) - grassMountain := generateMountain(31, theme.Name, theme.TriangleMountainColor) + mountainIcon := changeIconColor(Mountain, theme.MountainIconColor) + climberIcon := changeIconColor(Climber, theme.IconColor) + treeIcon := changeIconColor(Tree, theme.IconColor) + grassMountain := generateMountain(dailyCommitsSince1MonthCount, theme.Name, theme.TriangleMountainColor) svg := startSVG() svg += rect(theme.BgColor, theme.BorderColor) diff --git a/ui/icon.go b/ui/icon.go index f2d99f8..ca5fed4 100644 --- a/ui/icon.go +++ b/ui/icon.go @@ -5,7 +5,7 @@ import ( "strings" ) -var Mountain = `` +var Mountain = `` var Climber = `` var Tree = `` var Triangle = ` @@ -45,14 +45,8 @@ var Star = `` var Flag = `` -func changeMountainColor(mountainIconColor string) string { - return strings.ReplaceAll(Mountain, `fill="#ADFF2F"`, fmt.Sprintf(`fill="%s"`, mountainIconColor)) -} -func changeClimberColor(iconColor string) string { - return strings.ReplaceAll(Climber, `fill="#FFFFFF"`, fmt.Sprintf(`fill="%s"`, iconColor)) -} -func changeTreeColor(iconColor string) string { - return strings.ReplaceAll(Tree, `fill="#FFFFFF"`, fmt.Sprintf(`fill="%s"`, iconColor)) +func changeIconColor(svgIcon, iconColor string) string { + return strings.ReplaceAll(fmt.Sprintf("%s", svgIcon), `fill="#FFFFFF"`, fmt.Sprintf(`fill="%s"`, iconColor)) } func generateTrianglePath(x, y int, triangleMountainColor string) string { From a15e185836a4f45d40f891eb034b5521a8cf9a75 Mon Sep 17 00:00:00 2001 From: suba <84484832+suba327777@users.noreply.github.com> Date: Mon, 13 May 2024 21:23:44 +0900 Subject: [PATCH 20/23] add: sakura theme --- ui/icon.go | 1 + ui/mountain.go | 4 ++++ ui/theme.go | 10 ++++++++++ 3 files changed, 15 insertions(+) diff --git a/ui/icon.go b/ui/icon.go index ca5fed4..d2c288b 100644 --- a/ui/icon.go +++ b/ui/icon.go @@ -43,6 +43,7 @@ var Star = `` +var Sakura = `` var Flag = `` func changeIconColor(svgIcon, iconColor string) string { diff --git a/ui/mountain.go b/ui/mountain.go index 35ffb10..c90ff32 100644 --- a/ui/mountain.go +++ b/ui/mountain.go @@ -44,6 +44,8 @@ func generateMountain(count int, themeName, triangleMountainColor string) string results.WriteString(generateBonusIconPath(x, y, Sun)) case "dark": results.WriteString(generateBonusIconPath(x, y, Star)) + case "sakura": + results.WriteString(generateBonusIconPath(x, y, Sakura)) } } else if i == 30 { x -= 30 @@ -53,6 +55,8 @@ func generateMountain(count int, themeName, triangleMountainColor string) string case "dark": results.WriteString(generateBonusIconPath(x, y, Star)) + case "sakura": + results.WriteString(generateBonusIconPath(x, y, Sakura)) } } else if i == 31 { x += 30 diff --git a/ui/theme.go b/ui/theme.go index 7a8174e..715b929 100644 --- a/ui/theme.go +++ b/ui/theme.go @@ -32,6 +32,16 @@ var Themes = []Theme{ BgColor: "#141321", BorderColor: "#FFFFFF", }, + { + Name: "sakura", + TitleColor: "#FFFFFF", + IconColor: "#FFB6A1", + MountainIconColor: "#AAD378", + TriangleMountainColor: "#AAD378", + TextColor: "#FEFFFF", + BgColor: "#FDD9D9", + BorderColor: "#FEFFFF", + }, } func getTheme(name string) Theme { From 5682dc841464e29416a2c9b624a2700e27f9c377 Mon Sep 17 00:00:00 2001 From: suba <84484832+suba327777@users.noreply.github.com> Date: Mon, 13 May 2024 21:34:07 +0900 Subject: [PATCH 21/23] update: output directory name --- mountain-output/README.md | 1 + output/README.md | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 mountain-output/README.md delete mode 100644 output/README.md diff --git a/mountain-output/README.md b/mountain-output/README.md new file mode 100644 index 0000000..04cef2c --- /dev/null +++ b/mountain-output/README.md @@ -0,0 +1 @@ +# Output folder diff --git a/output/README.md b/output/README.md deleted file mode 100644 index b3cfc04..0000000 --- a/output/README.md +++ /dev/null @@ -1 +0,0 @@ -# Output folder \ No newline at end of file From 6abd214079ff1bbd12bcf4161e896492d5491f59 Mon Sep 17 00:00:00 2001 From: suba <84484832+suba327777@users.noreply.github.com> Date: Mon, 13 May 2024 22:11:36 +0900 Subject: [PATCH 22/23] add: maple theme --- ui/icon.go | 1 + ui/mountain.go | 5 +++++ ui/theme.go | 10 ++++++++++ 3 files changed, 16 insertions(+) diff --git a/ui/icon.go b/ui/icon.go index d2c288b..4ff34a4 100644 --- a/ui/icon.go +++ b/ui/icon.go @@ -44,6 +44,7 @@ var Star = `` var Sakura = `` +var maple = `` var Flag = `` func changeIconColor(svgIcon, iconColor string) string { diff --git a/ui/mountain.go b/ui/mountain.go index c90ff32..0a05f90 100644 --- a/ui/mountain.go +++ b/ui/mountain.go @@ -46,7 +46,10 @@ func generateMountain(count int, themeName, triangleMountainColor string) string results.WriteString(generateBonusIconPath(x, y, Star)) case "sakura": results.WriteString(generateBonusIconPath(x, y, Sakura)) + case "maple": + results.WriteString(generateBonusIconPath(x, y, maple)) } + } else if i == 30 { x -= 30 y += 20 @@ -57,6 +60,8 @@ func generateMountain(count int, themeName, triangleMountainColor string) string results.WriteString(generateBonusIconPath(x, y, Star)) case "sakura": results.WriteString(generateBonusIconPath(x, y, Sakura)) + case "maple": + results.WriteString(generateBonusIconPath(x, y, maple)) } } else if i == 31 { x += 30 diff --git a/ui/theme.go b/ui/theme.go index 715b929..a07331b 100644 --- a/ui/theme.go +++ b/ui/theme.go @@ -42,6 +42,16 @@ var Themes = []Theme{ BgColor: "#FDD9D9", BorderColor: "#FEFFFF", }, + { + Name: "maple", + TitleColor: "#D88352", + IconColor: "#ACBC65", + MountainIconColor: "#E58C43", + TriangleMountainColor: "#FBAC33", + TextColor: "#D88352", + BgColor: "#FCC796", + BorderColor: "#D88352", + }, } func getTheme(name string) Theme { From 8969a196ecda6e55c48f91c4033b3e9d224c9854 Mon Sep 17 00:00:00 2001 From: suba <84484832+suba327777@users.noreply.github.com> Date: Mon, 13 May 2024 22:19:55 +0900 Subject: [PATCH 23/23] fix: lint error --- main.go | 1 - ui/icon.go | 20 +++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/main.go b/main.go index 03f5a32..f7ec246 100644 --- a/main.go +++ b/main.go @@ -8,7 +8,6 @@ import ( ) func main() { - svg, err := api.MountainHandler() if err != nil { fmt.Printf("Error calling MountainHandler: %v\n", err) diff --git a/ui/icon.go b/ui/icon.go index 4ff34a4..d8e023d 100644 --- a/ui/icon.go +++ b/ui/icon.go @@ -5,13 +5,14 @@ import ( "strings" ) -var Mountain = `` -var Climber = `` -var Tree = `` -var Triangle = ` +var ( + Mountain = `` + Climber = `` + Tree = `` + Triangle = ` ` -var Star = ` + Star = ` ` -var Sun = `` -var Sakura = `` -var maple = `` -var Flag = `` + Sun = `` + Sakura = `` + maple = `` + Flag = `` +) func changeIconColor(svgIcon, iconColor string) string { return strings.ReplaceAll(fmt.Sprintf("%s", svgIcon), `fill="#FFFFFF"`, fmt.Sprintf(`fill="%s"`, iconColor))