Skip to content

Commit

Permalink
feat: link external icon
Browse files Browse the repository at this point in the history
  • Loading branch information
MounirAbdousNventive committed Aug 7, 2024
1 parent 5225346 commit a30eff7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
18 changes: 16 additions & 2 deletions frontend/src/app/components/link/Link.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ExternalLinkOutlined from "@icons/ExternalLinkOutlined";
import { LinkProps, Link as MuiLink, styled } from "@mui/material";
import style from "@styles/style.module.scss";

Expand All @@ -8,14 +9,27 @@ const StyledMuiLink = styled(MuiLink)({
cursor: "pointer",
});

interface ILink extends LinkProps {
external?: boolean;
}

export default function Link({
children,
underline = "hover",
external,
rel,
target,
...props
}: LinkProps) {
}: ILink) {
return (
<StyledMuiLink underline={underline} {...props}>
<StyledMuiLink
{...props}
underline={underline}
rel={rel || external ? "noreferrer" : undefined}
target={target || external ? "_blank" : undefined}
>
{children}
{external && <ExternalLinkOutlined className="ml-xxs" />}
</StyledMuiLink>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ export default function CookieBanner({
<Link
href={t("cookie_consent_link")}
underline="always"
target="_blank"
rel="noreferrer"
external
>
<Typography.Body2>
{t("cookie_consent__learn_more")}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ export default function CookieModal({
className="mr-a"
href={t("cookie_consent_link")}
underline="always"
target="_blank"
rel="noreferrer"
external
>
<Typography.Body2>
{t("cookie_consent__learn_more")}
Expand Down
7 changes: 1 addition & 6 deletions frontend/src/app/pages/login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,8 @@ export default function Login() {
<Typography.Body1 className="color-basic-body mb-xxs">
Password: oliviawpass
</Typography.Body1>
<Link
href="https://dummyjson.com/users"
target="_blank"
rel="noreferrer"
>
<Link href="https://dummyjson.com/users" external>
<Typography.Body2>{t("login__more_user")}</Typography.Body2>
<ExternalLinkOutlined className="ml-xxs" />
</Link>
</div>
<LoginForm setIsLoading={setIsLoading} />
Expand Down

0 comments on commit a30eff7

Please sign in to comment.