mirror of
https://github.com/hazemKrimi/personal-website.git
synced 2026-05-01 18:00:26 +00:00
Update button behavior to work as link
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
import { FC } from 'react';
|
||||
import styled from 'styled-components';
|
||||
import Image from 'next/image';
|
||||
import Link from 'next/link';
|
||||
|
||||
interface Props {
|
||||
icon: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
href?: string;
|
||||
target?: HTMLAnchorElement['target'];
|
||||
onClick?: () => void;
|
||||
}
|
||||
|
||||
@@ -18,15 +22,23 @@ const Btn = styled.button`
|
||||
|
||||
const IconButton: FC<Props & { className?: string }> = ({
|
||||
icon,
|
||||
href,
|
||||
target,
|
||||
onClick,
|
||||
className,
|
||||
width = 24,
|
||||
height = 24
|
||||
}) => {
|
||||
return (
|
||||
return !href ? (
|
||||
<Btn onClick={onClick} className={className}>
|
||||
<Image src={icon} width={width} height={height} />
|
||||
</Btn>
|
||||
) : (
|
||||
<Link href={href} passHref>
|
||||
<Btn as='a' target={target} onClick={onClick} className={className}>
|
||||
<Image src={icon} width={width} height={height} />
|
||||
</Btn>
|
||||
</Link>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user