Skip to content

Commit

Permalink
refactor(menuitem): change to using tooltip and set delay to 500ms
Browse files Browse the repository at this point in the history
\
  • Loading branch information
seaerchin committed Nov 10, 2023
1 parent 1edcb8e commit eb41ace
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
2 changes: 0 additions & 2 deletions src/layouts/components/Editor/components/MenuBar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { Divider, HStack } from "@chakra-ui/react"
import { Editor } from "@tiptap/react"
import { Fragment } from "react"
import { v4 as uuid } from "uuid"

import { useEditorModal } from "contexts/EditorModalContext"

Expand Down
37 changes: 20 additions & 17 deletions src/layouts/components/Editor/components/MenuItem.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Tooltip } from "@chakra-ui/react"
import { IconButton } from "@opengovsg/design-system-react"
import { MouseEventHandler } from "react"
import remixiconUrl from "remixicon/fonts/remixicon.symbol.svg"
Expand All @@ -17,21 +18,23 @@ export const MenuItem = ({
isRound,
isActive = null,
}: MenuItemProps) => (
<IconButton
_hover={{ bg: "gray.100" }}
_active={{ bg: "gray.200" }}
onClick={action}
title={title}
bgColor={isActive && isActive() ? "gray.200" : "transparent"}
border="none"
h="1.75rem"
w="1.75rem"
p="0.25rem"
aria-label={title || "divider"}
isRound={isRound}
>
<svg className="remix" height="1.25rem" width="1.25rem">
<use xlinkHref={`${remixiconUrl}#ri-${icon}`} />
</svg>
</IconButton>
// NOTE: Delay opening by 500ms
<Tooltip label={title || "divider"} openDelay={500}>
<IconButton
_hover={{ bg: "gray.100" }}
_active={{ bg: "gray.200" }}
onClick={action}
bgColor={isActive && isActive() ? "gray.200" : "transparent"}
border="none"
h="1.75rem"
w="1.75rem"
p="0.25rem"
aria-label={title || "divider"}
isRound={isRound}
>
<svg className="remix" height="1.25rem" width="1.25rem">
<use xlinkHref={`${remixiconUrl}#ri-${icon}`} />
</svg>
</IconButton>
</Tooltip>
)

0 comments on commit eb41ace

Please sign in to comment.