This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

7.3 kB 135 lines
1{{define "notifications/fragments/item"}} 2 <a href="{{ .URL resolver }}" 3 onclick="if(!event.target.closest('button'))navigator.sendBeacon('/notifications/{{ .ID }}/read')" 4 class="block no-underline hover:no-underline group"> 5 <div 6 class=" 7 w-full mx-auto dark:text-white px-2 md:px-6 py-4 8 {{ if not .Read }}bg-indigo-50/50 dark:bg-indigo-950/20 hover:bg-gray-100/50 dark:hover:bg-gray-700/50{{ else }}bg-white dark:bg-gray-800 hover:bg-gray-100/50 dark:hover:bg-gray-700/50{{ end }} 9 grid grid-cols-[auto_1fr_auto] gap-x-4 gap-y-1 items-center 10 "> 11 {{/* row 1, col 1: icon */}} 12 <div class="row-start-1 {{ template "notificationIconColor" . }}">{{ i (.Icon) "size-4" }}</div> 13 {{/* row 1, col 2: header */}} 14 <div class="row-start-1 flex items-center gap-1.5 text-sm min-w-0 overflow-hidden"> 15 {{- if not .Read }} 16 {{ template "repo/fragments/colorBall" (dict "color" "#4338ca" "classes" "shrink-0 dark:hidden") }} 17 {{ template "repo/fragments/colorBall" (dict "color" "#6366f1" "classes" "shrink-0 hidden dark:block") }} 18 {{- end -}} 19 {{- template "notificationHeader" . -}} 20 </div> 21 {{/* row 1, col 3: timestamp normally, button on hover */}} 22 <div class="row-start-1 relative flex items-center justify-end"> 23 <span class="text-sm text-gray-500 dark:text-gray-400 whitespace-nowrap md:group-hover:invisible">{{ template "repo/fragments/shortTime" .Created }}</span> 24 {{ if .Read }} 25 <button 26 hx-post="/notifications/{{ .ID }}/unread" 27 hx-target="closest a" 28 hx-swap="outerHTML" 29 class="hidden md:group-hover:flex absolute inset-0 items-center justify-end p-0 text-gray-400 dark:text-gray-500 hover:text-gray-600" 30 title="Mark as unread" 31 onclick="event.preventDefault()"> 32 {{ i "mail" "size-4" }} 33 </button> 34 {{ else }} 35 <button 36 hx-post="/notifications/{{ .ID }}/read" 37 hx-target="closest a" 38 hx-swap="outerHTML" 39 class="hidden md:group-hover:flex absolute inset-0 items-center justify-end p-0 text-gray-400 dark:text-gray-500 hover:text-gray-600" 40 title="Mark as read" 41 onclick="event.preventDefault()"> 42 {{ i "mail-open" "size-4" }} 43 </button> 44 {{ end }} 45 </div> 46 {{/* row 2, col 1: #N */}} 47 {{ template "notificationNumber" . }} 48 {{/* row 2, col 2: title */}} 49 {{ template "notificationSummary" . }} 50 </div> 51 </a> 52{{end}} 53 54{{ define "notificationIconColor" }} 55 {{ if or (eq .Type "issue_created") (eq .Type "issue_reopen") }}text-green-600 dark:text-green-500 56 {{ else if or (eq .Type "pull_created") (eq .Type "pull_reopen") }}text-green-600 dark:text-green-500 57 {{ else if eq .Type "pull_merged" }}text-purple-600 dark:text-purple-500 58 {{ else if eq .Type "pull_closed" }}text-red-600 dark:text-red-500 59 {{ else if eq .Type "user_mentioned" }}text-blue-500 dark:text-blue-400 60 {{ else if eq .Type "repo_starred" }}text-yellow-500 dark:text-yellow-600 61 {{ else if or (eq .Type "issue_assigned") (eq .Type "pull_assigned") }} text-blue-500 dark:text-blue-400 62 {{ else }}text-gray-500 dark:text-gray-400 63 {{ end }} 64{{ end }} 65 66{{ define "notificationNumber" }} 67 {{ if .Issue }} 68 <span class="row-start-2 col-start-1 text-sm text-gray-500 dark:text-gray-400 font-medium text-center">#{{ .Issue.IssueId }}</span> 69 {{ else if .Pull }} 70 <span class="row-start-2 col-start-1 text-sm text-gray-500 dark:text-gray-400 font-medium text-center">#{{ .Pull.PullId }}</span> 71 {{ end }} 72{{ end }} 73 74{{ define "notificationHeader" }} 75 {{ $repoOwner := "" }} 76 {{ $repoName := "" }} 77 {{ if .Repo }} 78 {{ $repoOwner = resolve .Repo.Did }} 79 {{ $repoName = .Repo.Name }} 80 {{ end }} 81 82 {{ $textStyle := "text-gray-700 dark:text-gray-300" }} 83 {{ $subjectStyle := "text-gray-800 dark:text-gray-200" }} 84 {{ $repo := printf "%s/%s" $repoOwner $repoName }} 85 <span class="shrink-0 flex items-center gap-1">{{ template "user/fragments/picHandle" .ActorDid }}</span> 86 <span class="truncate"> 87 {{ if eq .Type "repo_starred" }} 88 <span class="{{ $textStyle }}">starred</span> <span class="{{ $subjectStyle }}">{{ $repo }}</span> 89 {{ else if eq .Type "issue_created" }} 90 <span class="{{ $textStyle }}">opened an issue on</span> <span class="{{ $subjectStyle }}">{{ $repo }}</span> 91 {{ else if eq .Type "issue_commented" }} 92 <span class="{{ $textStyle }}">commented on an issue on</span> <span class="{{ $subjectStyle }}">{{ $repo }}</span> 93 {{ else if eq .Type "issue_closed" }} 94 <span class="{{ $textStyle }}">closed an issue on</span> <span class="{{ $subjectStyle }}">{{ $repo }}</span> 95 {{ else if eq .Type "issue_reopen" }} 96 <span class="{{ $textStyle }}">reopened an issue on</span> <span class="{{ $subjectStyle }}">{{ $repo }}</span> 97 {{ else if eq .Type "pull_created" }} 98 <span class="{{ $textStyle }}">created a PR on</span> <span class="{{ $subjectStyle }}">{{ $repo }}</span> 99 {{ else if eq .Type "pull_commented" }} 100 <span class="{{ $textStyle }}">commented on a PR on</span> <span class="{{ $subjectStyle }}">{{ $repo }}</span> 101 {{ else if eq .Type "pull_merged" }} 102 <span class="{{ $textStyle }}">merged a PR on</span> <span class="{{ $subjectStyle }}">{{ $repo }}</span> 103 {{ else if eq .Type "pull_closed" }} 104 <span class="{{ $textStyle }}">closed a PR on</span> <span class="{{ $subjectStyle }}">{{ $repo }}</span> 105 {{ else if eq .Type "pull_reopen" }} 106 <span class="{{ $textStyle }}">reopened a PR on</span> <span class="{{ $subjectStyle }}">{{ $repo }}</span> 107 {{ else if eq .Type "followed" }} 108 <span class="{{ $textStyle }}">followed you</span> 109 {{ else if eq .Type "user_mentioned" }} 110 {{ if .Issue }} 111 <span class="{{ $textStyle }}">mentioned you on an issue in</span> <span class="{{ $subjectStyle }}">{{ $repo }}</span> 112 {{ else if .Pull }} 113 <span class="{{ $textStyle }}">mentioned you on a pull request in</span> <span class="{{ $subjectStyle }}">{{ $repo }}</span> 114 {{ else }} 115 <span class="{{ $textStyle }}">mentioned you in</span> <span class="{{ $subjectStyle }}">{{ $repo }}</span> 116 {{ end }} 117 {{ else if eq .Type "issue_assigned" }} 118 <span class="{{ $textStyle }}">assigned you to an issue on</span> <span class="{{ $subjectStyle }}">{{ $repo }}</span> 119 {{ else if eq .Type "issue_unassigned" }} 120 <span class="{{ $textStyle }}">unassigned you from an issue on</span> <span class="{{ $subjectStyle }}">{{ $repo }}</span> 121 {{ else if eq .Type "pull_assigned" }} 122 <span class="{{ $textStyle }}">assigned you to a PR on</span> <span class="{{ $subjectStyle }}">{{ $repo }}</span> 123 {{ else if eq .Type "pull_unassigned" }} 124 <span class="{{ $textStyle }}">unassigned you from a PR on</span> <span class="{{ $subjectStyle }}">{{ $repo }}</span> 125 {{ end }} 126 </span> 127{{ end }} 128 129{{ define "notificationSummary" }} 130 {{ if .Issue }} 131 <div class="row-start-2 col-start-2 text-sm text-gray-700 dark:text-gray-300 truncate">{{ .Issue.Title }}</div> 132 {{ else if .Pull }} 133 <div class="row-start-2 col-start-2 text-sm text-gray-700 dark:text-gray-300 truncate">{{ .Pull.Title }}</div> 134 {{ end }} 135{{ end }}