appview/pages: prevent action button overflow in timeline cards #596

merged
opened by oppi.li targeting master from push-rrsulrtnsmtw
Changed files
+63 -63
appview
+1
appview/pages/pages.go
···
type FollowCard struct {
UserDid string
+
LoggedInUser *oauth.User
FollowStatus models.FollowStatus
FollowersCount int64
FollowingCount int64
+10 -33
appview/pages/templates/timeline/fragments/timeline.html
···
{{ $event := index . 1 }}
{{ $follow := $event.Follow }}
{{ $profile := $event.Profile }}
-
{{ $stat := $event.FollowStats }}
+
{{ $followStats := $event.FollowStats }}
+
{{ $followStatus := $event.FollowStatus }}
{{ $userHandle := resolve $follow.UserDid }}
{{ $subjectHandle := resolve $follow.SubjectDid }}
···
{{ template "user/fragments/picHandleLink" $subjectHandle }}
<span class="text-gray-700 dark:text-gray-400 text-xs">{{ template "repo/fragments/time" $follow.FollowedAt }}</span>
</div>
-
<div class="py-4 px-6 drop-shadow-sm rounded bg-white dark:bg-gray-800 flex flex-col md:flex-row md:items-center gap-4">
-
<div class="flex items-center gap-4 flex-1">
-
<div class="flex-shrink-0 max-h-full w-24 h-24">
-
<img alt="" class="object-cover rounded-full p-2" src="{{ fullAvatar $subjectHandle }}" />
-
</div>
-
-
<div class="flex-1 min-h-0 justify-around flex flex-col">
-
<a href="/{{ $subjectHandle }}">
-
<span class="font-bold dark:text-white overflow-hidden text-ellipsis whitespace-nowrap max-w-full">{{ $subjectHandle | truncateAt30 }}</span>
-
</a>
-
{{ with $profile }}
-
{{ with .Description }}
-
<p class="text-sm pb-2 md:pb-2">{{.}}</p>
-
{{ end }}
-
{{ end }}
-
{{ with $stat }}
-
<div class="text-sm flex items-center gap-2 my-2 overflow-hidden text-ellipsis whitespace-nowrap max-w-full">
-
<span class="flex-shrink-0">{{ i "users" "size-4" }}</span>
-
<span id="followers"><a href="/{{ $subjectHandle }}?tab=followers">{{ .Followers }} followers</a></span>
-
<span class="select-none after:content-['·']"></span>
-
<span id="following"><a href="/{{ $subjectHandle }}?tab=following">{{ .Following }} following</a></span>
-
</div>
-
{{ end }}
-
</div>
-
</div>
-
-
{{ if and $root.LoggedInUser (ne $event.FollowStatus.String "IsSelf") }}
-
<div class="flex-shrink-0 w-fit ml-auto">
-
{{ template "user/fragments/follow" (dict "UserDid" $follow.SubjectDid "FollowStatus" $event.FollowStatus) }}
-
</div>
-
{{ end }}
-
</div>
+
{{ template "user/fragments/followCard"
+
(dict
+
"LoggedInUser" $root.LoggedInUser
+
"UserDid" $follow.SubjectDid
+
"Profile" $profile
+
"FollowStatus" $followStatus
+
"FollowersCount" $followStats.Followers
+
"FollowingCount" $followStats.Following) }}
{{ end }}
+8 -1
appview/pages/templates/user/followers.html
···
<p class="text-sm font-bold p-2 dark:text-white">ALL FOLLOWERS</p>
<div id="followers" class="grid grid-cols-1 gap-4 mb-6">
{{ range .Followers }}
-
{{ template "user/fragments/followCard" . }}
+
{{ template "user/fragments/followCard"
+
(dict
+
"LoggedInUser" $.LoggedInUser
+
"UserDid" .UserDid
+
"Profile" .Profile
+
"FollowStatus" .FollowStatus
+
"FollowersCount" .FollowersCount
+
"FollowingCount" .FollowingCount) }}
{{ else }}
<p class="px-6 dark:text-white">This user does not have any followers yet.</p>
{{ end }}
+8 -1
appview/pages/templates/user/following.html
···
<p class="text-sm font-bold p-2 dark:text-white">ALL FOLLOWING</p>
<div id="following" class="grid grid-cols-1 gap-4 mb-6">
{{ range .Following }}
-
{{ template "user/fragments/followCard" . }}
+
{{ template "user/fragments/followCard"
+
(dict
+
"LoggedInUser" $.LoggedInUser
+
"UserDid" .UserDid
+
"Profile" .Profile
+
"FollowStatus" .FollowStatus
+
"FollowersCount" .FollowersCount
+
"FollowingCount" .FollowingCount) }}
{{ else }}
<p class="px-6 dark:text-white">This user does not follow anyone yet.</p>
{{ end }}
+6 -2
appview/pages/templates/user/fragments/follow.html
···
{{ define "user/fragments/follow" }}
<button id="{{ normalizeForHtmlId .UserDid }}"
-
class="btn mt-2 flex gap-2 items-center group"
+
class="btn w-full flex gap-2 items-center group"
{{ if eq .FollowStatus.String "IsNotFollowing" }}
hx-post="/follow?subject={{.UserDid}}"
···
hx-target="#{{ normalizeForHtmlId .UserDid }}"
hx-swap="outerHTML"
>
-
{{ if eq .FollowStatus.String "IsNotFollowing" }}{{ i "user-round-plus" "w-4 h-4" }} follow{{ else }}{{ i "user-round-minus" "w-4 h-4" }} unfollow{{ end }}
+
{{ if eq .FollowStatus.String "IsNotFollowing" }}
+
{{ i "user-round-plus" "w-4 h-4" }} follow
+
{{ else }}
+
{{ i "user-round-minus" "w-4 h-4" }} unfollow
+
{{ end }}
{{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }}
</button>
{{ end }}
+19 -16
appview/pages/templates/user/fragments/followCard.html
···
<img class="object-cover rounded-full p-2" src="{{ fullAvatar $userIdent }}" />
</div>
-
<div class="flex-1 min-h-0 justify-around flex flex-col">
-
<a href="/{{ $userIdent }}">
-
<span class="font-bold dark:text-white overflow-hidden text-ellipsis whitespace-nowrap max-w-full">{{ $userIdent | truncateAt30 }}</span>
-
</a>
-
<p class="text-sm pb-2 md:pb-2">{{.Profile.Description}}</p>
-
<div class="text-sm flex items-center gap-2 my-2 overflow-hidden text-ellipsis whitespace-nowrap max-w-full">
-
<span class="flex-shrink-0">{{ i "users" "size-4" }}</span>
-
<span id="followers"><a href="/{{ $userIdent }}?tab=followers">{{ .FollowersCount }} followers</a></span>
-
<span class="select-none after:content-['·']"></span>
-
<span id="following"><a href="/{{ $userIdent }}?tab=following">{{ .FollowingCount }} following</a></span>
+
<div class="flex flex-col md:flex-row md:items-center md:justify-between gap-2 w-full">
+
<div class="flex-1 min-h-0 justify-around flex flex-col">
+
<a href="/{{ $userIdent }}">
+
<span class="font-bold dark:text-white overflow-hidden text-ellipsis whitespace-nowrap max-w-full">{{ $userIdent | truncateAt30 }}</span>
+
</a>
+
{{ with .Profile }}
+
<p class="text-sm pb-2 md:pb-2">{{.Description}}</p>
+
{{ end }}
+
<div class="text-sm flex items-center gap-2 my-2 overflow-hidden text-ellipsis whitespace-nowrap max-w-full">
+
<span class="flex-shrink-0">{{ i "users" "size-4" }}</span>
+
<span id="followers"><a href="/{{ $userIdent }}?tab=followers">{{ .FollowersCount }} followers</a></span>
+
<span class="select-none after:content-['·']"></span>
+
<span id="following"><a href="/{{ $userIdent }}?tab=following">{{ .FollowingCount }} following</a></span>
+
</div>
</div>
-
</div>
-
-
{{ if ne .FollowStatus.String "IsSelf" }}
-
<div class="max-w-24">
+
{{ if and .LoggedInUser (ne .FollowStatus.String "IsSelf") }}
+
<div class="w-full md:w-auto md:max-w-24 order-last md:order-none">
{{ template "user/fragments/follow" . }}
</div>
-
{{ end }}
+
{{ end }}
+
</div>
</div>
</div>
-
{{ end }}
+
{{ end }}
+10 -10
appview/pages/templates/user/fragments/repoCard.html
···
{{ with $repo }}
<div class="py-4 px-6 gap-1 flex flex-col drop-shadow-sm rounded bg-white dark:bg-gray-800 min-h-32">
<div class="font-medium dark:text-white flex items-center justify-between">
-
<div class="flex items-center">
-
{{ if .Source }}
-
{{ i "git-fork" "w-4 h-4 mr-1.5 shrink-0" }}
-
{{ else }}
-
{{ i "book-marked" "w-4 h-4 mr-1.5 shrink-0" }}
-
{{ end }}
-
+
<div class="flex items-center min-w-0 flex-1 mr-2">
+
{{ if .Source }}
+
{{ i "git-fork" "w-4 h-4 mr-1.5 shrink-0" }}
+
{{ else }}
+
{{ i "book-marked" "w-4 h-4 mr-1.5 shrink-0" }}
+
{{ end }}
{{ $repoOwner := resolve .Did }}
{{- if $fullName -}}
-
<a href="/{{ $repoOwner }}/{{ .Name }}" class="truncate">{{ $repoOwner }}/{{ .Name }}</a>
+
<a href="/{{ $repoOwner }}/{{ .Name }}" class="truncate min-w-0">{{ $repoOwner }}/{{ .Name }}</a>
{{- else -}}
-
<a href="/{{ $repoOwner }}/{{ .Name }}" class="truncate">{{ .Name }}</a>
+
<a href="/{{ $repoOwner }}/{{ .Name }}" class="truncate min-w-0">{{ .Name }}</a>
{{- end -}}
</div>
-
{{ if and $starButton $root.LoggedInUser }}
+
<div class="shrink-0">
{{ template "repo/fragments/repoStar" $starData }}
+
</div>
{{ end }}
</div>
{{ with .Description }}
+1
appview/state/profile.go
···
profile.Did = did
}
followCards[i] = pages.FollowCard{
+
LoggedInUser: loggedInUser,
UserDid: did,
FollowStatus: followStatus,
FollowersCount: followStats.Followers,