appview/pages: render a placeholder avatar when there's no did #896

open
opened by anirudh.fi targeting master from icy/tolqpt
Changed files
+31 -4
appview
pages
+16
appview/pages/funcmap.go
··· 360 360 "fullAvatar": func(handle string) string { 361 361 return p.AvatarUrl(handle, "") 362 362 }, 363 + "placeholderAvatar": func(size string) template.HTML { 364 + sizeClass := "size-6" 365 + iconSize := "size-4" 366 + if size == "tiny" { 367 + sizeClass = "size-6" 368 + iconSize = "size-4" 369 + } else if size == "small" { 370 + sizeClass = "size-8" 371 + iconSize = "size-5" 372 + } else { 373 + sizeClass = "size-12" 374 + iconSize = "size-8" 375 + } 376 + icon, _ := p.icon("user-round", []string{iconSize, "text-gray-400", "dark:text-gray-500"}) 377 + return template.HTML(fmt.Sprintf(`<div class="%s rounded-full bg-gray-200 dark:bg-gray-700 flex items-center justify-center flex-shrink-0">%s</div>`, sizeClass, icon)) 378 + }, 363 379 "profileAvatarUrl": func(profile *models.Profile, size string) string { 364 380 return p.ProfileAvatarUrl(profile, size) 365 381 },
+4 -1
appview/pages/templates/repo/commit.html
··· 100 100 {{ if $did }} 101 101 {{ template "user/fragments/picHandleLink" $did }} 102 102 {{ else }} 103 - <a href="mailto:{{ $email }}" class="no-underline hover:underline text-gray-500 dark:text-gray-300">{{ $name }}</a> 103 + <span class="flex items-center gap-1"> 104 + {{ placeholderAvatar "tiny" }} 105 + <a href="mailto:{{ $email }}" class="no-underline hover:underline text-gray-500 dark:text-gray-300">{{ $name }}</a> 106 + </span> 104 107 {{ end }} 105 108 {{ end }} 106 109
+6 -2
appview/pages/templates/repo/index.html
··· 259 259 {{ define "attribution" }} 260 260 {{ $commit := index . 0 }} 261 261 {{ $map := index . 1 }} 262 - <span class="flex items-center"> 262 + <span class="flex items-center gap-1"> 263 263 {{ $author := index $map $commit.Author.Email }} 264 264 {{ $coauthors := $commit.CoAuthors }} 265 265 {{ $all := list }} ··· 274 274 {{ end }} 275 275 {{ end }} 276 276 277 - {{ template "fragments/tinyAvatarList" (dict "all" $all "classes" "size-6") }} 277 + {{ if $author }} 278 + {{ template "fragments/tinyAvatarList" (dict "all" $all "classes" "size-6") }} 279 + {{ else }} 280 + {{ placeholderAvatar "tiny" }} 281 + {{ end }} 278 282 <a href="{{ if $author }}/{{ $author }}{{ else }}mailto:{{ $commit.Author.Email }}{{ end }}" 279 283 class="no-underline hover:underline"> 280 284 {{ if $author }}{{ resolve $author }}{{ else }}{{ $commit.Author.Name }}{{ end }}
+5 -1
appview/pages/templates/repo/log.html
··· 186 186 {{ end }} 187 187 {{ end }} 188 188 189 - {{ template "fragments/tinyAvatarList" (dict "all" $all "classes" "size-6") }} 189 + {{ if $author }} 190 + {{ template "fragments/tinyAvatarList" (dict "all" $all "classes" "size-6") }} 191 + {{ else }} 192 + {{ placeholderAvatar "tiny" }} 193 + {{ end }} 190 194 <a href="{{ if $author }}/{{ $author }}{{ else }}mailto:{{ $commit.Author.Email }}{{ end }}" 191 195 class="no-underline hover:underline"> 192 196 {{ if $author }}{{ resolve $author }}{{ else }}{{ $commit.Author.Name }}{{ end }}