mirror of
https://gitlab.nic.cz/turris/reforis/foris-js.git
synced 2024-11-14 17:35:35 +01:00
Compare commits
No commits in common. "3fa5ab7c0748d72ab358dab9712b26d503f7c8b1" and "39257567d48b453df1e7649831be5f9483856a43" have entirely different histories.
3fa5ab7c07
...
39257567d4
|
@ -69,7 +69,7 @@ export {
|
|||
withErrorMessage,
|
||||
} from "./utils/conditionalHOCs";
|
||||
export { ErrorMessage } from "./utils/ErrorMessage";
|
||||
export { useClickOutside } from "./utils/hooks";
|
||||
export { useClickOutside, useTooltip } from "./utils/hooks";
|
||||
export { toLocaleDateString } from "./utils/datetime";
|
||||
export { displayCard } from "./utils/displayCard";
|
||||
export { isPluginInstalled } from "./utils/isPluginInstalled";
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
import { useState, useEffect } from "react";
|
||||
import { useState, useEffect, useRef } from "react";
|
||||
import { Tooltip } from "bootstrap/dist/js/bootstrap.bundle.min";
|
||||
|
||||
/** Execute callback when condition is set to true. */
|
||||
export function useConditionalTimeout(
|
||||
|
@ -40,3 +41,22 @@ export function useClickOutside(element, callback) {
|
|||
};
|
||||
});
|
||||
}
|
||||
|
||||
/** useTooltip hook for Bootstrap tooltips. */
|
||||
export function useTooltip(description, placement = "top", trigger = "hover") {
|
||||
const tooltipRef = useRef();
|
||||
|
||||
useEffect(() => {
|
||||
const tooltip = new Tooltip(tooltipRef.current, {
|
||||
title: description,
|
||||
placement,
|
||||
trigger,
|
||||
});
|
||||
|
||||
return () => {
|
||||
tooltip.dispose();
|
||||
};
|
||||
});
|
||||
|
||||
return tooltipRef;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user