Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 4,521 Bytes
21edd9f ebdfd67 2a8ebbd 21edd9f ebdfd67 81e0b0c 21edd9f 83106dd 2a8ebbd 21edd9f 81e0b0c 9afe01c 21edd9f ebdfd67 2a8ebbd ebdfd67 2a8ebbd ebdfd67 2a8ebbd ebdfd67 21edd9f ebdfd67 21edd9f ebdfd67 21edd9f 83106dd ebdfd67 81e0b0c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
import React, { useState } from "react";
import {
Box,
Typography,
IconButton,
Tooltip,
Menu,
MenuItem,
useTheme,
useMediaQuery,
} from "@mui/material";
import OpenInNewIcon from "@mui/icons-material/OpenInNew";
import ShareIcon from "@mui/icons-material/Share";
import MenuIcon from "@mui/icons-material/Menu";
const Navigation = () => {
const [anchorEl, setAnchorEl] = useState(null);
const theme = useTheme();
const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
const handleShare = async () => {
try {
await navigator.share({
title: "YourBench Demo",
text: "Check out this benchmark evaluation on YourBench!",
url: window.location.href,
});
} catch (err) {
console.log("Error sharing:", err);
}
};
const handleMenuOpen = (event) => {
setAnchorEl(event.currentTarget);
};
const handleMenuClose = () => {
setAnchorEl(null);
};
const externalLinks = [
{
name: "GitHub",
url: "https://github.com/huggingface/yourbench",
},
{
name: "Advanced demo",
url: "https://huggingface.co/spaces/yourbench/advanced",
},
];
return (
<Box
sx={{
position: "fixed",
top: 24,
left: 24,
right: 24,
margin: "auto",
display: "flex",
justifyContent: "space-between",
alignItems: "center",
zIndex: 1000,
}}
>
{isMobile ? (
<>
<IconButton
onClick={handleMenuOpen}
size="small"
sx={{
color: "inherit",
opacity: 0.7,
"&:hover": {
opacity: 1,
},
}}
>
<MenuIcon />
</IconButton>
<Menu
anchorEl={anchorEl}
open={Boolean(anchorEl)}
onClose={handleMenuClose}
PaperProps={{
sx: {
mt: 1,
minWidth: 200,
borderRadius: 2,
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
},
}}
>
{externalLinks.map((link) => (
<MenuItem
key={link.name}
onClick={handleMenuClose}
sx={{
display: "flex",
alignItems: "center",
gap: 1,
py: 1.5,
px: 2,
}}
>
<a
href={link.url}
target="_blank"
rel="noopener noreferrer"
style={{
textDecoration: "none",
color: "inherit",
display: "flex",
alignItems: "center",
gap: 0.5,
width: "100%",
}}
>
{link.name}
<OpenInNewIcon sx={{ fontSize: "0.75rem", opacity: 0.6 }} />
</a>
</MenuItem>
))}
</Menu>
</>
) : (
<Typography
variant="body2"
sx={{
display: "flex",
gap: 2,
alignItems: "center",
}}
>
{externalLinks.map((link, index) => (
<React.Fragment key={link.name}>
<a
href={link.url}
target="_blank"
rel="noopener noreferrer"
style={{ textDecoration: "none", color: "inherit" }}
>
{link.name}
<OpenInNewIcon
sx={{ fontSize: "0.75rem", ml: 0.5, opacity: 0.6 }}
/>
</a>
{index < externalLinks.length - 1 && (
<Typography component="span" sx={{ opacity: 0.5 }}>
•
</Typography>
)}
</React.Fragment>
))}
</Typography>
)}
<Box sx={{ display: "flex", alignItems: "center" }}>
<Tooltip title="Share">
<IconButton
onClick={handleShare}
size="small"
sx={{
color: "inherit",
opacity: 0.7,
"&:hover": {
opacity: 1,
},
}}
>
<ShareIcon fontSize="small" />
</IconButton>
</Tooltip>
</Box>
</Box>
);
};
export default Navigation;
|