mirror of
https://github.com/jeffvli/sonixd.git
synced 2026-05-02 20:22:38 -04:00
move tooltip to shared folder
This commit is contained in:
@@ -1,27 +1,21 @@
|
||||
import React from 'react';
|
||||
import { IconButton, Icon, Tooltip, Whisper } from 'rsuite';
|
||||
import { IconButton, Icon } from 'rsuite';
|
||||
import { useAppDispatch } from '../../redux/hooks';
|
||||
import { clearSelected } from '../../redux/multiSelectSlice';
|
||||
|
||||
const tooltip = (text: string) => <Tooltip>{text}</Tooltip>;
|
||||
import CustomTooltip from '../shared/CustomTooltip';
|
||||
|
||||
const CustomIconButton = ({ tooltipText, icon, handleClick, ...rest }: any) => {
|
||||
return (
|
||||
<>
|
||||
{tooltipText ? (
|
||||
<Whisper
|
||||
placement="top"
|
||||
trigger="hover"
|
||||
delay={300}
|
||||
speaker={tooltip(tooltipText)}
|
||||
>
|
||||
<CustomTooltip text={tooltipText}>
|
||||
<IconButton
|
||||
size="xs"
|
||||
{...rest}
|
||||
icon={<Icon icon={icon} {...rest} />}
|
||||
onClick={handleClick}
|
||||
/>
|
||||
</Whisper>
|
||||
</CustomTooltip>
|
||||
) : (
|
||||
<IconButton size="xs" icon={<Icon icon={icon} {...rest} />} />
|
||||
)}
|
||||
|
||||
19
src/components/shared/CustomTooltip.tsx
Normal file
19
src/components/shared/CustomTooltip.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
import React from 'react';
|
||||
import { Tooltip, Whisper } from 'rsuite';
|
||||
|
||||
export const tooltip = (text: string) => <Tooltip>{text}</Tooltip>;
|
||||
|
||||
const CustomTooltip = ({ children, text, delay }: any) => {
|
||||
return (
|
||||
<Whisper
|
||||
placement="top"
|
||||
trigger="hover"
|
||||
delay={delay || 300}
|
||||
speaker={tooltip(text)}
|
||||
>
|
||||
{children}
|
||||
</Whisper>
|
||||
);
|
||||
};
|
||||
|
||||
export default CustomTooltip;
|
||||
Reference in New Issue
Block a user