-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create and implement ModsTableTooltip component
-still doesn't work when the `ModsTable` is scrolled down -haven't figured out how to make the `multiline` functionality of the `Tooltip` work yet
- Loading branch information
Showing
3 changed files
with
137 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Tooltip, Text } from "@mantine/core"; | ||
import { useDebouncedValue, useDisclosure } from "@mantine/hooks"; | ||
|
||
|
||
|
||
|
||
type ModsTableTooltipProps = { | ||
targetString: string; | ||
dropdownString: string; | ||
multiline?: boolean; | ||
maxWidth?: number; | ||
}; | ||
|
||
|
||
|
||
/** `target` must be able to accept a `ref`. */ | ||
export const ModsTableTooltip = ({ | ||
targetString, | ||
dropdownString, | ||
multiline = false, //TODO!!!: figure out how to make multiline work | ||
maxWidth, | ||
}: ModsTableTooltipProps) => { | ||
const [isOpened, { close, open }] = useDisclosure(false); | ||
|
||
// Since there is a gap between the link and the tooltip, | ||
// debouncing prevents the tooltip from closing when we move from the link to tooltip. | ||
const [debouncedIsOpened] = useDebouncedValue(isOpened, 200); | ||
|
||
return ( | ||
<Tooltip | ||
offset={21} | ||
opened={debouncedIsOpened} | ||
label={ | ||
<Text // TODO!!!: figure out why onMouseEnter and onMouseLeave don't work | ||
size="xs" | ||
onMouseEnter={open} | ||
onMouseLeave={close} | ||
> | ||
{dropdownString} | ||
</Text> | ||
} | ||
> | ||
<Text | ||
size="sm" | ||
onMouseEnter={open} | ||
onMouseLeave={close} | ||
> | ||
{targetString} | ||
</Text> | ||
</Tooltip> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const defaultToLocaleDateStringOptions: Intl.DateTimeFormatOptions = { | ||
year: "numeric", | ||
month: "long", | ||
day: "numeric", | ||
}; |