Skip to content

Improve issue card #26561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions routers/web/repo/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func Projects(ctx *context.Context) {

ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(unit.TypeProjects)
ctx.Data["IsShowClosed"] = isShowClosed
ctx.Data["IsProjectsPage"] = true
ctx.Data["PageIsProjects"] = true
ctx.Data["SortType"] = sortType

ctx.HTML(http.StatusOK, tplProjects)
Expand Down Expand Up @@ -371,7 +371,7 @@ func ViewProject(ctx *context.Context) {
return
}

ctx.Data["IsProjectsPage"] = true
ctx.Data["PageIsProjects"] = true
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(unit.TypeProjects)
ctx.Data["Project"] = project
ctx.Data["IssuesMap"] = issuesMap
Expand Down
2 changes: 1 addition & 1 deletion templates/repo/header.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
{{end}}

{{if and (not .UnitProjectsGlobalDisabled) (.Permission.CanRead $.UnitTypeProjects)}}
<a href="{{.RepoLink}}/projects" class="{{if .IsProjectsPage}}active {{end}}item">
<a href="{{.RepoLink}}/projects" class="{{if .PageIsProjects}}active {{end}}item">
{{svg "octicon-project"}} {{ctx.Locale.Tr "repo.project_board"}}
{{if .Repository.NumOpenProjects}}
<span class="ui small label">{{CountFmt .Repository.NumOpenProjects}}</span>
Expand Down
34 changes: 18 additions & 16 deletions templates/repo/issue/card.tmpl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{{with .Issue}}
{{if eq $.Page.Project.CardType 1}}{{/* Images and Text*/}}
<div class="card-attachment-images">
<div class="issue-card-content card-attachment-images">
{{range (index $.Page.issuesAttachmentMap .ID)}}
<img src="{{.DownloadURL}}" alt="{{.Name}}" />
{{end}}
</div>
{{end}}
<div class="content gt-p-0 gt-w-full">
<div class="issue-card-content">
<div class="gt-df gt-items-start">
<div class="issue-card-icon">
{{template "shared/issueicon" .}}
Expand All @@ -18,7 +18,7 @@
</a>
{{end}}
</div>
<div class="meta gt-my-2">
<div class="gt-my-2">
<span class="text light grey muted-links">
{{if not $.Page.Repository}}{{.Repo.FullName}}{{end}}#{{.Index}}
{{$timeStr := TimeSinceUnix .GetLastEventTimestamp ctx.Locale}}
Expand All @@ -32,16 +32,16 @@
</span>
</div>
{{if .MilestoneID}}
<div class="meta gt-my-2">
<a class="milestone" href="{{.Repo.Link}}/milestone/{{.MilestoneID}}">
<div class="gt-df gt-my-2">
<a class="sidebar-item-link muted" href="{{.Repo.Link}}/milestone/{{.MilestoneID}}">
{{svg "octicon-milestone" 16 "gt-mr-2 gt-vm"}}
<span class="gt-vm">{{.Milestone.Name}}</span>
{{.Milestone.Name}}
</a>
</div>
{{end}}
{{if $.Page.LinkedPRs}}
{{range index $.Page.LinkedPRs .ID}}
<div class="meta gt-my-2">
<div class="gt-my-2">
<a href="{{$.Issue.Repo.Link}}/pulls/{{.Index}}">
<span class="gt-m-0 text {{if .PullRequest.HasMerged}}purple{{else if .IsClosed}}red{{else}}green{{end}}">{{svg "octicon-git-merge" 16 "gt-mr-2 gt-vm"}}</span>
<span class="gt-vm">{{.Title}} <span class="text light grey">#{{.Index}}</span></span>
Expand All @@ -58,16 +58,18 @@
{{end}}
</div>

{{if or .Labels .Assignees}}
<div class="extra content labels-list gt-p-0 gt-pt-2">
{{range .Labels}}
<a target="_blank" href="{{$.Issue.Repo.Link}}/issues?labels={{.ID}}">{{RenderLabel ctx .}}</a>
{{if .Labels}}
<div class="issue-card-content labels-list">
{{range .Labels}}0
<a {{if $.PageIsProjects}}target="_blank"{{end}} href="{{$.Issue.Repo.Link}}/issues?labels={{.ID}}">{{RenderLabel ctx .}}</a>
{{end}}
</div>
{{end}}
{{if .Assignees}}
<div class="issue-card-content gt-df">
{{range .Assignees}}
<a class="flex-text-inline" {{if $.PageIsProjects}}target="_blank"{{end}} href="{{.HomeLink}}" data-tooltip-content="{{ctx.Locale.Tr "repo.projects.column.assigned_to"}} {{.Name}}">{{ctx.AvatarUtils.Avatar . 28 "mini gt-mr-3"}}</a>
{{end}}
<div class="right floated">
{{range .Assignees}}
<a target="_blank" href="{{.HomeLink}}" data-tooltip-content="{{ctx.Locale.Tr "repo.projects.column.assigned_to"}} {{.Name}}">{{ctx.AvatarUtils.Avatar . 28 "mini gt-mr-3"}}</a>
{{end}}
</div>
</div>
{{end}}
{{end}}
9 changes: 8 additions & 1 deletion web_src/css/features/projects.css
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
}

.card-attachment-images {
display: inline-block;
display: flex;
flex-wrap: wrap;
white-space: nowrap;
overflow: hidden;
text-align: center;
Expand All @@ -82,12 +83,18 @@
.card-attachment-images img {
display: inline-block;
max-height: 50px;
max-width: 100%;
border-radius: var(--border-radius);
margin-right: 2px;
Copy link
Member

@silverwind silverwind Aug 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
margin-right: 2px;
margin-right: 2px;
aspect-ratio: 1;

Better to have this just in case, to ensure the image maintains aspect ratio when scaling width/height.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this overlap be a problem?

https://jsfiddle.net/fmapw0ye/

image

Copy link
Member

@silverwind silverwind Aug 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fix that overlap, does require max-height on the parent. Better would be direct max-height on the img without any parent.

max-width: 100%;
max-height: 100%;
aspect-ratio: 1;

}

.card-attachment-images img:not(:first-child) {
padding-top: 0.25rem;
}

.card-attachment-images img:only-child {
max-height: 90px;
max-width: 100%;
margin: auto;
}

Expand Down
8 changes: 8 additions & 0 deletions web_src/css/repo/issue-card.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
background: var(--color-card);
}

.issue-card .issue-card-content {
width: 100%;
}

.issue-card .issue-card-content:not(:first-child) {
padding-top: 0.25rem;
}

.issue-card-icon,
.issue-card-unpin {
margin-top: 1px;
Expand Down