mirror of
https://github.com/go-gitea/gitea.git
synced 2026-12-04 15:54:57 +00:00
fix(ui): wrap long unbroken text in profile card and sidebars (#40535)
- Long text without natural break points, such as email addresses, URLs and names containing underscores, no longer overflows the profile card, the package title and sidebar, the repository sidebar, the organization header and the stargazer, watcher and follower cards. - These containers use `overflow-wrap: anywhere`, because the global `overflow-wrap: break-word` does not let flex items shrink below their longest word. - The profile card icon rows share one layout again, so location, email and website align the same way. - An empty topics row no longer adds extra space around "Manage Topics" in the repository sidebar. - Cancelling or saving the topic editor keeps an empty topics row hidden, instead of showing it again until the next page load. - The package view uses its own header class instead of borrowing the issue title one. <img width="688" alt="Before and after" src="https://github.com/user-attachments/assets/d1417853-d6ce-4797-b26d-1a2ead67608c"> Assisted-by: Claude Code:claude-opus-5-5 --------- Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
1 parent
4f45df1727
commit
073a966227
9 files changed
+38
-32
No files matched your search
@@ -1,6 +1,6 @@
|
||||
<div class="ui container flex-container">
|
||||
<div>{{ctx.AvatarUtils.Avatar .Org 100}}</div>
|
||||
<div class="flex-relaxed-list tw-flex-1">
|
||||
<div class="flex-relaxed-list tw-flex-1 tw-break-anywhere">
|
||||
<div class="ui header flex-left-right tw-m-0">
|
||||
<div class="flex-text-block">
|
||||
<span class="tw-text-24">{{.Org.DisplayName}}</span>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
{{svg "octicon-lock" 16 "tw-text-red"}}
|
||||
<span>{{ctx.Locale.Tr "packages.terraform.locked_by" $data.TerraformLock.Who}}</span>
|
||||
</div>
|
||||
<div class="tw-text-xs tw-ml-6 tw-break-anywhere">
|
||||
<div class="tw-text-xs tw-ml-6">
|
||||
{{DateUtils.TimeSince $data.TerraformLock.Created}} ({{$data.TerraformLock.Operation}})
|
||||
</div>
|
||||
{{if .CanWritePackages}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<div class="issue-title-header">
|
||||
<div class="package-header">
|
||||
{{$packageVersionLink := print $.PackageDescriptor.PackageWebLink "/" (PathEscape .PackageDescriptor.Version.LowerVersion)}}
|
||||
<div class="tw-flex tw-flex-wrap tw-items-center tw-gap-2">
|
||||
<h1 class="tw-mb-0">{{.PackageDescriptor.Package.Name}} ({{.PackageDescriptor.Version.Version}})</h1>
|
||||
|
||||
@@ -18,17 +18,17 @@
|
||||
</div>
|
||||
|
||||
{{if .Repository.Website}}
|
||||
<a class="flex-text-block" href="{{.Repository.Website}}">
|
||||
<a class="flex-text-block tw-break-anywhere" href="{{.Repository.Website}}">
|
||||
{{svg "octicon-link" 16 "tw-text-text"}} <span class="tw-text-primary">{{.Repository.Website}}</span>
|
||||
</a>
|
||||
{{end}}
|
||||
|
||||
<div id="repo-topics" class="flex-text-block tw-flex-wrap tw-gap-1 tw-my-1 tw-text-text">
|
||||
<div id="repo-topics" class="flex-text-block tw-flex-wrap tw-gap-1{{if not .Topics}} tw-hidden{{end}}">
|
||||
{{/* !!!! it SHOULD and MUST match the code in repo-home.ts */}}
|
||||
{{range .Topics}}<a class="repo-topic ui large label gt-ellipsis" title={{.Name}} href="{{AppSubUrl}}/explore/repos?q={{.Name}}&topic=1">{{.Name}}</a>{{end}}
|
||||
</div>
|
||||
{{if and .Permission.IsAdmin (not .Repository.IsArchived)}}
|
||||
<button type="button" id="manage_topic" class="btn interact-fg tw-mb-2 tw-text-12">{{ctx.Locale.Tr "repo.topic.manage_topics"}}</button>
|
||||
<button type="button" id="manage_topic" class="btn interact-fg tw-text-12">{{ctx.Locale.Tr "repo.topic.manage_topics"}}</button>
|
||||
<div class="ui form tw-hidden tw-my-2" id="topic_edit">
|
||||
<div class="ui fluid multiple search selection dropdown tw-flex-wrap tw-flex-1">
|
||||
<input type="hidden" name="topics" value="{{range $i, $v := .Topics}}{{.Name}}{{if Eval $i "+" 1 "<" (len $.Topics)}},{{end}}{{end}}">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<div id="profile-avatar-card" class="ui fitted segment">
|
||||
<div id="profile-avatar-card" class="ui fitted segment tw-break-anywhere">
|
||||
<div class="flex-divided-list items-px-default muted-links">
|
||||
<div class="item flex-text-block tw-justify-center tw-p-5">
|
||||
{{if eq .SignedUserID .ContextUser.ID}}
|
||||
@@ -30,14 +30,14 @@
|
||||
</div>
|
||||
|
||||
{{if .UserBlocking}}
|
||||
<div class="item tw-text-red">{{svg "octicon-circle-slash"}} {{ctx.Locale.Tr "user.block.blocked"}}</div>
|
||||
<div class="item flex-text-inline tw-text-red">{{svg "octicon-circle-slash"}} {{ctx.Locale.Tr "user.block.blocked"}}</div>
|
||||
{{if .UserBlocking.Note}}
|
||||
<div class="item tw-text-xs tw-text-red">{{ctx.Locale.Tr "user.block.note"}}: {{.UserBlocking.Note}}</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
{{if .ContextUser.Location}}
|
||||
<div class="item">
|
||||
<div class="item flex-text-inline">
|
||||
{{svg "octicon-location"}}
|
||||
<span class="tw-flex-1">{{.ContextUser.Location}}</span>
|
||||
{{if .ContextUserLocationMapURL}}
|
||||
@@ -48,25 +48,21 @@
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
{{if (eq .SignedUserID .ContextUser.ID)}}
|
||||
{{$isOwnProfile := eq .SignedUserID .ContextUser.ID}}
|
||||
{{if or $isOwnProfile .ShowUserEmail}}
|
||||
<div class="item flex-text-inline">
|
||||
{{svg "octicon-mail"}}
|
||||
<a class="tw-flex-1" href="mailto:{{.ContextUser.Email}}" rel="nofollow">{{.ContextUser.Email}}</a>
|
||||
<a class="flex-text-inline" href="{{AppSubUrl}}/user/settings#privacy-user-settings" data-tooltip-content="{{ctx.Locale.Tr (Iif .ShowUserEmail "user.email_visibility.limited" "user.email_visibility.private")}}">
|
||||
{{svg (Iif .ShowUserEmail "octicon-unlock" "octicon-lock")}}
|
||||
</a>
|
||||
{{if $isOwnProfile}}
|
||||
<a class="flex-text-inline" href="{{AppSubUrl}}/user/settings#privacy-user-settings" data-tooltip-content="{{ctx.Locale.Tr (Iif .ShowUserEmail "user.email_visibility.limited" "user.email_visibility.private")}}">
|
||||
{{svg (Iif .ShowUserEmail "octicon-unlock" "octicon-lock")}}
|
||||
</a>
|
||||
{{end}}
|
||||
</div>
|
||||
{{else}}
|
||||
{{if .ShowUserEmail}}
|
||||
<div class="item">
|
||||
{{svg "octicon-mail"}}
|
||||
<a href="mailto:{{.ContextUser.Email}}" rel="nofollow">{{.ContextUser.Email}}</a>
|
||||
</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
{{if .ContextUser.Website}}
|
||||
<div class="item">
|
||||
<div class="item flex-text-inline">
|
||||
{{svg "octicon-link"}}
|
||||
<a target="_blank" rel="me" href="{{.ContextUser.Website}}">{{.ContextUser.Website}}</a>
|
||||
</div>
|
||||
@@ -78,7 +74,7 @@
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
<div class="item">{{svg "octicon-calendar"}} <span>{{ctx.Locale.Tr "user.joined_on" (DateUtils.AbsoluteShort .ContextUser.CreatedUnix)}}</span></div>
|
||||
<div class="item flex-text-inline">{{svg "octicon-calendar"}} <span>{{ctx.Locale.Tr "user.joined_on" (DateUtils.AbsoluteShort .ContextUser.CreatedUnix)}}</span></div>
|
||||
|
||||
{{if and .Orgs .HasOrgsVisible}}
|
||||
<div class="item flex-relaxed-list">
|
||||
|
||||
@@ -278,7 +278,7 @@ func TestPackageComposer(t *testing.T) {
|
||||
AddBasicAuth(user.Name)
|
||||
viewResp := MakeRequest(t, viewReq, http.StatusOK)
|
||||
viewDoc := NewHTMLParser(t, bytes.NewReader(viewResp.Body.Bytes()))
|
||||
assert.Equal(t, 0, viewDoc.Find(".issue-title-header .ui.basic.label").Length())
|
||||
assert.Equal(t, 0, viewDoc.Find(".package-header .ui.basic.label").Length())
|
||||
|
||||
privatePackageName := privateUser.Name + "/private-composer-package"
|
||||
privatePackageVersion := "1.0.0"
|
||||
@@ -311,7 +311,7 @@ func TestPackageComposer(t *testing.T) {
|
||||
privateViewReq := NewRequest(t, "GET", fmt.Sprintf("/%s/-/packages/composer/%s/%s", privateUser.Name, neturl.PathEscape(privatePackageName), neturl.PathEscape(privatePackageVersion)))
|
||||
privateViewResp := privateSession.MakeRequest(t, privateViewReq, http.StatusOK)
|
||||
privateViewDoc := NewHTMLParser(t, bytes.NewReader(privateViewResp.Body.Bytes()))
|
||||
assert.Equal(t, 1, privateViewDoc.Find(".issue-title-header .ui.basic.label").Length())
|
||||
assert.Equal(t, "Private", privateViewDoc.Find(".issue-title-header .ui.basic.label").First().Text())
|
||||
assert.Equal(t, 1, privateViewDoc.Find(".package-header .ui.basic.label").Length())
|
||||
assert.Equal(t, "Private", privateViewDoc.Find(".package-header .ui.basic.label").First().Text())
|
||||
})
|
||||
}
|
||||
@@ -996,6 +996,7 @@
|
||||
list-style: none;
|
||||
display: flex;
|
||||
gap: var(--gap-block);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
#search-user-box .results .result .image {
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
.package-header {
|
||||
margin-bottom: 18px;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.packages-content {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
@@ -30,6 +35,7 @@
|
||||
.packages-content-right {
|
||||
margin: 0 !important;
|
||||
width: 250px;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
@media (max-width: 767.98px) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {stripTags} from '../utils.ts';
|
||||
import {hideElem, queryElemChildren, showElem} from '../utils/dom.ts';
|
||||
import {queryElemChildren, toggleElem} from '../utils/dom.ts';
|
||||
import {POST} from '../modules/fetch.ts';
|
||||
import {showErrorToast, type Toast} from '../modules/toast.ts';
|
||||
import {fomanticQuery} from '../modules/fomantic/base.ts';
|
||||
@@ -19,16 +19,20 @@ export function initRepoTopicBar() {
|
||||
const topicDropdown = editDiv.querySelector('.ui.dropdown')!;
|
||||
let lastErrorToast: Toast | null = null;
|
||||
|
||||
const setEditing = (editing: boolean) => {
|
||||
toggleElem(editDiv, editing);
|
||||
toggleElem(mgrBtn, !editing);
|
||||
toggleElem(viewDiv, !editing && viewDiv.children.length > 0);
|
||||
};
|
||||
|
||||
mgrBtn.addEventListener('click', () => {
|
||||
hideElem([viewDiv, mgrBtn]);
|
||||
showElem(editDiv);
|
||||
setEditing(true);
|
||||
topicDropdown.querySelector<HTMLInputElement>('input.search')!.focus();
|
||||
});
|
||||
|
||||
document.querySelector('#cancel_topic_edit')!.addEventListener('click', () => {
|
||||
lastErrorToast?.hideToast();
|
||||
hideElem(editDiv);
|
||||
showElem([viewDiv, mgrBtn]);
|
||||
setEditing(false);
|
||||
mgrBtn.focus();
|
||||
});
|
||||
|
||||
@@ -58,8 +62,7 @@ export function initRepoTopicBar() {
|
||||
viewDiv.append(link);
|
||||
}
|
||||
}
|
||||
hideElem(editDiv);
|
||||
showElem([viewDiv, mgrBtn]);
|
||||
setEditing(false);
|
||||
}
|
||||
} else if (response.status === 422) {
|
||||
// how to test: input topic like " invalid topic " (with spaces), and select it from the list, then "Save"
|
||||
|
||||
Reference in new issue
Block a user