From 524a8dfa1e5e3c32b0c041232b6d8cc4c4467398 Mon Sep 17 00:00:00 2001 From: oppiliappan Date: Mon, 29 Sep 2025 16:54:31 +0100 Subject: [PATCH] appview/pages: improve notification styles Change-Id: qwrnmrzwzunypnprpnlplozqksrkymxz Signed-off-by: oppiliappan --- appview/models/notifications.go | 30 ++++++- .../notifications/fragments/item.html | 78 +++++++++++++++---- .../pages/templates/notifications/list.html | 34 +++----- 3 files changed, 103 insertions(+), 39 deletions(-) diff --git a/appview/models/notifications.go b/appview/models/notifications.go index bb467fc2..441f3df5 100644 --- a/appview/models/notifications.go +++ b/appview/models/notifications.go @@ -1,6 +1,8 @@ package models -import "time" +import ( + "time" +) type NotificationType string @@ -32,6 +34,32 @@ type Notification struct { PullId *int64 } +// lucide icon that represents this notification +func (n *Notification) Icon() string { + switch n.Type { + case NotificationTypeRepoStarred: + return "star" + case NotificationTypeIssueCreated: + return "circle-dot" + case NotificationTypeIssueCommented: + return "message-square" + case NotificationTypeIssueClosed: + return "ban" + case NotificationTypePullCreated: + return "git-pull-request-create" + case NotificationTypePullCommented: + return "message-square" + case NotificationTypePullMerged: + return "git-merge" + case NotificationTypePullClosed: + return "git-pull-request-closed" + case NotificationTypeFollowed: + return "user-plus" + default: + return "" + } +} + type NotificationWithEntity struct { *Notification Repo *Repo diff --git a/appview/pages/templates/notifications/fragments/item.html b/appview/pages/templates/notifications/fragments/item.html index 7d663703..708e2b3d 100644 --- a/appview/pages/templates/notifications/fragments/item.html +++ b/appview/pages/templates/notifications/fragments/item.html @@ -1,19 +1,69 @@ {{define "notifications/fragments/item"}} -
- {{if .Issue}} - {{template "issueNotification" .}} - {{else if .Pull}} - {{template "pullNotification" .}} - {{else if .Repo}} - {{template "repoNotification" .}} - {{else if eq .Type "followed"}} - {{template "followNotification" .}} - {{else}} - {{template "genericNotification" .}} - {{end}} -
+
+ + {{ template "notificationIcon" . }} +
+ {{ template "notificationHeader" . }} + {{ template "notificationSummary" . }} +
+ +
{{end}} +{{ define "notificationIcon" }} +
+ +
+ {{ i .Icon "size-3 text-black dark:text-white" }} +
+
+{{ end }} + +{{ define "notificationHeader" }} + {{ $actor := resolve .ActorDid }} + + {{ $actor }} + {{ if eq .Type "repo_starred" }} + starred {{ resolve .Repo.Did }}/{{ .Repo.Name }} + {{ else if eq .Type "issue_created" }} + opened an issue + {{ else if eq .Type "issue_commented" }} + commented on an issue + {{ else if eq .Type "issue_closed" }} + closed an issue + {{ else if eq .Type "pull_created" }} + created a pull request + {{ else if eq .Type "pull_commented" }} + commented on a pull request + {{ else if eq .Type "pull_merged" }} + merged a pull request + {{ else if eq .Type "pull_closed" }} + closed a pull request + {{ else if eq .Type "followed" }} + followed you + {{ else }} + {{ end }} +{{ end }} + +{{ define "notificationSummary" }} + {{ if eq .Type "repo_starred" }} + + {{ else if .Issue }} + #{{.Issue.IssueId}} {{.Issue.Title}} on {{resolve .Repo.Did}}/{{.Repo.Name}} + {{ else if .Pull }} + #{{.Pull.PullId}} {{.Pull.Title}} on {{resolve .Repo.Did}}/{{.Repo.Name}} + {{ else if eq .Type "followed" }} + + {{ else }} + {{ end }} +{{ end }} + {{define "issueNotification"}} {{$url := printf "/%s/%s/issues/%d" (resolve .Repo.Did) .Repo.Name .Issue.IssueId}} {{end}} - {{template "user/fragments/picHandle" (resolve .ActorDid)}} + {{template "user/fragments/picHandle" .ActorDid}} {{if eq .Type "issue_created"}} opened issue {{else if eq .Type "issue_commented"}} diff --git a/appview/pages/templates/notifications/list.html b/appview/pages/templates/notifications/list.html index 7362e6db..e44177ea 100644 --- a/appview/pages/templates/notifications/list.html +++ b/appview/pages/templates/notifications/list.html @@ -1,8 +1,8 @@ {{ define "title" }}notifications{{ end }} {{ define "content" }} -