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"> <div className="bookmark-meta">
{eventNevent ? ( {eventNevent ? (
<a <IconButton
href={`https://search.dergigi.com/e/${eventNevent}`} icon={getKindIcon(bookmark.kind)}
target="_blank" ariaLabel="Open event in search"
rel="noopener noreferrer"
className="kind-icon-link"
title="Open event in search" title="Open event in search"
> href={`https://search.dergigi.com/e/${eventNevent}`}
<span className="kind-icon"> variant="ghost"
<FontAwesomeIcon icon={getKindIcon(bookmark.kind)} /> size={32}
</span> />
</a>
) : ( ) : (
<span className="kind-icon"> <IconButton
<FontAwesomeIcon icon={getKindIcon(bookmark.kind)} /> icon={getKindIcon(bookmark.kind)}
</span> ariaLabel="Event kind"
title="Event kind"
variant="ghost"
size={32}
/>
)} )}
<span> <span>
<a <a

View File

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