Monorepo for Tangled tangled.org

appview/pulls: draw pull status in a rounded rect #1050

merged opened by oppi.li targeting master from op/nzlxzlzoqxvm
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:qfpnj4og54vl56wngdriaxug/sh.tangled.repo.pull/3me3lzor5et22
+27 -19
Diff #0
+27 -19
appview/pulls/opengraph.go
··· 128 } 129 130 // Split stats area: left side for status/stats (80%), right side for dolly (20%) 131 - statusStatsArea, dollyArea := statsArea.Split(true, 80) 132 133 // Draw status and stats 134 - statsBounds := statusStatsArea.Img.Bounds() 135 statsX := statsBounds.Min.X + 60 // left padding 136 statsY := statsBounds.Min.Y 137 ··· 157 } else { 158 statusIcon = "git-pull-request-closed" 159 statusText = "closed" 160 - statusColor = color.RGBA{128, 128, 128, 255} // gray 161 } 162 163 - statusIconSize := 36 164 165 - // Draw icon with status color 166 - err = statusStatsArea.DrawLucideIcon(statusIcon, statsX, statsY+iconBaselineOffset-statusIconSize/2+5, statusIconSize, statusColor) 167 if err != nil { 168 log.Printf("failed to draw status icon: %v", err) 169 } 170 171 - // Draw text with status color 172 - textX := statsX + statusIconSize + 12 173 - statusTextSize := 32.0 174 - err = statusStatsArea.DrawTextAt(statusText, textX, statsY+iconBaselineOffset, statusColor, statusTextSize, ogcard.Middle, ogcard.Left) 175 if err != nil { 176 log.Printf("failed to draw status text: %v", err) 177 } 178 179 - statusTextWidth := len(statusText) * 20 180 - currentX := statsX + statusIconSize + 12 + statusTextWidth + 40 181 182 // Draw comment count 183 - err = statusStatsArea.DrawLucideIcon("message-square", currentX, statsY+iconBaselineOffset-iconSize/2+5, iconSize, iconColor) 184 if err != nil { 185 log.Printf("failed to draw comment icon: %v", err) 186 } ··· 190 if commentCount == 1 { 191 commentText = "1 comment" 192 } 193 - err = statusStatsArea.DrawTextAt(commentText, currentX, statsY+iconBaselineOffset, iconColor, textSize, ogcard.Middle, ogcard.Left) 194 if err != nil { 195 log.Printf("failed to draw comment text: %v", err) 196 } ··· 199 currentX += commentTextWidth + 40 200 201 // Draw files changed 202 - err = statusStatsArea.DrawLucideIcon("file-diff", currentX, statsY+iconBaselineOffset-iconSize/2+5, iconSize, iconColor) 203 if err != nil { 204 log.Printf("failed to draw file diff icon: %v", err) 205 } ··· 209 if filesChanged == 1 { 210 filesText = "1 file" 211 } 212 - err = statusStatsArea.DrawTextAt(filesText, currentX, statsY+iconBaselineOffset, iconColor, textSize, ogcard.Middle, ogcard.Left) 213 if err != nil { 214 log.Printf("failed to draw files text: %v", err) 215 } ··· 220 // Draw additions (green +) 221 greenColor := color.RGBA{34, 139, 34, 255} 222 additionsText := fmt.Sprintf("+%d", diffStats.Insertions) 223 - err = statusStatsArea.DrawTextAt(additionsText, currentX, statsY+iconBaselineOffset, greenColor, textSize, ogcard.Middle, ogcard.Left) 224 if err != nil { 225 log.Printf("failed to draw additions text: %v", err) 226 } ··· 231 // Draw deletions (red -) right next to additions 232 redColor := color.RGBA{220, 20, 60, 255} 233 deletionsText := fmt.Sprintf("-%d", diffStats.Deletions) 234 - err = statusStatsArea.DrawTextAt(deletionsText, currentX, statsY+iconBaselineOffset, redColor, textSize, ogcard.Middle, ogcard.Left) 235 if err != nil { 236 log.Printf("failed to draw deletions text: %v", err) 237 } ··· 254 openedDate := pull.Created.Format("Jan 2, 2006") 255 metaText := fmt.Sprintf("opened by %s 路 %s", authorHandle, openedDate) 256 257 - err = statusStatsArea.DrawTextAt(metaText, statsX, labelY, iconColor, labelSize, ogcard.Top, ogcard.Left) 258 if err != nil { 259 log.Printf("failed to draw metadata: %v", err) 260 }
··· 128 } 129 130 // Split stats area: left side for status/stats (80%), right side for dolly (20%) 131 + statusArea, dollyArea := statsArea.Split(true, 80) 132 133 // Draw status and stats 134 + statsBounds := statusArea.Img.Bounds() 135 statsX := statsBounds.Min.X + 60 // left padding 136 statsY := statsBounds.Min.Y 137 ··· 157 } else { 158 statusIcon = "git-pull-request-closed" 159 statusText = "closed" 160 + statusColor = color.RGBA{52, 58, 64, 255} // dark gray 161 } 162 163 + statusTextWidth := statusArea.TextWidth(statusText, textSize) 164 + badgePadding := 12 165 + badgeHeight := int(textSize) + (badgePadding * 2) 166 + badgeWidth := iconSize + badgePadding + statusTextWidth + (badgePadding * 2) 167 + cornerRadius := 8 168 + badgeX := 60 169 + badgeY := 0 170 171 + statusArea.DrawRoundedRect(badgeX, badgeY, badgeWidth, badgeHeight, cornerRadius, statusColor) 172 + 173 + whiteColor := color.RGBA{255, 255, 255, 255} 174 + iconX := statsX + badgePadding 175 + iconY := statsY + (badgeHeight-iconSize)/2 176 + err = statusArea.DrawLucideIcon(statusIcon, iconX, iconY, iconSize, whiteColor) 177 if err != nil { 178 log.Printf("failed to draw status icon: %v", err) 179 } 180 181 + textX := statsX + badgePadding + iconSize + badgePadding 182 + textY := statsY + (badgeHeight-int(textSize))/2 - 5 183 + err = statusArea.DrawTextAt(statusText, textX, textY, whiteColor, textSize, ogcard.Top, ogcard.Left) 184 if err != nil { 185 log.Printf("failed to draw status text: %v", err) 186 } 187 188 + currentX := statsX + badgeWidth + 50 189 190 // Draw comment count 191 + err = statusArea.DrawLucideIcon("message-square", currentX, iconY, iconSize, iconColor) 192 if err != nil { 193 log.Printf("failed to draw comment icon: %v", err) 194 } ··· 198 if commentCount == 1 { 199 commentText = "1 comment" 200 } 201 + err = statusArea.DrawTextAt(commentText, currentX, textY, iconColor, textSize, ogcard.Top, ogcard.Left) 202 if err != nil { 203 log.Printf("failed to draw comment text: %v", err) 204 } ··· 207 currentX += commentTextWidth + 40 208 209 // Draw files changed 210 + err = statusArea.DrawLucideIcon("file-diff", currentX, iconY, iconSize, iconColor) 211 if err != nil { 212 log.Printf("failed to draw file diff icon: %v", err) 213 } ··· 217 if filesChanged == 1 { 218 filesText = "1 file" 219 } 220 + err = statusArea.DrawTextAt(filesText, currentX, textY, iconColor, textSize, ogcard.Top, ogcard.Left) 221 if err != nil { 222 log.Printf("failed to draw files text: %v", err) 223 } ··· 228 // Draw additions (green +) 229 greenColor := color.RGBA{34, 139, 34, 255} 230 additionsText := fmt.Sprintf("+%d", diffStats.Insertions) 231 + err = statusArea.DrawTextAt(additionsText, currentX, textY, greenColor, textSize, ogcard.Top, ogcard.Left) 232 if err != nil { 233 log.Printf("failed to draw additions text: %v", err) 234 } ··· 239 // Draw deletions (red -) right next to additions 240 redColor := color.RGBA{220, 20, 60, 255} 241 deletionsText := fmt.Sprintf("-%d", diffStats.Deletions) 242 + err = statusArea.DrawTextAt(deletionsText, currentX, textY, redColor, textSize, ogcard.Top, ogcard.Left) 243 if err != nil { 244 log.Printf("failed to draw deletions text: %v", err) 245 } ··· 262 openedDate := pull.Created.Format("Jan 2, 2006") 263 metaText := fmt.Sprintf("opened by %s 路 %s", authorHandle, openedDate) 264 265 + err = statusArea.DrawTextAt(metaText, statsX, labelY, iconColor, labelSize, ogcard.Top, ogcard.Left) 266 if err != nil { 267 log.Printf("failed to draw metadata: %v", err) 268 }

History

1 round 0 comments
sign up or login to add to the discussion
oppi.li submitted #0
1 commit
expand
appview/pulls: draw pull status in a rounded rect
3/3 success
expand
expand 0 comments
pull request successfully merged