mirror of
https://github.com/dergigi/boris.git
synced 2025-12-17 14:44:26 +01:00
refactor(components): improve type safety and simplify IconButton
- Add proper type guards in ContentWithResolvedProfiles to avoid type assertions - Remove href/link functionality from IconButton component for simplification - Replace 'as any' with proper type narrowing using type predicates
This commit is contained in:
@@ -9,9 +9,6 @@ interface IconButtonProps {
|
||||
ariaLabel?: string
|
||||
variant?: 'primary' | 'success' | 'ghost'
|
||||
size?: number
|
||||
href?: string
|
||||
target?: string
|
||||
rel?: string
|
||||
}
|
||||
|
||||
const IconButton: React.FC<IconButtonProps> = ({
|
||||
@@ -20,35 +17,15 @@ const IconButton: React.FC<IconButtonProps> = ({
|
||||
title,
|
||||
ariaLabel,
|
||||
variant = 'ghost',
|
||||
size = 44,
|
||||
href,
|
||||
target,
|
||||
rel
|
||||
size = 44
|
||||
}) => {
|
||||
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
|
||||
{...(commonProps as any)}
|
||||
className={`icon-button ${variant}`}
|
||||
onClick={onClick}
|
||||
title={title}
|
||||
aria-label={ariaLabel || title}
|
||||
style={{ width: size, height: size }}
|
||||
>
|
||||
<FontAwesomeIcon icon={icon} />
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user