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