Skip to content

Commit 5111961

Browse files
authored
Merge pull request #1722 from recodehive/copilot/fix-avatar-stack-multiple-authors
feat: avatar stack for multiple-author blog post headers
2 parents 42a0d79 + c143ea3 commit 5111961

2 files changed

Lines changed: 52 additions & 28 deletions

File tree

src/theme/BlogPostItem/Header/index.tsx

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,14 @@ export default function BlogPostItemHeaderWrapper(props: Props): JSX.Element {
9797
<div className={styles.metaRow}>
9898
{authors.length > 0 && (
9999
<div className={styles.authorsPart}>
100-
{authors.map((author, idx) => (
101-
<React.Fragment key={author.handle ?? `${author.name ?? ""}-${idx}`}>
102-
{idx > 0 && (
103-
<span className={styles.authorSep} aria-hidden="true">
104-
&amp;
105-
</span>
106-
)}
107-
<div className={styles.authorPart}>
100+
{/* Stacked avatars */}
101+
<div className={styles.avatarStack}>
102+
{authors.map((author, idx) => (
103+
<div
104+
key={author.handle ?? `${author.name ?? ""}-${idx}`}
105+
className={styles.avatarStackItem}
106+
style={{ zIndex: authors.length - idx }}
107+
>
108108
{author.avatar ? (
109109
<img
110110
className={styles.avatar}
@@ -117,22 +117,33 @@ export default function BlogPostItemHeaderWrapper(props: Props): JSX.Element {
117117
{author.name?.charAt(0).toUpperCase()}
118118
</div>
119119
)}
120-
{author.handle &&
121-
(author.url ? (
122-
<Link
123-
to={author.url}
124-
className={styles.handle}
125-
target="_blank"
126-
rel="noopener noreferrer"
127-
>
128-
{author.handle}
129-
</Link>
130-
) : (
131-
<span className={styles.handle}>{author.handle}</span>
132-
))}
133120
</div>
134-
</React.Fragment>
135-
))}
121+
))}
122+
</div>
123+
{/* Handles after the stack (only authors with a handle) */}
124+
{authors
125+
.filter((author) => author.handle)
126+
.map((author, idx) => (
127+
<React.Fragment key={author.handle}>
128+
{idx > 0 && (
129+
<span className={styles.authorSep} aria-hidden="true">
130+
,
131+
</span>
132+
)}
133+
{author.url ? (
134+
<Link
135+
to={author.url}
136+
className={styles.handle}
137+
target="_blank"
138+
rel="noopener noreferrer"
139+
>
140+
{author.handle}
141+
</Link>
142+
) : (
143+
<span className={styles.handle}>{author.handle}</span>
144+
)}
145+
</React.Fragment>
146+
))}
136147
</div>
137148
)}
138149

src/theme/BlogPostItem/Header/styles.module.css

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,36 @@
3535
font-weight: 500;
3636
}
3737

38-
.authorPart {
38+
/* ── Stacked overlapping avatars ── */
39+
.avatarStack {
3940
display: flex;
4041
align-items: center;
41-
gap: 0.45rem;
4242
}
4343

44-
.avatar,
45-
.avatarFallback {
44+
.avatarStackItem {
4645
width: 32px;
4746
height: 32px;
4847
border-radius: 50%;
48+
overflow: hidden;
49+
flex-shrink: 0;
50+
border: 2px solid var(--ifm-background-color, #fff);
51+
}
52+
53+
.avatarStackItem:not(:first-child) {
54+
margin-left: -10px;
55+
}
56+
57+
.avatar,
58+
.avatarFallback {
59+
width: 100%;
60+
height: 100%;
61+
border-radius: 50%;
4962
flex-shrink: 0;
5063
}
5164

5265
.avatar {
5366
object-fit: cover;
54-
border: 1px solid var(--ifm-color-emphasis-300);
67+
display: block;
5568
}
5669

5770
.avatarFallback {

0 commit comments

Comments
 (0)