Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/card UI totalcommits #36

Merged
merged 5 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ linters:
- gosimple
- varcheck
- misspell
- lll
- gofumpt
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,26 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: Use README.Mountain
uses: suba327777/README.Mountain@main
uses: suba327777/README.Mountain@release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
USERNAME: ${{ github.repository_owner }}
# select theme
THEME: "default"
- name: Diff
id: diff
run: |
git add -N .
git diff --name-only --exit-code
continue-on-error: true
- name: commit & push
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "[μRM] generate svg."
git push
if: steps.diff.outcome == 'failure'
```

## dependency, environments
Expand Down
21 changes: 11 additions & 10 deletions ui/card.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,28 @@ func title(mountainIcon, textColor, username string) string {
return fmt.Sprintf(`
<g>
<g transform="translate(5,8)">%s</g>
<text x="45" y="26" font-size="16" dominant-baseline="middle" text-anchor="start" fill="%s">%s</text>
<text x="45" y="26" font-size="16" dominant-baseline="middle" text-anchor="start" font-weight="bold" fill="%s">%s</text>
suba327777 marked this conversation as resolved.
Show resolved Hide resolved
</g>
`, mountainIcon, textColor, username)
}

func leftInfo(dailyCommitsMonthCount, endOfMonth, commitsYearCount int, treeIcon, climberIcon, textColor string) string {
func leftInfo(dailyCommitsMonthCount, endOfMonth int, treeIcon, climberIcon, textColor, formatCommitsYearCount string) string {
suba327777 marked this conversation as resolved.
Show resolved Hide resolved
return fmt.Sprintf(`
<g>
<g>
<g transform="translate(5,75)">%s</g>
<text x="48" y="85" font-size="11" dominant-baseline="middle" text-anchor="start" fill="%s">commit day</text>
<text x="50" y="100" font-size="11" dominant-baseline="middle" text-anchor="start" fill="%s">per month</text>
<text x="125" y="90" font-size="10" dominant-baseline="middle" text-anchor="start" fill="%s">%d/%d</text>
<text x="48" y="85" font-size="11" dominant-baseline="middle" text-anchor="start" font-weight="bold" fill="%s">Commit Day</text>
suba327777 marked this conversation as resolved.
Show resolved Hide resolved
<text x="50" y="100" font-size="11" dominant-baseline="middle" text-anchor="start" font-weight="bold" fill="%s">Per Month</text>
suba327777 marked this conversation as resolved.
Show resolved Hide resolved
<text x="133" y="90" font-size="10" dominant-baseline="middle" text-anchor="start" font-weight="bold" fill="%s">%d/%d</text>
suba327777 marked this conversation as resolved.
Show resolved Hide resolved
</g>
<g>
<g transform="translate(5,140)">%s</g> <text x="40" y="150" font-size="11" dominant-baseline="middle" text-anchor="start" fill="%s">Total Commits</text>
<text x="60" y="165" font-size="11" dominant-baseline="middle" text-anchor="start" fill="%s">(2024)</text>
<text x="130" y="155" font-size="10" dominant-baseline="middle" text-anchor="start" fill="%s">%d</text>
<g transform="translate(5,140)">%s</g> <text x="40" y="150" font-size="11" dominant-baseline="middle" text-anchor="start" font-weight="bold" fill="%s">Total Commits</text>
suba327777 marked this conversation as resolved.
Show resolved Hide resolved
<text x="60" y="165" font-size="11" dominant-baseline="middle" text-anchor="start" font-weight="bold" fill="%s">(2024)</text>
suba327777 marked this conversation as resolved.
Show resolved Hide resolved
<text x="140" y="155" font-size="10" dominant-baseline="middle" text-anchor="start" font-weight="bold" fill="%s">%s</text>
suba327777 marked this conversation as resolved.
Show resolved Hide resolved

</g>
</g>
`, treeIcon, textColor, textColor, textColor, dailyCommitsMonthCount, endOfMonth, climberIcon, textColor, textColor, textColor, commitsYearCount)
`, treeIcon, textColor, textColor, textColor, dailyCommitsMonthCount, endOfMonth, climberIcon, textColor, textColor, textColor, formatCommitsYearCount)
suba327777 marked this conversation as resolved.
Show resolved Hide resolved
}

func rightInfo(bgColor, borderColor, grass string) string {
Expand All @@ -64,11 +64,12 @@ func GenerateCard(username string, dailyCommitsSince1MonthCount, dailyCommitsMon
climberIcon := changeIconColor(Climber, theme.IconColor)
treeIcon := changeIconColor(Tree, theme.IconColor)
grassMountain := generateMountain(dailyCommitsSince1MonthCount, theme.Name, theme.TriangleMountainColor)
formatCommitsYearCount := formatNumber(commitsYearCount)

svg := startSVG()
svg += rect(theme.BgColor, theme.BorderColor)
svg += title(mountainIcon, theme.TitleColor, username)
svg += leftInfo(dailyCommitsMonthCount, endOfMonth, commitsYearCount, treeIcon, climberIcon, theme.TextColor)
svg += leftInfo(dailyCommitsMonthCount, endOfMonth, treeIcon, climberIcon, theme.TextColor, formatCommitsYearCount)
svg += rightInfo(theme.BgColor, theme.BorderColor, grassMountain)
svg += endSVG()

Expand Down
11 changes: 11 additions & 0 deletions ui/utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package ui

import "fmt"

func formatNumber(num int) string {
if num >= 1000 {
return fmt.Sprintf("%.1fk", float64(num)/1000)
} else {
return fmt.Sprintf("%d", num)
}
}
Loading