1
1
import * as React from "react" ;
2
- import { Trans } from 'gatsby-plugin-react-i18next' ;
3
2
import styled from 'styled-components' ;
4
3
import { FiLinkedin , FiGithub , FiChevronLeft , FiChevronRight } from 'react-icons/fi' ;
5
4
import { GatsbyImage } from "gatsby-plugin-image" ;
6
- import team from '../assets/content/team.json' ;
7
5
8
- export default function CarouselCard ( { pic, index, count, teamIndex, setTeamIndex } ) {
6
+ export default function CarouselCard ( { member, index, count, teamIndex, setTeamIndex } ) {
7
+ const { name, title, linkedin, github, image, highlights } = member
8
+
9
9
// handle carousel navigation
10
10
const handlePrev = ( ) => {
11
11
setTeamIndex ( teamIndex - 1 )
@@ -14,56 +14,37 @@ export default function CarouselCard({ pic, index, count, teamIndex, setTeamInde
14
14
setTeamIndex ( teamIndex + 1 )
15
15
}
16
16
17
- // set the person based on the image
18
- const person = team . content . filter ( member => {
19
- return member . image === pic . node . base ;
20
- } ) [ 0 ]
21
-
22
17
return (
23
18
< CarouselCardStyles className = { `${ teamIndex === index ? "active" : "" } ` } >
24
19
< div className = "flex md:flex-row-reverse overflow-hidden bg-peach md:bg-white" >
25
20
< GatsbyImage
26
- image = { pic . node . childImageSharp . gatsbyImageData }
21
+ image = { image . childImageSharp . gatsbyImageData }
27
22
className = "w-1/3-vw h-1/3-vw md:w-1/3 md:h-auto"
28
23
imgStyle = { { objectPosition : `top center` } }
29
- alt = { pic . node . base . split ( '.' ) [ 0 ] }
30
- width = { 500 } />
31
-
24
+ alt = { name }
25
+ />
32
26
< div className = "p-4 md:p-8 w-2/3" >
33
27
< div className = "flex flex-col md:flex-row justify-between h-full md:h-auto" >
34
28
< div >
35
- < h3 className = "sm:text-2xl sm:mb-2" > { person . name } </ h3 >
36
- < p className = "sm:text-xl" >
37
- < Trans > { person . title } </ Trans >
38
- </ p >
29
+ < h3 className = "sm:text-2xl sm:mb-2" > { name } </ h3 >
30
+ < p className = "sm:text-xl" > { title } </ p >
39
31
</ div >
40
32
< div className = "text-xl sm:text-2xl md:text-3xl flex" >
41
- < a href = { person . linkedin } aria-label = "social media icon Linkedin" target = "_blank" rel = "noreferrer" > < FiLinkedin className = "mr-3" /> </ a >
42
- < a href = { person . github } aria-label = "social media icon Github" target = "_blank" rel = "noreferrer" > < FiGithub className = "md:ml-3" /> </ a >
33
+ < a href = { linkedin } aria-label = "social media icon Linkedin" target = "_blank" rel = "noreferrer" > < FiLinkedin className = "mr-3" /> </ a >
34
+ < a href = { github } aria-label = "social media icon Github" target = "_blank" rel = "noreferrer" > < FiGithub className = "md:ml-3" /> </ a >
43
35
</ div >
44
36
</ div >
45
-
37
+ { /* Highlights for large screens, show all */ }
46
38
< ul className = "py-4 hidden md:block" style = { { height : `312px` } } >
47
- { person . highlights . map ( hl => {
48
- return (
49
- < li key = { hl } >
50
- < Trans > { hl } </ Trans >
51
- </ li >
52
- )
53
- } ) }
39
+ { highlights . map ( hl => < li key = { hl } > { hl } </ li > ) }
54
40
</ ul >
55
41
</ div >
56
42
</ div >
43
+ { /* highlights for small screen, show first few */ }
57
44
< ul className = "py-4 block md:hidden" >
58
- { person . highlights . slice ( 0 , 3 ) . map ( ( hl , i ) => {
59
- return (
60
- < li key = { hl + i } >
61
- < Trans > { hl } </ Trans >
62
- </ li >
63
- )
64
- } ) }
45
+ { highlights . slice ( 0 , 3 ) . map ( ( hl , i ) => < li key = { hl + i } > { hl } </ li > ) }
65
46
</ ul >
66
- { /* Button */ }
47
+ { /* Button to navigate prev and next */ }
67
48
< div className = "carousel-btns" >
68
49
< button onClick = { handlePrev } className = "text-2xl p-4" disabled = { index === 0 } >
69
50
< FiChevronLeft />
0 commit comments