mirror of
https://github.com/stackblitz/bolt.new
synced 2024-11-27 22:42:21 +00:00
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import { memo } from 'react';
|
|
import { classNames } from '~/utils/classNames';
|
|
|
|
interface PanelHeaderButtonProps {
|
|
className?: string;
|
|
disabledClassName?: string;
|
|
disabled?: boolean;
|
|
children: string | JSX.Element | Array<JSX.Element | string>;
|
|
onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
}
|
|
|
|
export const PanelHeaderButton = memo(
|
|
({ className, disabledClassName, disabled = false, children, onClick }: PanelHeaderButtonProps) => {
|
|
return (
|
|
<button
|
|
className={classNames(
|
|
'flex items-center shrink-0 gap-1.5 px-1.5 rounded-md py-0.5 text-bolt-elements-item-contentDefault bg-transparent enabled:hover:text-bolt-elements-item-contentActive enabled:hover:bg-bolt-elements-item-backgroundActive disabled:cursor-not-allowed',
|
|
{
|
|
[classNames('opacity-30', disabledClassName)]: disabled,
|
|
},
|
|
className,
|
|
)}
|
|
disabled={disabled}
|
|
onClick={(event) => {
|
|
if (disabled) {
|
|
return;
|
|
}
|
|
|
|
onClick?.(event);
|
|
}}
|
|
>
|
|
{children}
|
|
</button>
|
|
);
|
|
},
|
|
);
|