@@ -3,6 +3,7 @@ import Footer from './Footer';
3
3
// import {API_DOMAIN} from '../constants';
4
4
import { fetcher } from '../utils/commonFunctions' ;
5
5
6
+ import { useTransition , animated } from '@react-spring/web' ;
6
7
import classnames from 'classnames' ;
7
8
import { useMemo , useEffect } from 'react' ;
8
9
import {
@@ -15,12 +16,11 @@ import {
15
16
import { Helmet } from 'react-helmet' ;
16
17
import useSWR from 'swr' ;
17
18
18
- const VOLUNTEERS_DOMAIN =
19
- 'https://raw.githubusercontent.com/shuklaayush/testing/gh-pages' ;
20
- const PLACEHOLDER_IMG =
21
- 'https://images.assetsdelivery.com/compings_v2/apoev/apoev1901/apoev190100061.jpg' ;
19
+ const VOLUNTEERS_DOMAIN = 'https://volunteers.covid19india.org' ;
20
+ // 'https://raw.githubusercontent.com/shuklaayush/testing/gh-pages';
21
+ const PLACEHOLDER_IMG = 'placeholder.jpg' ;
22
22
23
- function Member ( { className, name, bio, link, image, socials = { } } ) {
23
+ function Member ( { className, style , name, bio, link, image, socials = { } } ) {
24
24
const socialIcons = useMemo (
25
25
( ) => ( {
26
26
github : < GitHub size = { 16 } /> ,
@@ -32,10 +32,10 @@ function Member({className, name, bio, link, image, socials = {}}) {
32
32
) ;
33
33
34
34
return (
35
- < div className = { classnames ( 'Member' , className ) } >
35
+ < animated . div className = { classnames ( 'Member' , className ) } { ... { style } } >
36
36
{ link && < a href = { link } target = "_blank" rel = "noopener noreferrer" > </ a > }
37
37
< img
38
- src = { image ? `${ VOLUNTEERS_DOMAIN } /images/${ image } ` : PLACEHOLDER_IMG }
38
+ src = { `${ VOLUNTEERS_DOMAIN } /images/${ image ? image : PLACEHOLDER_IMG } ` }
39
39
/>
40
40
< div className = "details" >
41
41
< h2 className = "name" > { name } </ h2 >
@@ -62,16 +62,26 @@ function Member({className, name, bio, link, image, socials = {}}) {
62
62
< ExternalLink size = { 16 } />
63
63
</ div >
64
64
) }
65
- </ div >
65
+ </ animated . div >
66
66
) ;
67
67
}
68
68
69
- // TODO: Animations, lazy -loading and content loader
69
+ // TODO: Lazy -loading and content loader
70
70
function Volunteers ( ) {
71
71
const { data} = useSWR ( `${ VOLUNTEERS_DOMAIN } /data.json` , fetcher , {
72
72
suspense : true ,
73
73
} ) ;
74
74
75
+ const dataAugemented = useMemo ( ( ) => [ ...( data || [ ] ) , { } ] , [ data ] ) ;
76
+
77
+ const transition = useTransition ( dataAugemented , {
78
+ delay : 200 ,
79
+ trail : 200 / dataAugemented . length ,
80
+ from : { opacity : 0 , scale : 0.8 } ,
81
+ enter : { opacity : 1 , scale : 1 } ,
82
+ leave : { opacity : 0 , scale : 0 } ,
83
+ } ) ;
84
+
75
85
useEffect ( ( ) => {
76
86
window . scrollTo ( 0 , 0 ) ;
77
87
} , [ ] ) ;
@@ -88,21 +98,27 @@ function Volunteers() {
88
98
89
99
< div className = "Volunteers" >
90
100
< div className = "wrapper" >
91
- < div className = "description" >
101
+ < div
102
+ className = { classnames ( 'description' , 'fadeInUp' ) }
103
+ style = { { animationDelay : '0.1s' } }
104
+ >
92
105
PLACEHOLDER: We would like to thank the hundreds of volunteers who,
93
106
for the last 18 months, collected and published the most complete
94
107
data about COVID-19 in India.
95
108
</ div >
96
109
</ div >
97
110
< div className = "members" >
98
- { data . map ( ( member , index ) => (
99
- < Member key = { index } { ...member } />
100
- ) ) }
101
- < div className = "last" >
102
- < Member className = { 'first' } />
103
- < Member className = { 'second' } />
104
- < Member className = { 'third' } bio = "And many more..." />
105
- </ div >
111
+ { transition ( ( style , item ) =>
112
+ Object . keys ( item || { } ) . length > 0 ? (
113
+ < Member { ...item } { ...{ style} } />
114
+ ) : (
115
+ < animated . div className = "last" { ...{ style} } >
116
+ < Member className = { 'first' } />
117
+ < Member className = { 'second' } />
118
+ < Member className = { 'third' } bio = "And many more..." />
119
+ </ animated . div >
120
+ )
121
+ ) }
106
122
</ div >
107
123
</ div >
108
124
< Footer />
0 commit comments