2024-05-06 14:58:26 -07:00
|
|
|
import { Link as MuiLink, useTheme } from "@mui/material";
|
|
|
|
|
import PropTypes from "prop-types";
|
|
|
|
|
|
2024-05-10 12:25:05 -07:00
|
|
|
/**
|
|
|
|
|
* @component
|
|
|
|
|
* @param {Object} props
|
|
|
|
|
* @param {'primary' | 'secondary' | 'tertiary' | 'error'} props.level - The level of the link
|
|
|
|
|
* @param {string} props.label - The label of the link
|
|
|
|
|
* @param {string} props.url - The URL of the link
|
|
|
|
|
* @returns {JSX.Element}
|
|
|
|
|
*/
|
|
|
|
|
|
2024-05-06 14:58:26 -07:00
|
|
|
const Link = ({ level, label, url }) => {
|
|
|
|
|
const theme = useTheme();
|
|
|
|
|
|
|
|
|
|
const levelConfig = {
|
|
|
|
|
primary: {},
|
2024-07-20 20:48:59 -04:00
|
|
|
secondary: {
|
2024-08-27 17:01:28 -04:00
|
|
|
color: theme.palette.text.secondary,
|
2024-07-20 20:48:59 -04:00
|
|
|
sx: {
|
|
|
|
|
":hover": {
|
2024-08-27 17:01:28 -04:00
|
|
|
color: theme.palette.text.secondary,
|
2024-07-20 20:48:59 -04:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2024-05-06 14:58:26 -07:00
|
|
|
tertiary: {
|
2024-08-27 17:01:28 -04:00
|
|
|
color: theme.palette.text.tertiary,
|
2024-05-06 14:58:26 -07:00
|
|
|
sx: {
|
|
|
|
|
textDecoration: "underline",
|
|
|
|
|
textDecorationStyle: "dashed",
|
2024-08-27 17:01:28 -04:00
|
|
|
textDecorationColor: theme.palette.common.main,
|
2024-07-20 20:48:59 -04:00
|
|
|
textUnderlineOffset: "1px",
|
2024-05-06 14:58:26 -07:00
|
|
|
":hover": {
|
2024-08-27 17:01:28 -04:00
|
|
|
color: theme.palette.text.tertiary,
|
|
|
|
|
textDecorationColor: theme.palette.common.main,
|
|
|
|
|
backgroundColor: theme.palette.background.fill,
|
2024-05-06 14:58:26 -07:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
error: {},
|
|
|
|
|
};
|
|
|
|
|
const { sx, color } = levelConfig[level];
|
|
|
|
|
return (
|
2024-07-20 20:48:59 -04:00
|
|
|
<MuiLink
|
|
|
|
|
href={url}
|
|
|
|
|
sx={{ width: "fit-content", ...sx }}
|
|
|
|
|
color={color}
|
|
|
|
|
target="_blank"
|
|
|
|
|
rel="noreferrer"
|
|
|
|
|
>
|
2024-05-06 14:58:26 -07:00
|
|
|
{label}
|
|
|
|
|
</MuiLink>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Link.propTypes = {
|
|
|
|
|
url: PropTypes.string.isRequired,
|
|
|
|
|
level: PropTypes.oneOf(["primary", "secondary", "tertiary", "error"]),
|
|
|
|
|
label: PropTypes.string.isRequired,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default Link;
|