1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-11-24 08:57:03 -05:00

feat(ui): highlight user mention in comments and commit messages

This commit is contained in:
0ko 2024-11-10 17:57:32 +05:00 committed by Otto Richter
parent bd42f677b4
commit 634519e891
3 changed files with 36 additions and 0 deletions

View file

@ -26,6 +26,7 @@
.ui.secondary.menu .dropdown.item > .menu { margin-top: 0; } .ui.secondary.menu .dropdown.item > .menu { margin-top: 0; }
</style> </style>
</noscript> </noscript>
{{template "shared/user/mention_highlight" .}}
{{template "base/head_opengraph" .}} {{template "base/head_opengraph" .}}
{{template "base/head_style" .}} {{template "base/head_style" .}}
{{template "custom/header" .}} {{template "custom/header" .}}

View file

@ -0,0 +1,14 @@
{{if .IsSigned}}
<style>
.comment,
.commit-summary,
.commit-body {
.mention[href="{{AppSubUrl}}/{{.SignedUser.Name}}" i] {
background-color: var(--color-primary-alpha-30);
color: var(--color-primary-dark-2);
border-radius: 5px;
padding: 1px 4px;
}
}
</style>
{{end}}

View file

@ -0,0 +1,21 @@
// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: GPL-3.0-or-later
package integration
import (
"net/http"
"testing"
"github.com/stretchr/testify/assert"
)
func TestHeadMentionCSS(t *testing.T) {
userSession := loginUser(t, "user2")
resp := userSession.MakeRequest(t, NewRequest(t, "GET", "/"), http.StatusOK)
assert.Contains(t, resp.Body.String(), `.mention[href="/user2" i]`)
guestSession := emptyTestSession(t)
resp = guestSession.MakeRequest(t, NewRequest(t, "GET", "/"), http.StatusOK)
assert.NotContains(t, resp.Body.String(), `.mention[href="`)
}