1
- import * as React from 'react' ;
1
+ import React from 'react' ;
2
2
import { graphql , useStaticQuery } from 'gatsby' ;
3
3
import { GatsbyImage } from 'gatsby-plugin-image' ;
4
+ import styled from 'styled-components' ;
4
5
5
6
export default function StackedAvatar ( { sectionRefs, setTeamIndex, pausedRef } ) {
6
7
// Query all team name and image sorted by image file name
@@ -47,24 +48,17 @@ export default function StackedAvatar({ sectionRefs, setTeamIndex, pausedRef })
47
48
const members = allMembersJson . nodes . map ( ( member ) => member . en ) ;
48
49
49
50
return (
50
- < div className = "py-8 flex" >
51
+ < AvatarsStyles >
51
52
{ members . map ( ( member , i ) => {
52
53
const zIndex = members . length - i ;
53
- const translateX = i * - 30 ;
54
54
return (
55
55
< button
56
+ type = "button"
56
57
data-team = { i }
57
58
onClick = { handleClick }
58
59
key = { `avatar-${ member . name } ` }
59
60
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,
68
62
} }
69
63
>
70
64
< GatsbyImage
@@ -75,8 +69,40 @@ export default function StackedAvatar({ sectionRefs, setTeamIndex, pausedRef })
75
69
/>
76
70
</ button >
77
71
) ;
78
- } ) . slice ( 0 , 7 ) }
79
- { /* TODO: handle representation for members with count above 7 */ }
80
- </ div >
72
+ } ) }
73
+ </ AvatarsStyles >
81
74
) ;
82
75
}
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