🔨 refactor(components): add info property to ParameterComponentType
The ParameterComponent now has an info icon and tooltip to show additional information about the parameter. The GenericNode component now passes the info prop to the ParameterComponent to show the additional information. The ParameterComponentType has been refactored to include the info property. 🎨 style(parameterComponent): add info icon and tooltip to show additional information 🚀 feat(GenericNode): pass info prop to ParameterComponent to show additional information
This commit is contained in:
parent
e362cfcf16
commit
87af22d059
3 changed files with 36 additions and 8 deletions
|
|
@ -25,6 +25,7 @@ import { nodeColors } from "../../../../utils";
|
||||||
import ShadTooltip from "../../../../components/ShadTooltipComponent";
|
import ShadTooltip from "../../../../components/ShadTooltipComponent";
|
||||||
import { PopUpContext } from "../../../../contexts/popUpContext";
|
import { PopUpContext } from "../../../../contexts/popUpContext";
|
||||||
import ToggleShadComponent from "../../../../components/toggleShadComponent";
|
import ToggleShadComponent from "../../../../components/toggleShadComponent";
|
||||||
|
import { Info } from "lucide-react";
|
||||||
|
|
||||||
export default function ParameterComponent({
|
export default function ParameterComponent({
|
||||||
left,
|
left,
|
||||||
|
|
@ -36,9 +37,11 @@ export default function ParameterComponent({
|
||||||
type,
|
type,
|
||||||
name = "",
|
name = "",
|
||||||
required = false,
|
required = false,
|
||||||
|
info = "",
|
||||||
}: ParameterComponentType) {
|
}: ParameterComponentType) {
|
||||||
const ref = useRef(null);
|
const ref = useRef(null);
|
||||||
const refHtml = useRef(null);
|
const refHtml = useRef(null);
|
||||||
|
const infoHtml = useRef(null);
|
||||||
const updateNodeInternals = useUpdateNodeInternals();
|
const updateNodeInternals = useUpdateNodeInternals();
|
||||||
const [position, setPosition] = useState(0);
|
const [position, setPosition] = useState(0);
|
||||||
const { closePopUp } = useContext(PopUpContext);
|
const { closePopUp } = useContext(PopUpContext);
|
||||||
|
|
@ -79,6 +82,18 @@ export default function ParameterComponent({
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
infoHtml.current = (
|
||||||
|
<div className="h-full w-full break-words">
|
||||||
|
{info.split("\n").map((line, i) => (
|
||||||
|
<p key={i} className="block">
|
||||||
|
{line}
|
||||||
|
</p>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}, [info]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const groupedObj = groupByFamily(myData, tooltipTitle);
|
const groupedObj = groupByFamily(myData, tooltipTitle);
|
||||||
|
|
||||||
|
|
@ -126,8 +141,25 @@ export default function ParameterComponent({
|
||||||
className="w-full flex flex-wrap justify-between items-center bg-muted dark:bg-gray-800 dark:text-white mt-1 px-5 py-2"
|
className="w-full flex flex-wrap justify-between items-center bg-muted dark:bg-gray-800 dark:text-white mt-1 px-5 py-2"
|
||||||
>
|
>
|
||||||
<>
|
<>
|
||||||
<div className={"text-sm truncate w-full " + (left ? "" : "text-end")}>
|
<div
|
||||||
|
className={
|
||||||
|
"text-sm truncate w-full" +
|
||||||
|
(left ? "" : " text-end") +
|
||||||
|
(info !== "" ? " flex items-center" : "")
|
||||||
|
}
|
||||||
|
>
|
||||||
{title}
|
{title}
|
||||||
|
<div className="">
|
||||||
|
{info !== "" && (
|
||||||
|
<ShadTooltip
|
||||||
|
open={true}
|
||||||
|
delayDuration={500}
|
||||||
|
content={infoHtml.current}
|
||||||
|
>
|
||||||
|
<Info className="ml-2 relative bottom-0.5 w-3 h-3" />
|
||||||
|
</ShadTooltip>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
<span className="text-red-600">{required ? " *" : ""}</span>
|
<span className="text-red-600">{required ? " *" : ""}</span>
|
||||||
</div>
|
</div>
|
||||||
{left &&
|
{left &&
|
||||||
|
|
|
||||||
|
|
@ -244,6 +244,7 @@ export default function GenericNode({
|
||||||
? toTitleCase(data.node.template[t].name)
|
? toTitleCase(data.node.template[t].name)
|
||||||
: toTitleCase(t)
|
: toTitleCase(t)
|
||||||
}
|
}
|
||||||
|
info={data.node.template[t].info}
|
||||||
name={t}
|
name={t}
|
||||||
tooltipTitle={data.node.template[t].type}
|
tooltipTitle={data.node.template[t].type}
|
||||||
required={data.node.template[t].required}
|
required={data.node.template[t].required}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,4 @@
|
||||||
import {
|
import { ReactElement, ReactNode } from "react";
|
||||||
ComponentType,
|
|
||||||
ForwardRefExoticComponent,
|
|
||||||
ReactElement,
|
|
||||||
ReactNode,
|
|
||||||
SVGProps,
|
|
||||||
} from "react";
|
|
||||||
import { NodeDataType } from "../flow/index";
|
import { NodeDataType } from "../flow/index";
|
||||||
import { typesContextType } from "../typesContext";
|
import { typesContextType } from "../typesContext";
|
||||||
export type InputComponentType = {
|
export type InputComponentType = {
|
||||||
|
|
@ -41,6 +35,7 @@ export type ParameterComponentType = {
|
||||||
name?: string;
|
name?: string;
|
||||||
tooltipTitle: string;
|
tooltipTitle: string;
|
||||||
dataContext?: typesContextType;
|
dataContext?: typesContextType;
|
||||||
|
info?: string;
|
||||||
};
|
};
|
||||||
export type InputListComponentType = {
|
export type InputListComponentType = {
|
||||||
value: string[];
|
value: string[];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue