refactor(ui): use IconButton for kind icon (square, link-capable)

This commit is contained in:
Gigi
2025-10-03 00:59:45 +02:00
parent 18af2d02ea
commit 4fe9fd5470
2 changed files with 42 additions and 18 deletions

View File

@@ -9,6 +9,9 @@ interface IconButtonProps {
ariaLabel?: string
variant?: 'primary' | 'success' | 'ghost'
size?: number
href?: string
target?: string
rel?: string
}
const IconButton: React.FC<IconButtonProps> = ({
@@ -17,15 +20,35 @@ const IconButton: React.FC<IconButtonProps> = ({
title,
ariaLabel,
variant = 'ghost',
size = 44
size = 44,
href,
target,
rel
}) => {
const commonProps = {
className: `icon-button ${variant}`,
title,
'aria-label': ariaLabel || title,
style: { width: size, height: size }
} as const
if (href) {
return (
<a
{...(commonProps as any)}
href={href}
target={target || '_blank'}
rel={rel || 'noopener noreferrer'}
>
<FontAwesomeIcon icon={icon} />
</a>
)
}
return (
<button
className={`icon-button ${variant}`}
{...(commonProps as any)}
onClick={onClick}
title={title}
aria-label={ariaLabel || title}
style={{ width: size, height: size }}
>
<FontAwesomeIcon icon={icon} />
</button>