From b0eacfbd42f4d6580cc39d2b671fa18c3b357f84 Mon Sep 17 00:00:00 2001 From: oppiliappan Date: Mon, 29 Sep 2025 15:54:31 +0000 Subject: [PATCH] appview/pages: improve notification styles Signed-off-by: oppiliappan --- appview/models/notifications.go | 30 +++++++++++++++++++++++++++++- appview/pages/templates/notifications/list.html | 34 ++++++++++------------------------ appview/pages/templates/notifications/fragments/item.html | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------- 3 file(s) changed, 103 insertion(s)(+), 39 deletion(s)(-) diff --git a/appview/models/notifications.go b/appview/models/notifications.go --- a/appview/models/notifications.go +++ b/appview/models/notifications.go @@ -1,6 +1,8 @@ package models -import "time" +import ( + "time" +) type NotificationType string @@ -30,6 +32,32 @@ RepoId *int64 IssueId *int64 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 { diff --git a/appview/pages/templates/notifications/list.html b/appview/pages/templates/notifications/list.html --- a/appview/pages/templates/notifications/list.html +++ b/appview/pages/templates/notifications/list.html @@ -1,8 +1,8 @@ {{ define "title" }}notifications{{ end }} {{ define "content" }} -
-
+ -
{{if .Notifications}} -
+
{{range .Notifications}} {{template "notifications/fragments/item" .}} {{end}}
- {{if .HasMore}} -
- -
- {{end}} {{else}} -
-
- {{ i "bell-off" "w-16 h-16" }} +
+
+
+ {{ i "bell-off" "w-16 h-16" }} +
+

No notifications

+

When you receive notifications, they'll appear here.

-

No notifications

-

When you receive notifications, they'll appear here.

{{end}} -
{{ end }} diff --git a/appview/pages/templates/notifications/fragments/item.html b/appview/pages/templates/notifications/fragments/item.html --- a/appview/pages/templates/notifications/fragments/item.html +++ b/appview/pages/templates/notifications/fragments/item.html @@ -1,18 +1,68 @@ {{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}} @@ -37,7 +87,7 @@ {{ i "ban" "w-4 h-4" }} {{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"}} -- tangled.sh