1
0
mirror of https://gitlab.nic.cz/turris/reforis/foris-js.git synced 2024-11-14 17:35:35 +01:00

Add Bootstrap tooltip component

This commit is contained in:
Aleksandr Gumroian 2022-03-18 18:43:13 +01:00
parent e1064c70fb
commit e00863a343
No known key found for this signature in database
GPG Key ID: 9E77849C64F0A733
2 changed files with 39 additions and 0 deletions

38
src/bootstrap/Tooltip.js Normal file
View File

@ -0,0 +1,38 @@
/*
* Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
*
* This is free software, licensed under the GNU General Public License v3.
* See /LICENSE for more information.
*/
import React, { useEffect, useRef } from "react";
import PropTypes from "prop-types";
import { Tooltip as BSTooltip } from "bootstrap/dist/js/bootstrap.esm";
export function Tooltip({ title, placement, trigger, children }) {
const tooltipRef = useRef();
useEffect(() => {
const tooltip = new BSTooltip(tooltipRef.current, {
title,
placement,
trigger,
});
});
return <span ref={tooltipRef}>{children}</span>;
}
Tooltip.propTypes = {
/** Field label. */
title: PropTypes.string.isRequired,
/** Error text. */
placement: PropTypes.string,
/** Help text message. */
trigger: PropTypes.string,
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node),
PropTypes.node,
]),
};

View File

@ -30,6 +30,7 @@ export { PasswordInput } from "./bootstrap/PasswordInput";
export { Radio, RadioSet } from "./bootstrap/RadioSet";
export { Select } from "./bootstrap/Select";
export { TextInput } from "./bootstrap/TextInput";
export { Tooltip } from "./bootstrap/Tooltip";
export { formFieldsSize, buttonFormFieldsSize } from "./bootstrap/constants";
export { Switch } from "./bootstrap/Switch";