Skip to content

Commit b94f630

Browse files
committed
Manage layout when avatars are wrapped in <avatar-fallback>
Make `avatar-fallback` invisible to the layout system, removing them from the document flow. This allows the child .avatar img(s) to behave as if they are direct children of `.Avatar-body`
1 parent 0489e2e commit b94f630

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/* OpenProject AvatarStack - styles for avatar-fallback wrapper elements */
2+
3+
.AvatarStack-body {
4+
/* Make avatar-fallback invisible to layout - inner img acts as direct child */
5+
& avatar-fallback {
6+
display: contents;
7+
}
8+
9+
/*
10+
* Z-index stacking for avatars inside avatar-fallback wrappers.
11+
* The base CSS uses .avatar:first-child/:last-child but those selectors
12+
* don't match when .avatar is inside avatar-fallback (not a direct child).
13+
*/
14+
& avatar-fallback:first-child .avatar {
15+
z-index: 3;
16+
}
17+
18+
& avatar-fallback:nth-child(2) .avatar {
19+
z-index: 2;
20+
}
21+
22+
/* Hide 4th+ wrapped avatars */
23+
& avatar-fallback:nth-child(n + 4) {
24+
display: none;
25+
opacity: 0;
26+
}
27+
28+
/* Show all on hover/focus */
29+
&:hover:not([data-disable-expand]),
30+
&:focus-within:not([data-disable-expand]) {
31+
& avatar-fallback:nth-child(n + 4) {
32+
display: contents;
33+
opacity: 1;
34+
}
35+
}
36+
}

app/components/primer/primer.pcss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
@import "./alpha/action_bar.pcss";
4646

4747
/* OP specifics */
48+
@import "./open_project/avatar_stack.pcss";
4849
@import "./open_project/page_header.pcss";
4950
@import "./open_project/drag_handle.pcss";
5051
@import "./open_project/border_grid.pcss";

0 commit comments

Comments
 (0)