Skip to content

Commit

Permalink
Enable touch on tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
HussainTaj-W committed Jun 5, 2023
1 parent 789bc8e commit 74591d7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/components/Skill/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Box, Text, Image, Progress, Tag, Tooltip } from "@chakra-ui/react";
import { Box, Text, Image, Progress, Tag } from "@chakra-ui/react";

import TooltipTouch from "@/components/TooltipTouch";
import ISkill from "@/types/skill";

import styles from "./styles.module.scss";
Expand All @@ -16,7 +17,7 @@ function Skill({ data, type = "full" }: Props) {
const isFull = type === "full";

return (
<Tooltip
<TooltipTouch
label={data.name}
aria-label="A tooltip"
isDisabled={!isIcon}
Expand Down Expand Up @@ -71,7 +72,7 @@ function Skill({ data, type = "full" }: Props) {
/>
) : null}
</Box>
</Tooltip>
</TooltipTouch>
);
}

Expand Down
29 changes: 29 additions & 0 deletions src/components/TooltipTouch/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { ReactNode, useState } from "react";

import { Box, Tooltip } from "@chakra-ui/react";

const TooltipTouch = ({
children,
...restToolTipProps
}: {
children: ReactNode;
[key: string]: any;
}) => {
const [isLabelOpen, setIsLabelOpen] = useState(false);

return (
<Tooltip isOpen={isLabelOpen} {...restToolTipProps}>
<Box
onMouseEnter={() =>
setIsLabelOpen(true && !restToolTipProps.isDisabled)
}
onMouseLeave={() => setIsLabelOpen(false)}
onClick={() => setIsLabelOpen(true && !restToolTipProps.isDisabled)}
>
{children}
</Box>
</Tooltip>
);
};

export default TooltipTouch;

0 comments on commit 74591d7

Please sign in to comment.