refactor: add tooltips to UI global variables components (#5648)

* 📝 (GlobalVariableModal.tsx): adjust popover width from "520px" to "29rem" for better UI responsiveness
📝 (index.tsx): import ShadTooltip component and update CommandItemContent to use it for better user experience
📝 (index.tsx): update popover width from "315px" to "17.5rem" for consistency and improved design aesthetics

* 🔧 (index.tsx): add side prop to ShadTooltip component to position the tooltip on the left side of the content.

*  (index.tsx): Add support for custom node styles in CommandItemContent component to allow for more flexible styling options
🔧 (index.tsx): Pass nodeStyle prop to CommandItemContent component to customize node styles based on the provided value
This commit is contained in:
Cristhian Zanforlin Lousa 2025-01-16 10:18:43 -03:00 committed by GitHub
commit a56cccd91f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 28 additions and 12 deletions

View file

@ -203,7 +203,7 @@ export default function GlobalVariableModal({
password={false}
placeholder="Choose a field for the variable..."
id="apply-to-fields"
popoverWidth="520px"
popoverWidth="29rem"
optionsPlaceholder="Fields"
/>
<div className="text-xs text-muted-foreground">

View file

@ -1,4 +1,5 @@
import ForwardedIconComponent from "@/components/common/genericIconComponent";
import ShadTooltip from "@/components/common/shadTooltipComponent";
import { Badge } from "@/components/ui/badge";
import {
Command,
@ -69,15 +70,21 @@ const CommandItemContent = ({
option,
isSelected,
optionButton,
nodeStyle,
}: {
option: string;
isSelected: boolean;
optionButton: (option: string) => ReactNode;
nodeStyle?: string;
}) => (
<div className="group flex w-full items-center justify-between">
<div className="flex items-center justify-between">
<SelectionIndicator isSelected={isSelected} />
<span className="max-w-52 truncate pr-2">{option}</span>
<ShadTooltip content={option} side="left">
<div className={cn("truncate pr-2", nodeStyle ? "max-w-52" : "w-full")}>
<span>{option}</span>
</div>
</ShadTooltip>
</div>
{optionButton && optionButton(option)}
</div>
@ -170,6 +177,8 @@ const CustomInputPopover = ({
const [isFocused, setIsFocused] = useState(false);
const memoizedOptions = useMemo(() => new Set<string>(options), [options]);
console.log(nodeStyle);
const PopoverContentInput = editNode
? PopoverContent
: PopoverContentWithoutPortal;
@ -222,15 +231,21 @@ const CustomInputPopover = ({
))}
</div>
) : selectedOption?.length > 0 ? (
<OptionBadge
option={selectedOption}
onRemove={(e) => handleRemoveOption(selectedOption, e)}
variant={nodeStyle ? "emerald" : "secondary"}
className={cn(
editNode && "text-xs",
nodeStyle ? "rounded-[3px] px-1 font-mono" : "bg-muted",
)}
/>
<ShadTooltip content={selectedOption} side="left">
<div>
<OptionBadge
option={selectedOption}
onRemove={(e) => handleRemoveOption(selectedOption, e)}
variant={nodeStyle ? "emerald" : "secondary"}
className={cn(
editNode && "text-xs",
nodeStyle
? "max-w-60 rounded-[3px] px-1 font-mono"
: "bg-muted",
)}
/>
</div>
</ShadTooltip>
) : null}
{!selectedOption?.length && !selectedOptions?.length && (
@ -304,6 +319,7 @@ const CustomInputPopover = ({
selectedOptions?.includes(option)
}
optionButton={optionButton}
nodeStyle={nodeStyle}
/>
</CommandItem>
))}

View file

@ -90,7 +90,7 @@ export default function InputGlobalComponent({
return (
<InputComponent
nodeStyle
popoverWidth="315px"
popoverWidth="17.5rem"
placeholder={getPlaceholder(disabled, placeholder)}
id={id}
editNode={editNode}