Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public
.DS_Store

# Yarn
yarn.lock
yarn-error.log
.pnp/
.pnp.js
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@
"react-server-dom-webpack@0.0.0-experimental-c8b778b7f-20220825": {
"react": "^18.2.0"
}
},
"resolutions": {
"@types/react": "^18.2.0",
"@types/react-dom": "^18.2.0"
},
"scripts": {
"lint": "eslint 'src/**/*' 'lib/**/*' 'gatsby/**/*'",
Expand Down
62 changes: 33 additions & 29 deletions src/components/ExternalLink.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import * as React from "react"

import { styled } from '@mui/material/styles';
import { styled } from "@mui/material/styles"

import { Tooltip } from "@mui/material"
import { Tooltip } from "@mui/material"

import { Launch } from "@mui/icons-material"
import clsx from "classnames"
import {PropsWithChildren} from 'react';
import { PropsWithChildren } from "react"

const PREFIX = 'ExternalLink';
const PREFIX = "ExternalLink"

const classes = {
link: `${PREFIX}-link`,
icon: `${PREFIX}-icon`,
hover: `${PREFIX}-hover`
};
hover: `${PREFIX}-hover`,
}

const Root = styled('div')(() => ({
const Root = styled("span")(() => ({
[`& .${classes.link}`]: {
display: "inline-flex",
alignItems: "center",
Expand All @@ -32,36 +32,40 @@ const Root = styled('div')(() => ({
opacity: 1.0,
},
opacity: 0.3,
}
}));
},
}))

type Props = {
href: string
title?: string
hover?: true | undefined
}

const ExternalLink: React.FC<PropsWithChildren<Props>> = ({ href, title, children, hover }) => {

const ExternalLink: React.FC<PropsWithChildren<Props>> = ({
href,
title,
children,
hover,
}) => {
return (
<Root>
<Tooltip title={title || ""}>
<a
className={clsx({ [classes.hover]: hover }, classes.link)}
href={href}
target="_blank"
rel="noreferrer"
>
{children}
<Launch
className={clsx({ [classes.icon]: children !== undefined })}
color="action"
fontSize={children === undefined ? undefined : "inherit"}
/>
</a>
</Tooltip>
</Root>
);
<Root>
<Tooltip title={title || ""}>
<a
className={clsx({ [classes.hover]: hover }, classes.link)}
href={href}
target="_blank"
rel="noreferrer"
>
{children}
<Launch
className={clsx({ [classes.icon]: children !== undefined })}
color="action"
fontSize={children === undefined ? undefined : "inherit"}
/>
</a>
</Tooltip>
</Root>
)
}

export default ExternalLink
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */,
"baseUrl": "./src",
"noEmit": true,
"paths": {
"@/*": ["./*"]
}
Expand Down
Loading