Skip to content

Commit 4b88721

Browse files
committed
Add unique URL for each solution
1 parent 1b112d6 commit 4b88721

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/App.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
}
4242

4343
.problem-card {
44+
display: block;
4445
background-color: #282a36;
4546
border-radius: 5px;
4647
padding: 20px 20px;
@@ -52,6 +53,8 @@
5253
}
5354

5455
.problem-card:hover {
56+
color: white;
57+
text-decoration: none;
5558
background-color: #1a1c27;
5659
}
5760

src/App.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,14 @@ const Main = ({ updateProblem }) => {
8383
</div>
8484
<div className="problems">
8585
{_.map(problems, (problem) => (
86-
<div
87-
className="problem-card"
86+
<a
8887
onClick={() => updateProblem(problem.number)}
88+
href={"#" + problem.number}
8989
key={problem.number}
90+
className="problem-card"
9091
>
9192
{problem["number"] + ". " + problem["name"]}
92-
</div>
93+
</a>
9394
))}
9495
</div>
9596
{!problems.length && difficulty !== "All" && (
@@ -178,6 +179,11 @@ const Problem = ({ problem, updateProblem }) => {
178179
const App = () => {
179180
const [problem, updateProblem] = useState(null);
180181

182+
useEffect(() => {
183+
const problemId = window.location.hash.substring(1);
184+
if (data[problemId]) updateProblem(problemId);
185+
}, [window.location]);
186+
181187
return (
182188
<div className="app">
183189
<Main {...{ updateProblem }} />

0 commit comments

Comments
 (0)