@@ -7,7 +7,15 @@ type Props = {
7
7
} ;
8
8
9
9
export const LandingCommunity : FC < Props > = ( { className } ) => {
10
- const { githubStarCountText, githubContributorsCount, githubForksCount } = useCommunityStatsContext ( ) ;
10
+ const {
11
+ githubStarCountText,
12
+ githubContributorsCountText,
13
+ githubForksCountText,
14
+ githubReposCountText,
15
+ loading,
16
+ error
17
+ } = useCommunityStatsContext ( ) ;
18
+
11
19
const [ state , setState ] = useState ( {
12
20
stat0 : 0 ,
13
21
stat1 : 0 ,
@@ -18,28 +26,29 @@ export const LandingCommunity: FC<Props> = ({ className }) => {
18
26
const generateList = useMemo ( ( ) => [
19
27
{
20
28
stat : githubStarCountText ,
21
- description : "Stars on our GitHub repository, showcase the support and contribution, we recieved from the community." ,
29
+ description : "Stars across all our GitHub repositories, showcasing the support and appreciation from the community." ,
22
30
href : "https://github.com/recodehive" ,
23
- // https://github.com/CodeHarborHub/codeharborhub.github.io/stargazers
31
+ label : "GitHub Stars"
24
32
} ,
25
33
{
26
- stat : 20 ,
27
- description : "Live projects on recodehive, demonstrating the power of open-source collaboration." ,
34
+ stat : githubReposCountText ,
35
+ description : "Live public projects on RecodHive, demonstrating the power of open-source collaboration." ,
36
+ href : "https://github.com/orgs/recodehive/repositories?q=visibility%3Apublic+archived%3Afalse" ,
37
+ label : "Public Repositories"
28
38
} ,
29
39
{
30
- stat : githubContributorsCount ,
31
- description : "List of Contributors who have made our repository better." ,
32
- href : "https://github.com/recodehive" ,
33
- // https://github.com/CodeHarborHub/codeharborhub.github.io/graphs/contributors
40
+ stat : githubContributorsCountText ,
41
+ description : "Amazing contributors who have made our repositories better and helped build our community ." ,
42
+ href : "https://github.com/orgs/ recodehive/people " ,
43
+ label : "Contributors"
34
44
} ,
35
45
{
36
- stat : githubForksCount ,
37
- description : "Forks of our repository, showing how our community extends our work." ,
38
- href : "https://github.com/recodehive" ,
39
-
40
- //https://github.com/CodeHarborHub/codeharborhub.github.io/network/members
46
+ stat : githubForksCountText ,
47
+ description : "Forks of our repositories, showing how our community extends and builds upon our work." ,
48
+ href : "https://github.com/orgs/recodehive/discussions" ,
49
+ label : "Community Forks"
41
50
} ,
42
- ] , [ githubStarCountText , githubContributorsCount , githubForksCount ] ) ;
51
+ ] , [ githubStarCountText , githubReposCountText , githubContributorsCountText , githubForksCountText ] ) ;
43
52
44
53
const handleDynamicChange = ( target : number , index : number ) => {
45
54
let count = 0 ;
@@ -54,11 +63,22 @@ export const LandingCommunity: FC<Props> = ({ className }) => {
54
63
} , 20 ) ;
55
64
} ;
56
65
66
+ const handleCardClick = ( href : string ) => {
67
+ if ( href ) {
68
+ window . open ( href , '_blank' , 'noopener,noreferrer' ) ;
69
+ }
70
+ } ;
71
+
57
72
useEffect ( ( ) => {
58
- generateList . forEach ( ( item , index ) => {
59
- handleDynamicChange ( Number ( item . stat ) , index ) ;
60
- } ) ;
61
- } , [ generateList ] ) ;
73
+ if ( ! loading ) {
74
+ generateList . forEach ( ( item , index ) => {
75
+ const numericStat = typeof item . stat === 'string' ?
76
+ parseInt ( item . stat . replace ( / [ ^ \d ] / g, '' ) ) || 0 :
77
+ Number ( item . stat ) ;
78
+ handleDynamicChange ( numericStat , index ) ;
79
+ } ) ;
80
+ }
81
+ } , [ generateList , loading ] ) ;
62
82
63
83
return (
64
84
< div className = { `landing-community ${ className || "" } ` } >
@@ -67,61 +87,83 @@ export const LandingCommunity: FC<Props> = ({ className }) => {
67
87
Discover the strength of our{ " " }
68
88
< span className = "landing-community__highlight" > amazing community</ span > .
69
89
</ h2 >
90
+ { error && (
91
+ < div className = "landing-community__error" >
92
+ < small > ⚠️ Stats may be cached or incomplete</ small >
93
+ </ div >
94
+ ) }
70
95
</ div >
71
96
72
97
< div className = "landing-community__content" >
73
98
< div className = "landing-community__stats" >
74
99
{ generateList . map ( ( item , index ) => (
75
- < span key = { index } className = "landing-community__stat-item" >
100
+ < div
101
+ key = { index }
102
+ className = { `landing-community__stat-item ${ item . href ? 'clickable' : '' } ${ loading ? 'loading' : '' } ` }
103
+ onClick = { ( ) => handleCardClick ( item . href ) }
104
+ role = { item . href ? "button" : "presentation" }
105
+ tabIndex = { item . href ? 0 : - 1 }
106
+ onKeyDown = { ( e ) => {
107
+ if ( item . href && ( e . key === 'Enter' || e . key === ' ' ) ) {
108
+ e . preventDefault ( ) ;
109
+ handleCardClick ( item . href ) ;
110
+ }
111
+ } }
112
+ title = { item . href ? `Click to visit ${ item . label } ` : item . label }
113
+ >
76
114
< div className = "landing-community__stat-value" >
77
- { item . href ? (
78
- < a
79
- href = { item . href }
80
- target = "_blank"
81
- rel = "noopener noreferrer"
82
- >
83
- { `${ state [ `stat${ index } ` ] } ${ index !== 1 ? "" : "" } ` }
84
- </ a >
115
+ { loading ? (
116
+ < div className = "landing-community__loading" >
117
+ < span className = "loading-spinner" > ⏳</ span >
118
+ </ div >
85
119
) : (
86
- `${ state [ `stat${ index } ` ] } `
120
+ < span >
121
+ { item . stat }
122
+ { item . href && < span className = "external-link-icon" > ↗</ span > }
123
+ </ span >
87
124
) }
88
125
</ div >
89
126
< div className = "landing-community__stat-description" >
90
127
{ item . description }
91
128
</ div >
92
- </ span >
129
+ </ div >
93
130
) ) }
94
131
</ div >
95
132
96
- < div className = "landing-community__info" >
133
+ < div
134
+ className = "landing-community__info clickable"
135
+ onClick = { ( ) => handleCardClick ( "https://github.com/recodehive" ) }
136
+ role = "button"
137
+ tabIndex = { 0 }
138
+ onKeyDown = { ( e ) => {
139
+ if ( e . key === 'Enter' || e . key === ' ' ) {
140
+ e . preventDefault ( ) ;
141
+ handleCardClick ( "https://github.com/recodehive" ) ;
142
+ }
143
+ } }
144
+ title = "Click to visit RecodHive GitHub Organization"
145
+ >
97
146
< img
98
147
className = "landing-community__image"
99
148
src = "/community.png"
100
149
alt = "team collaboration"
101
150
loading = "lazy"
102
151
/>
103
152
< div className = "landing-community__info-text" >
104
- Our developers are the core of Hive community. We take pride in
153
+ Our developers are the core of RecodHive community. We take pride in
105
154
our{ " " }
106
- < a
107
- href = "https://github.com/recodehive"
108
- //https://github.com/CodeHarborHub/codeharborhub.github.io/graphs/contributors
109
- target = "_blank"
110
- rel = "noopener noreferrer"
111
- className = "landing-community__link"
112
- >
113
- GitHub community
114
- </ a > { " " }
115
- with over{ " " }
116
- < a
117
- href = "https://github.com/recodehive"
118
- target = "_blank"
119
- rel = "noopener noreferrer"
120
- className = "landing-community__link"
121
- >
122
- 500+ contributors
123
- </ a > { " " }
124
- powering recodehive.
155
+ < span className = "landing-community__link" >
156
+ GitHub organization
157
+ </ span > { " " }
158
+ with amazing{ " " }
159
+ < span className = "landing-community__link" >
160
+ contributors and maintainers
161
+ </ span > { " " }
162
+ powering RecodHive's growth.
163
+ < div className = "external-link-indicator" >
164
+ < span className = "external-link-icon" > ↗</ span >
165
+ < small > Click to explore our GitHub</ small >
166
+ </ div >
125
167
</ div >
126
168
</ div >
127
169
</ div >
0 commit comments