mirror of
https://github.com/wanderer-industries/wanderer
synced 2025-12-06 15:55:36 +00:00
* feat(Map): Add widget for comments. Refactor design of Signatures widget. Refactor a lot of code. Add Transition component in ui-kit. Sync versions of react. --------- Co-authored-by: Dmitry Popov <dmitriypopovsamara@gmail.com> Co-authored-by: achichenkov <aleksei.chichenkov@telleqt.ai>
60 lines
1.5 KiB
TypeScript
60 lines
1.5 KiB
TypeScript
import classes from './WdImgButton.module.scss';
|
|
import clsx from 'clsx';
|
|
import { WithClassName } from '@/hooks/Mapper/types/common.ts';
|
|
import { HTMLProps, MouseEvent } from 'react';
|
|
import { WdTooltipWrapper, WdTooltipWrapperProps } from '@/hooks/Mapper/components/ui-kit/WdTooltipWrapper';
|
|
|
|
export enum WdImageSize {
|
|
off = 'off',
|
|
small = 'small',
|
|
normal = 'normal',
|
|
large = 'large',
|
|
}
|
|
|
|
export type WdImgButtonProps = {
|
|
onClick?(e: MouseEvent): void;
|
|
source?: string;
|
|
width?: number;
|
|
height?: number;
|
|
tooltip?: Pick<WdTooltipWrapperProps, 'content' | 'position' | 'offset' | 'className'>;
|
|
textSize?: WdImageSize;
|
|
} & WithClassName &
|
|
HTMLProps<HTMLDivElement>;
|
|
|
|
export const WdImgButton = ({
|
|
onClick,
|
|
className,
|
|
source,
|
|
width = 20,
|
|
height = 20,
|
|
textSize = WdImageSize.normal,
|
|
tooltip,
|
|
disabled,
|
|
...props
|
|
}: WdImgButtonProps) => {
|
|
const content = (
|
|
<div
|
|
{...props}
|
|
className={clsx(
|
|
classes.WdImgButtonRoot,
|
|
{
|
|
[classes.Normal]: textSize === WdImageSize.normal,
|
|
[classes.Large]: textSize === WdImageSize.large,
|
|
[classes.Disabled]: disabled,
|
|
},
|
|
'pi cursor-pointer',
|
|
className,
|
|
)}
|
|
onClick={disabled ? undefined : onClick}
|
|
>
|
|
{source && <img src={source} width={width} height={height} className="external-icon" />}
|
|
</div>
|
|
);
|
|
|
|
if (tooltip) {
|
|
return <WdTooltipWrapper {...tooltip}>{content}</WdTooltipWrapper>;
|
|
}
|
|
|
|
return content;
|
|
};
|