@@ -11,10 +11,10 @@ import {
1111 CircularProgress ,
1212 Alert ,
1313} from "@mui/material" ;
14- import { FaGithub } from "react-icons/fa" ; // GitHub Icon
15- import axios from "axios" ;
14+ import { FaGithub } from "react-icons/fa" ;
15+ import axios from "axios"
1616import { Link } from "react-router-dom" ;
17- import { useTheme } from "../../hooks/useTheme" ;
17+
1818
1919interface Contributor {
2020 id : number ;
@@ -24,137 +24,102 @@ interface Contributor {
2424 html_url : string ;
2525}
2626
27+
2728const ContributorsPage = ( ) => {
2829 const [ contributors , setContributors ] = useState < Contributor [ ] > ( [ ] ) ;
2930 const [ loading , setLoading ] = useState < boolean > ( true ) ;
3031 const [ error , setError ] = useState < string | null > ( null ) ;
31- const { theme } = useTheme ( ) ;
32-
33- // Theme-based colors
34- const bgColor = theme === "dark" ? "#1f1f1f" : "#FFFFFF" ;
35- const textColor = theme === "dark" ? "#FFFFFF" : "#333333" ;
36- const cardBg = theme === "dark" ? "#2a2a2a" : "#FFFFFF" ;
37- const borderColor = theme === "dark" ? "#444444" : "#E0E0E0" ;
38- const hoverBorder = theme === "dark" ? "#666666" : "#C0C0C0" ;
39-
32+ // Fetch contributors data from GitHub API
4033 useEffect ( ( ) => {
4134 const fetchContributors = async ( ) => {
4235 try {
4336 const response = await axios . get (
4437 "https://api.github.com/repos/mehul-m-prajapati/github_tracker/contributors" ,
45- { withCredentials : false }
38+ {
39+ withCredentials : false ,
40+ }
4641 ) ;
4742 setContributors ( response . data ) ;
4843 } catch ( err ) {
49- setError ( "Failed to fetch contributors. Please try again later." ) ;
44+ setError ( "Failed to fetch contributors. Please try again later." + err ) ;
5045 } finally {
5146 setLoading ( false ) ;
5247 }
5348 } ;
54-
5549 fetchContributors ( ) ;
5650 } , [ ] ) ;
57-
58- // To trigger re-render on theme change (optional)
59- useEffect ( ( ) => {
60- setContributors ( ( prev ) => [ ...prev ] ) ;
61- } , [ theme ] ) ;
62-
6351 if ( loading ) {
6452 return (
6553 < Box sx = { { display : "flex" , justifyContent : "center" , mt : 4 } } >
6654 < CircularProgress />
6755 </ Box >
6856 ) ;
6957 }
70-
7158 if ( error ) {
7259 return (
7360 < Box sx = { { mt : 4 } } >
7461 < Alert severity = "error" > { error } </ Alert >
7562 </ Box >
7663 ) ;
7764 }
78-
7965 return (
80- < Container
81- sx = { {
82- mt : 4 ,
83- backgroundColor : bgColor ,
84- color : textColor ,
85- minHeight : "100vh" ,
86- p : { xs : 2 , sm : 4 } ,
87- } }
88- >
89- < Typography
90- variant = "h4"
91- align = "center"
92- gutterBottom
93- sx = { {
94- fontSize : { xs : "1.8rem" , sm : "2.2rem" } ,
95- fontWeight : "bold" ,
96- mb : 3 ,
97- } }
98- >
99- 🤝 GitHub Contributors
100- </ Typography >
66+ < div className = "bg-white dark:bg-gray-900 text-black dark:text-white min-h-screen p-4 mt-4" >
67+ < Container >
68+ < Typography sx = { { pb : 2 } } variant = "h4" align = "center" gutterBottom >
69+ 🤝 GitHub Contributors
70+ </ Typography >
71+ < Grid container spacing = { 4 } >
72+ { contributors . map ( ( contributor ) => (
73+ < Grid item xs = { 12 } sm = { 6 } md = { 4 } key = { contributor . id } >
10174
102- < Grid container spacing = { 3 } >
103- { contributors . map ( ( contributor ) => (
104- < Grid item xs = { 12 } sm = { 6 } md = { 4 } key = { contributor . id } >
10575 < Link
10676 to = { `/user/${ contributor . login } ` }
10777 style = { { textDecoration : "none" } }
10878 >
10979 < Card
11080 sx = { {
11181 textAlign : "center" ,
112- backgroundColor : cardBg ,
113- color : textColor ,
114- borderRadius : "12px" ,
115- border : `1px solid ${ borderColor } ` ,
82+ p : 2 ,
83+
84+ borderRadius : "10px" ,
85+ border : "1px solid #E0E0E0" , // Border styling
86+
11687 boxShadow : "0 4px 10px rgba(0,0,0,0.1)" ,
11788 transition : "transform 0.3s ease-in-out" ,
11889 "&:hover" : {
119- transform : "scale(1.05)" ,
90+ transform : "scale(1.05)" , // Zoom effect
12091 boxShadow : "0 8px 15px rgba(0,0,0,0.2)" ,
121- borderColor : hoverBorder ,
92+ borderColor : "#C0C0C0" , // Change border color on hover
93+ outlineColor : "#B3B3B3" , // Change outline color on hover
12294 } ,
12395 } }
12496 >
12597 < Avatar
12698 src = { contributor . avatar_url }
12799 alt = { contributor . login }
128- sx = { { width : 100 , height : 100 , mx : "auto" , mt : 3 } }
100+ sx = { { width : 100 , height : 100 , mx : "auto" , mb : 2 } }
129101 />
130102 < CardContent >
131- < Typography
132- variant = "h6"
133- sx = { { fontWeight : "bold" , color : textColor } }
134- >
103+ < Typography variant = "h6" sx = { { fontWeight : "bold" } } >
135104 { contributor . login }
136105 </ Typography >
137- < Typography variant = "body2" sx = { { mt : 1 , color : textColor } } >
106+ < Typography variant = "body2" color = "textSecondary" >
138107 { contributor . contributions } Contributions
139108 </ Typography >
140- < Typography variant = "body2" sx = { { mt : 2 , color : textColor } } >
141- Thank you for your valuable contributions!
109+ < Typography variant = "body2" sx = { { mt : 2 } } >
110+ Thank you for your valuable contributions to our community !
142111 </ Typography >
143112 < Box sx = { { mt : 2 } } >
144113 < Button
145114 variant = "contained"
146115 startIcon = { < FaGithub /> }
147116 href = { contributor . html_url }
148117 target = "_blank"
149- onClick = { ( e ) => e . stopPropagation ( ) }
150118 sx = { {
151- backgroundColor : "#24292f" ,
152- color : "#fff" ,
153- fontSize : { xs : "0.75rem" , sm : "0.85rem" } ,
154- px : 2 ,
155- py : 1 ,
119+ backgroundColor : "#333333" ,
120+ color : "#FFFFFF" ,
156121 "&:hover" : {
157- backgroundColor : "#444" ,
122+ backgroundColor : "#555555" , // Custom hover color
158123 } ,
159124 } }
160125 >
@@ -163,11 +128,12 @@ const ContributorsPage = () => {
163128 </ Box >
164129 </ CardContent >
165130 </ Card >
166- </ Link >
167- </ Grid >
168- ) ) }
169- </ Grid >
170- </ Container >
131+ </ Link >
132+ </ Grid >
133+ ) ) }
134+ </ Grid >
135+ </ Container >
136+ </ div >
171137 ) ;
172138} ;
173139
0 commit comments