0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-06-11 01:15:21 +02:00
gitea/web_src/css/avatar.css
bircni 54916f708e
feat: Add avatar stacks (#37594)
Parse `Co-authored-by:` trailers from commit messages and surface
contributors as an avatar stack across the commit page, commits list, PR
commits tab, latest-commit row, blame, graph, and dashboard feed.

- Up to 10 visible 20px avatars, GitHub-style overlap (6px first stride,
4px between subsequent), `+N` chip for the rest.
- Label: 1 → name; 2 → `<a> and <b>`; 3+ → `<N> people` opens a Tippy
popup with all participants.
- Names and avatars link to the repo's commits-by-author search; fall
back to profile or `mailto:`.
- Trailer parsing uses `net/mail.ParseAddress`, scans only the trailing
paragraph, filters out the commit's own author/committer.
- Drops the non-standard `Co-committed-by:` emission on squash merge and
web edits.

Devtest: `/devtest/coauthor-avatars`.

Fixes #25521

----
<img width="353" height="277" alt="image"
src="https://github.com/user-attachments/assets/72092ceb-97ca-4b09-9557-0b72d3c5458e"
/>

<img width="533" height="328"
src="https://github.com/user-attachments/assets/11d0c8f8-8b3f-4f2e-9993-879f1c06bcc5"
/>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Giteabot <teabot@gitea.io>
2026-06-08 17:16:22 +00:00

126 lines
3.1 KiB
CSS

img.ui.avatar,
.ui.avatar img,
.ui.avatar svg {
border-radius: var(--border-radius);
object-fit: contain;
aspect-ratio: 1;
}
.avatar-stack-names {
display: inline-flex;
align-items: center;
align-self: center;
gap: 4px;
white-space: nowrap;
vertical-align: middle;
}
.avatar-stack-names > a.muted,
.avatar-stack-names > .avatar-stack-popup-trigger {
overflow: hidden;
text-overflow: ellipsis;
max-width: 240px;
}
/* use semibold for latest commit author */
.latest-commit .avatar-stack-names > a,
.latest-commit .avatar-stack-names > .avatar-stack-popup-trigger {
font-weight: var(--font-weight-semibold);
}
/* template emits children reversed; row-reverse re-orders visually and keeps the author last-painted (on top) */
.avatar-stack {
display: inline-flex;
align-items: center;
flex-direction: row-reverse;
}
.avatar-stack > * {
margin-left: -16px;
transition: transform 0.15s ease, opacity 0.15s ease;
position: relative;
display: inline-flex;
}
.avatar-stack > *:last-child { margin-left: 0; }
.avatar-stack > *:nth-last-child(2) { margin-left: -14px; }
/* hover spreads via transform (no layout shift); positions count from visual-left = last DOM child = :nth-last-child */
.avatar-stack:hover > *:nth-last-child(2) { transform: translateX(14px); }
.avatar-stack:hover > *:nth-last-child(3) { transform: translateX(30px); }
.avatar-stack:hover > *:nth-last-child(4) { transform: translateX(46px); }
.avatar-stack:hover > *:nth-last-child(5) { transform: translateX(62px); }
.avatar-stack:hover > *:nth-last-child(6) { transform: translateX(78px); }
.avatar-stack:hover > *:nth-last-child(7) { transform: translateX(94px); }
.avatar-stack:hover > *:nth-last-child(8) { transform: translateX(110px); }
.avatar-stack:hover > *:nth-last-child(9) { transform: translateX(126px); }
.avatar-stack:hover > *:nth-last-child(10) { transform: translateX(142px); }
.avatar-stack:hover > *:nth-last-child(11) { transform: translateX(158px); }
.avatar-stack .avatar {
border: 1px solid var(--color-body);
background: var(--color-body);
transition: border-color 0.15s ease, background-color 0.15s ease;
}
.avatar-stack:hover .avatar {
background-color: var(--color-body);
}
.avatar-stack-overflow-chip {
align-items: center;
justify-content: center;
width: 0;
height: 20px;
margin-left: 0;
border: 0 solid var(--color-body);
border-radius: var(--border-radius);
color: var(--color-text);
font-weight: var(--font-weight-semibold);
overflow: hidden;
opacity: 0;
transition: all 0.15s ease;
}
.avatar-stack:hover .avatar-stack-overflow-chip {
width: 20px;
margin-left: -16px;
border-width: 1px;
opacity: 1;
}
.avatar-stack-popup-trigger {
cursor: pointer;
background: none;
border: none;
padding: 0;
font: inherit;
color: inherit;
}
.avatar-stack-popup-trigger:hover {
color: var(--color-primary);
}
.avatar-stack-popup {
min-width: 200px;
display: flex;
flex-direction: column;
padding: 4px 0;
}
.avatar-stack-popup > a {
padding: 6px 12px;
gap: 8px;
}
.avatar-stack-popup > a:hover {
background: var(--color-hover);
}
@media (max-width: 767.98px) {
.avatar-stack-names {
max-width: 80px;
}
}