Skip to content

Commit 2001854

Browse files
committed
Make mobile responsive
1 parent e664c06 commit 2001854

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

src/App.tsx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
1-
import { useCallback, useRef } from 'react';
1+
import { useCallback, useMemo, useRef, useState } from 'react';
22
import { useNavigate } from 'react-router';
33

44
function App() {
55
const navigate = useNavigate()
6-
const usernameRef = useRef<HTMLInputElement>(null);
6+
const [username, setUsername] = useState<string>("");
7+
8+
const usernameInput = useCallback((event: React.ChangeEvent<HTMLInputElement>) => {
9+
setUsername(event.currentTarget.value)
10+
}, [])
711

812
const searchUser = useCallback(() => {
9-
navigate(`/dashboard/${usernameRef?.current?.value}`)
10-
}, [navigate, usernameRef])
13+
navigate(`/dashboard/${username}`)
14+
}, [navigate, username])
15+
16+
const isSearchDisabled = useMemo(() => {
17+
return username.trim() === ""
18+
}, [username])
1119

1220
return (
13-
<div className="w-[40%] my-28 mx-auto">
21+
<div className="lg:w-[40%] my-28 mx-auto md:w-[60%] w-[80%]">
1422
<div className="text-center mb-6">
1523
<h1 className="text-4xl font-bold mb-4">Git Mastery Progress Dashboard</h1>
1624
<p className="text-gray-700 font-semibold">Enter your Github username to find your progress!</p>
@@ -19,10 +27,10 @@ function App() {
1927
<div className="flex items-center justify-center p-4 border-r border-r-gray-700">
2028
<span className="font-bold">@</span>
2129
</div>
22-
<input ref={usernameRef} className="font-semibold w-full px-4 focus:outline-none" placeholder="Your Github username" type="text" />
30+
<input onChange={usernameInput} className="font-semibold w-full px-4 focus:outline-none" placeholder="Your Github username" type="text" />
2331
</div>
2432
<div className="text-center mt-4">
25-
<button type="button" onClick={searchUser} className="hover:cursor-pointer hover:bg-gray-600 hover:text-white transition border-1 rounded-sm px-4 py-2 font-semibold">View Progress →</button>
33+
<button type="button" onClick={searchUser} disabled={isSearchDisabled} className="enabled:hover:cursor-pointer enabled:hover:bg-gray-600 enabled:hover:text-white transition border-1 rounded-sm px-4 py-2 font-semibold disabled:border-gray-200 disabled:text-gray-400 disabled:cursor-not-allowed">View Progress →</button>
2634
</div>
2735
</div>
2836
)

src/Dashboard.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,8 @@ function Dashboard() {
6666
return sortedGroups
6767
}, [problemSets, isProblemSetsLoading, parsedUserProgress])
6868

69-
console.log(problemSetGroups)
70-
7169
return (
72-
<div className="w-[40%] my-28 mx-auto">
70+
<div className="lg:w-[40%] my-28 mx-auto md:w-[60%] w-[80%]">
7371
<h3 className="text-2xl font-bold mb-4">Git Mastery Progress Dashboard</h3>
7472
<div className="mb-6">
7573
<Link to="/" className="text-gray-500 italic mb-2">← Back to search</Link>

0 commit comments

Comments
 (0)