Skip to content

Commit 3ed385f

Browse files
author
Carms Ng
committed
[FIX] Avatar Component overflow
1 parent bfee47e commit 3ed385f

File tree

1 file changed

+40
-14
lines changed

1 file changed

+40
-14
lines changed

src/components/StackedAvatar.js

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import * as React from 'react';
1+
import React from 'react';
22
import { graphql, useStaticQuery } from 'gatsby';
33
import { GatsbyImage } from 'gatsby-plugin-image';
4+
import styled from 'styled-components';
45

56
export default function StackedAvatar({ sectionRefs, setTeamIndex, pausedRef }) {
67
// Query all team name and image sorted by image file name
@@ -47,24 +48,17 @@ export default function StackedAvatar({ sectionRefs, setTeamIndex, pausedRef })
4748
const members = allMembersJson.nodes.map((member) => member.en);
4849

4950
return (
50-
<div className="py-8 flex">
51+
<AvatarsStyles>
5152
{members.map((member, i) => {
5253
const zIndex = members.length - i;
53-
const translateX = i * -30;
5454
return (
5555
<button
56+
type="button"
5657
data-team={i}
5758
onClick={handleClick}
5859
key={`avatar-${member.name}`}
5960
style={{
60-
width: '75px',
61-
height: '75px',
62-
zIndex: `${zIndex}`,
63-
border: '1px solid var(--white)',
64-
borderRadius: '50%',
65-
background: 'var(--white)',
66-
transform: `translateX(${translateX}%)`,
67-
position: 'relative',
61+
zIndex,
6862
}}
6963
>
7064
<GatsbyImage
@@ -75,8 +69,40 @@ export default function StackedAvatar({ sectionRefs, setTeamIndex, pausedRef })
7569
/>
7670
</button>
7771
);
78-
}).slice(0, 7)}
79-
{/* TODO: handle representation for members with count above 7 */}
80-
</div>
72+
})}
73+
</AvatarsStyles>
8174
);
8275
}
76+
77+
const AvatarsStyles = styled.div`
78+
margin: 1rem 0;
79+
height: 100%;
80+
max-width: calc(100vw - 40px);
81+
overflow-x: scroll;
82+
white-space: nowrap;
83+
-ms-overflow-style: none;
84+
scrollbar-width: none;
85+
&::-webkit-scrollbar {
86+
display: none;
87+
}
88+
89+
> button {
90+
display: inline-table;
91+
height: 100%;
92+
position: relative;
93+
94+
&:not(:first-child) {
95+
margin-left: -25px;
96+
}
97+
> div {
98+
display: table-cell;
99+
vertical-align: middle;
100+
}
101+
}
102+
@media (min-width: 1024px) {
103+
> button {
104+
margin: 0 1rem;
105+
}
106+
margin: 0 auto;
107+
}
108+
`;

0 commit comments

Comments
 (0)