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

@@ -134,21 +134,22 @@ export const BookmarkItem: React.FC<BookmarkItemProps> = ({ bookmark, index, onS
<div className="bookmark-meta">
{eventNevent ? (
<a
href={`https://search.dergigi.com/e/${eventNevent}`}
target="_blank"
rel="noopener noreferrer"
className="kind-icon-link"
<IconButton
icon={getKindIcon(bookmark.kind)}
ariaLabel="Open event in search"
title="Open event in search"
>
<span className="kind-icon">
<FontAwesomeIcon icon={getKindIcon(bookmark.kind)} />
</span>
</a>
href={`https://search.dergigi.com/e/${eventNevent}`}
variant="ghost"
size={32}
/>
) : (
<span className="kind-icon">
<FontAwesomeIcon icon={getKindIcon(bookmark.kind)} />
</span>
<IconButton
icon={getKindIcon(bookmark.kind)}
ariaLabel="Event kind"
title="Event kind"
variant="ghost"
size={32}
/>
)}
<span>
<a

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>