Added a link component, currently only have tertiary style

This commit is contained in:
Alex Holliday committed 2024-05-06 14:58:26 -07:00
1 parent e76db0a499
commit 731cb84244
4 files changed
+57

No files matched your search

Whitespace-only changes.
+47
View File
@@ -0,0 +1,47 @@
import { Link as MuiLink, useTheme } from "@mui/material";
import PropTypes from "prop-types";
const Link = ({ level, label, url }) => {
const theme = useTheme();
const levelConfig = {
primary: {},
secondary: {},
tertiary: {
color: theme.palette.tertiary.main,
sx: {
textDecoration: "underline",
textDecorationStyle: "dashed",
textDecorationColor: theme.palette.primary.main,
":hover": {
color: theme.palette.tertiary.main,
textDecorationColor: theme.palette.primary.main,
backgroundColor: theme.palette.tertiary.linkHover,
},
},
},
error: {},
};
/**
* @typedef {Object} Props
* @property {'primary' | 'secondary' | 'tertiary' | 'error'} level - The level of the link
* @property {string} label - The label of the link
* @property {string} url - The URL of the link
*/
const { sx, color } = levelConfig[level];
return (
<MuiLink href={url} sx={sx} color={color}>
{label}
</MuiLink>
);
};
Link.propTypes = {
url: PropTypes.string.isRequired,
level: PropTypes.oneOf(["primary", "secondary", "tertiary", "error"]),
label: PropTypes.string.isRequired,
};
export default Link;
+8
View File
@@ -2,6 +2,7 @@ import React from "react";
import DropdownTeamMember from "../../Components/DropdownTeamMember";
import "./index.css";
import Button from "../../Components/Button";
import Link from "../../Components/Link";
const Home = () => {
return (
@@ -25,6 +26,13 @@ const Home = () => {
<Button level="tertiary" label="Tertiary" disabled />
<Button level="error" label="Error" disabled />
</div>
<div>
<Link
level="tertiary"
label="Tertiary Link"
url={"https://www.google.com"}
/>
</div>
</div>
</>
);
+2
View File
@@ -3,6 +3,7 @@ import { createTheme } from "@mui/material";
// Colors for MUI theme
const secondaryMain = "#475467";
const tertiaryMain = "#475467";
const tertiaryLinkHover = "#eff8ff";
const theme = createTheme({
palette: {
@@ -11,6 +12,7 @@ const theme = createTheme({
},
tertiary: {
main: tertiaryMain,
linkHover: tertiaryLinkHover,
},
},
});