Merge branch 'next-console-errors' into 'next'
Next console errors See merge request soapbox-pub/soapbox-fe!1135
This commit is contained in:
commit
6c1ed1b79c
4 changed files with 37 additions and 0 deletions
Binary file not shown.
37
app/soapbox/components/permalink.tsx
Normal file
37
app/soapbox/components/permalink.tsx
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
import * as React from 'react';
|
||||||
|
import { useHistory } from 'react-router-dom';
|
||||||
|
|
||||||
|
interface IPermaLink extends Pick<React.HTMLAttributes<HTMLAnchorElement>, 'dangerouslySetInnerHTML'> {
|
||||||
|
className?: string,
|
||||||
|
href: string,
|
||||||
|
title?: string,
|
||||||
|
to: string,
|
||||||
|
}
|
||||||
|
|
||||||
|
const Permalink: React.FC<IPermaLink> = (props) => {
|
||||||
|
const history = useHistory();
|
||||||
|
|
||||||
|
const { className, href, title, to, children, ...filteredProps } = props;
|
||||||
|
|
||||||
|
const handleClick = (event: React.MouseEvent<HTMLAnchorElement>) => {
|
||||||
|
if (event.button === 0 && !(event.ctrlKey || event.metaKey)) {
|
||||||
|
event.preventDefault();
|
||||||
|
history.push(to);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<a
|
||||||
|
target='_blank'
|
||||||
|
href={href}
|
||||||
|
onClick={handleClick}
|
||||||
|
title={title}
|
||||||
|
className={`permalink${className ? ' ' + className : ''}`}
|
||||||
|
{...filteredProps}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</a>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Permalink;
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue