Skip to content

Commit 66f70dc

Browse files
odysseus0claude
andcommitted
feat: add click-to-navigate functionality for MEV refunds
- Make MEV refunds metric clickable, redirecting to protect.flashbots.net - Add hover and active states for better UX - Include keyboard accessibility (Enter/Space key support) - Implement as per requirement to navigate to Protect site from docs 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 8ce8f6d commit 66f70dc

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

src/components/MevMetrics.module.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@
3232
opacity: 0.3;
3333
}
3434

35+
.clickable {
36+
cursor: pointer;
37+
transition: opacity 0.2s ease;
38+
}
39+
40+
.clickable:hover {
41+
opacity: 0.8;
42+
}
43+
44+
.clickable:active {
45+
opacity: 0.6;
46+
}
47+
3548
@media (max-width: 996px) {
3649
.container {
3750
display: none !important;

src/components/MevMetrics.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { useEffect, useState } from 'react';
2+
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
23
import styles from './MevMetrics.module.css';
34

45
interface MetricsResponse {
@@ -9,13 +10,15 @@ interface MetricsResponse {
910
}
1011

1112
export default function MevMetrics(): JSX.Element {
13+
const { siteConfig } = useDocusaurusContext();
1214
const [data, setData] = useState<MetricsResponse | null>(null);
1315
const [loading, setLoading] = useState(true);
1416

1517
useEffect(() => {
1618
const fetchMetrics = async () => {
1719
try {
18-
const response = await fetch('https://refund-metrics-dune-api.vercel.app/api/metrics');
20+
const apiUrl = siteConfig.customFields?.refundMetricsApiUrl as string;
21+
const response = await fetch(`${apiUrl}/api/metrics`);
1922
if (!response.ok) {
2023
throw new Error(`HTTP error! status: ${response.status}`);
2124
}
@@ -42,11 +45,25 @@ export default function MevMetrics(): JSX.Element {
4245
return `${value.toFixed(2)} ETH`;
4346
};
4447

48+
const handleMevClick = () => {
49+
window.open('https://protect.flashbots.net/', '_blank', 'noopener,noreferrer');
50+
};
51+
4552
return (
4653
<div className={styles.container}>
4754
<span className={styles.label}>Refund</span>
4855
<span className={styles.separator}>|</span>
49-
<div className={styles.metric}>
56+
<div
57+
className={`${styles.metric} ${styles.clickable}`}
58+
onClick={handleMevClick}
59+
role="button"
60+
tabIndex={0}
61+
onKeyDown={(e) => {
62+
if (e.key === 'Enter' || e.key === ' ') {
63+
handleMevClick();
64+
}
65+
}}
66+
>
5067
<span className={styles.label}>MEV:</span>
5168
<span className={`${styles.value} ${loading ? styles.loading : ''}`}>
5269
{loading ? '...' : data && formatValue(data.totalMevRefund)}

0 commit comments

Comments
 (0)