kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Add iconClassName prop in Button
rodzic
bad386ee23
commit
2d8859ead4
|
@ -14,6 +14,8 @@ interface IButton {
|
||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
/** Extra class names for the button. */
|
/** Extra class names for the button. */
|
||||||
className?: string;
|
className?: string;
|
||||||
|
/** Extra class names for the icon. */
|
||||||
|
iconClassName?: string;
|
||||||
/** Prevent the button from being clicked. */
|
/** Prevent the button from being clicked. */
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
/** Specifies the icon element as 'svg' or 'img'. */
|
/** Specifies the icon element as 'svg' or 'img'. */
|
||||||
|
@ -49,6 +51,7 @@ const Button = forwardRef<HTMLButtonElement, IButton>((props, ref): JSX.Element
|
||||||
to,
|
to,
|
||||||
type = 'button',
|
type = 'button',
|
||||||
className,
|
className,
|
||||||
|
iconClassName,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const body = text || children;
|
const body = text || children;
|
||||||
|
@ -65,7 +68,7 @@ const Button = forwardRef<HTMLButtonElement, IButton>((props, ref): JSX.Element
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return <Icon src={icon} className='size-4' element={iconElement} />;
|
return <Icon src={icon} className={clsx('size-4', iconClassName)} element={iconElement} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClick: React.MouseEventHandler<HTMLButtonElement> = useCallback((event) => {
|
const handleClick: React.MouseEventHandler<HTMLButtonElement> = useCallback((event) => {
|
||||||
|
|
Ładowanie…
Reference in New Issue