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:
parent
1932f9a836
commit
a56cccd91f
3 changed files with 28 additions and 12 deletions
|
|
@ -203,7 +203,7 @@ export default function GlobalVariableModal({
|
||||||
password={false}
|
password={false}
|
||||||
placeholder="Choose a field for the variable..."
|
placeholder="Choose a field for the variable..."
|
||||||
id="apply-to-fields"
|
id="apply-to-fields"
|
||||||
popoverWidth="520px"
|
popoverWidth="29rem"
|
||||||
optionsPlaceholder="Fields"
|
optionsPlaceholder="Fields"
|
||||||
/>
|
/>
|
||||||
<div className="text-xs text-muted-foreground">
|
<div className="text-xs text-muted-foreground">
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import ForwardedIconComponent from "@/components/common/genericIconComponent";
|
import ForwardedIconComponent from "@/components/common/genericIconComponent";
|
||||||
|
import ShadTooltip from "@/components/common/shadTooltipComponent";
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import {
|
import {
|
||||||
Command,
|
Command,
|
||||||
|
|
@ -69,15 +70,21 @@ const CommandItemContent = ({
|
||||||
option,
|
option,
|
||||||
isSelected,
|
isSelected,
|
||||||
optionButton,
|
optionButton,
|
||||||
|
nodeStyle,
|
||||||
}: {
|
}: {
|
||||||
option: string;
|
option: string;
|
||||||
isSelected: boolean;
|
isSelected: boolean;
|
||||||
optionButton: (option: string) => ReactNode;
|
optionButton: (option: string) => ReactNode;
|
||||||
|
nodeStyle?: string;
|
||||||
}) => (
|
}) => (
|
||||||
<div className="group flex w-full items-center justify-between">
|
<div className="group flex w-full items-center justify-between">
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<SelectionIndicator isSelected={isSelected} />
|
<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>
|
</div>
|
||||||
{optionButton && optionButton(option)}
|
{optionButton && optionButton(option)}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -170,6 +177,8 @@ const CustomInputPopover = ({
|
||||||
const [isFocused, setIsFocused] = useState(false);
|
const [isFocused, setIsFocused] = useState(false);
|
||||||
const memoizedOptions = useMemo(() => new Set<string>(options), [options]);
|
const memoizedOptions = useMemo(() => new Set<string>(options), [options]);
|
||||||
|
|
||||||
|
console.log(nodeStyle);
|
||||||
|
|
||||||
const PopoverContentInput = editNode
|
const PopoverContentInput = editNode
|
||||||
? PopoverContent
|
? PopoverContent
|
||||||
: PopoverContentWithoutPortal;
|
: PopoverContentWithoutPortal;
|
||||||
|
|
@ -222,15 +231,21 @@ const CustomInputPopover = ({
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
) : selectedOption?.length > 0 ? (
|
) : selectedOption?.length > 0 ? (
|
||||||
|
<ShadTooltip content={selectedOption} side="left">
|
||||||
|
<div>
|
||||||
<OptionBadge
|
<OptionBadge
|
||||||
option={selectedOption}
|
option={selectedOption}
|
||||||
onRemove={(e) => handleRemoveOption(selectedOption, e)}
|
onRemove={(e) => handleRemoveOption(selectedOption, e)}
|
||||||
variant={nodeStyle ? "emerald" : "secondary"}
|
variant={nodeStyle ? "emerald" : "secondary"}
|
||||||
className={cn(
|
className={cn(
|
||||||
editNode && "text-xs",
|
editNode && "text-xs",
|
||||||
nodeStyle ? "rounded-[3px] px-1 font-mono" : "bg-muted",
|
nodeStyle
|
||||||
|
? "max-w-60 rounded-[3px] px-1 font-mono"
|
||||||
|
: "bg-muted",
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
|
</ShadTooltip>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{!selectedOption?.length && !selectedOptions?.length && (
|
{!selectedOption?.length && !selectedOptions?.length && (
|
||||||
|
|
@ -304,6 +319,7 @@ const CustomInputPopover = ({
|
||||||
selectedOptions?.includes(option)
|
selectedOptions?.includes(option)
|
||||||
}
|
}
|
||||||
optionButton={optionButton}
|
optionButton={optionButton}
|
||||||
|
nodeStyle={nodeStyle}
|
||||||
/>
|
/>
|
||||||
</CommandItem>
|
</CommandItem>
|
||||||
))}
|
))}
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ export default function InputGlobalComponent({
|
||||||
return (
|
return (
|
||||||
<InputComponent
|
<InputComponent
|
||||||
nodeStyle
|
nodeStyle
|
||||||
popoverWidth="315px"
|
popoverWidth="17.5rem"
|
||||||
placeholder={getPlaceholder(disabled, placeholder)}
|
placeholder={getPlaceholder(disabled, placeholder)}
|
||||||
id={id}
|
id={id}
|
||||||
editNode={editNode}
|
editNode={editNode}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue