Skip to content

Commit 71f44bd

Browse files
Mikadowsangristan
authored andcommitted
fix(ui): back buttons in header component
1 parent e1f9fb6 commit 71f44bd

File tree

2 files changed

+50
-21
lines changed

2 files changed

+50
-21
lines changed

src/components/Benchmarks/BenchmarkDetail.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ const BenchmarkDetail = ({
178178

179179
<Header
180180
title={benchmarkData?.title || 'Failed to load benchmark'}
181-
button="Back"
181+
button="back"
182182
navTo="/benchmarks"
183183
/>
184184
<div className="flex p-4 overflow-hidden ">
@@ -287,10 +287,10 @@ const BenchmarkDetail = ({
287287
<ReactMarkdown>{benchmarkData?.subject || ''}</ReactMarkdown>
288288
<div className="flex">
289289
<button
290-
className="bg-blue-500 hover:bg-blue-700 text-white font-bold mt-2 py-2 px-4 rounded"
290+
className="bg-blue-500 hover:bg-blue-700 text-white font-bold mt-2 py-2 px-4 rounded-full"
291291
onClick={openLeaderboardPanel}
292292
>
293-
See Leaderboard
293+
Leaderboard 📈
294294
</button>
295295
</div>
296296
</div>
@@ -317,7 +317,7 @@ const BenchmarkDetail = ({
317317
});
318318
}}
319319
>
320-
Run code
320+
Run code 🚀
321321
</button>
322322
</div>
323323
</div>

src/components/Page/Header.tsx

Lines changed: 46 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,60 @@
1-
import {Link} from "react-router-dom";
2-
import React from "react";
1+
import { Link } from 'react-router-dom';
2+
import React from 'react';
33

44
interface HeaderProps {
55
title: string;
66
button?: string;
77
navTo?: string;
88
}
99

10-
const Header: React.FC<HeaderProps> = ({ title, button, navTo}) => {
11-
const isButtonNeeded = button !== undefined && navTo !== undefined;
10+
const Header: React.FC<HeaderProps> = ({ title, button, navTo }) => {
11+
const isButtonNeeded = button !== undefined && navTo !== undefined;
1212

13-
return (
13+
return (
1414
<header className="bg-white shadow">
15-
<div className="max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8 flex justify-between">
16-
<h1 className="text-3xl font-bold text-gray-900">{title}</h1>
17-
{isButtonNeeded?
18-
<Link
19-
className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-full"
20-
to={navTo !== undefined ? navTo : '/500'}
15+
{button === 'back' ? (
16+
<div className="max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8 flex ">
17+
{isButtonNeeded ? (
18+
<Link
19+
className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-full"
20+
to={navTo !== undefined ? navTo : '/500'}
21+
>
22+
<svg
23+
xmlns="http://www.w3.org/2000/svg"
24+
className="h-6 w-6"
25+
fill="none"
26+
viewBox="0 0 24 24"
27+
stroke="currentColor"
2128
>
22-
{button}
23-
</Link>
24-
: <></>}
25-
</div>
26-
29+
<path
30+
strokeLinecap="round"
31+
strokeLinejoin="round"
32+
strokeWidth="2"
33+
d="M10 19l-7-7m0 0l7-7m-7 7h18"
34+
/>
35+
</svg>
36+
</Link>
37+
) : (
38+
<></>
39+
)}
40+
<h1 className="text-3xl font-bold text-gray-900 ml-2">{title}</h1>
41+
</div>
42+
) : (
43+
<div className="max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8 flex justify-between">
44+
<h1 className="text-3xl font-bold text-gray-900">{title}</h1>
45+
{isButtonNeeded ? (
46+
<Link
47+
className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-full"
48+
to={navTo !== undefined ? navTo : '/500'}
49+
>
50+
{button}
51+
</Link>
52+
) : (
53+
<></>
54+
)}
55+
</div>
56+
)}
2757
</header>
28-
2958
);
3059
};
3160

0 commit comments

Comments
 (0)