Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: standardize toolbar select item widths and improve alignment #4539

Merged
merged 19 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
cecba35
📝 (select-custom.tsx): Update styling in SelectItem component to impr…
Cristhianzl Nov 12, 2024
2116b88
✨ (nodeToolbarComponent/index.tsx): Center align select items by addi…
Cristhianzl Nov 12, 2024
abb14fe
Merge branch 'main' into cz/fix-toolbar
Cristhianzl Nov 12, 2024
88158fb
Merge branch 'main' into cz/fix-toolbar
Cristhianzl Nov 12, 2024
653bf97
✨ (GenericNode/index.tsx): Add functionality to toggle show more opti…
Cristhianzl Nov 12, 2024
54ada98
Merge branch 'cz/fix-toolbar' of github.com:langflow-ai/langflow into…
Cristhianzl Nov 12, 2024
2e90278
Merge branch 'main' into cz/fix-toolbar
Cristhianzl Nov 12, 2024
8a25ca7
✨ (nodeToolbarComponent/index.tsx): Update styles and dimensions for …
Cristhianzl Nov 12, 2024
b9e4d5c
Merge branch 'cz/fix-toolbar' of github.com:langflow-ai/langflow into…
Cristhianzl Nov 12, 2024
5a0f511
🔧 (nodeToolbarComponent/index.tsx): Remove unnecessary 'm-auto' class…
Cristhianzl Nov 12, 2024
de13925
📝 (select-custom.tsx): Update styling in SelectItem component to impr…
Cristhianzl Nov 12, 2024
1674bdb
✨ (nodeToolbarComponent/index.tsx): Center align select items by addi…
Cristhianzl Nov 12, 2024
46b8945
✨ (GenericNode/index.tsx): Add functionality to toggle show more opti…
Cristhianzl Nov 12, 2024
eaa8e0d
✨ (nodeToolbarComponent/index.tsx): Update styles and dimensions for …
Cristhianzl Nov 12, 2024
948b5a8
🔧 (nodeToolbarComponent/index.tsx): Remove unnecessary 'm-auto' class…
Cristhianzl Nov 12, 2024
ac841cb
Merge branch 'main' into cz/fix-toolbar
Cristhianzl Nov 13, 2024
6e24fee
✨ (actionsMainPage-shard-1.spec.ts): Update test descriptions to use …
Cristhianzl Nov 13, 2024
80eda65
Merge branch 'cz/fix-toolbar' of github.com:langflow-ai/langflow into…
Cristhianzl Nov 13, 2024
a135abc
🔧 (typescript_test.yml): Update shardIndex and shardTotal values to r…
Cristhianzl Nov 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/frontend/src/CustomNodes/GenericNode/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ export default function GenericNode({

const shortcuts = useShortcutsStore((state) => state.shortcuts);

const [openShowMoreOptions, setOpenShowMoreOptions] = useState(false);

const renderOutputParameter = (
output: OutputFieldType,
idx: number,
Expand Down Expand Up @@ -232,6 +234,7 @@ export default function GenericNode({
onCloseAdvancedModal={() => {}}
updateNode={handleUpdateCode}
isOutdated={isOutdated && isUserEdited}
setOpenShowMoreOptions={setOpenShowMoreOptions}
/>
</NodeToolbar>
);
Expand Down Expand Up @@ -335,6 +338,7 @@ export default function GenericNode({
: `h-[4.065rem] w-48 rounded-[0.75rem] ${!selected ? "border-[1px] border-border ring-[0.5px] ring-border" : ""}`,
"generic-node-div group/node relative",
!hasOutputs && "pb-4",
openShowMoreOptions && "nowheel",
)}
>
<div
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/components/ui/select-custom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const SelectItem = React.forwardRef<
<SelectPrimitive.Item
ref={ref}
className={cn(
"relative flex w-full cursor-pointer select-none items-center rounded-sm py-1.5 pl-3 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
"relative flex w-full cursor-pointer select-none items-center rounded-sm px-3 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
className,
)}
{...props}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export default function NodeToolbarComponent({
onCloseAdvancedModal,
updateNode,
isOutdated,
setOpenShowMoreOptions,
}: nodeToolbarPropsType): JSX.Element {
const version = useDarkStore((state) => state.version);
const [showModalAdvanced, setShowModalAdvanced] = useState(false);
Expand Down Expand Up @@ -344,6 +345,10 @@ export default function NodeToolbarComponent({
(selectTriggerRef.current! as HTMLElement)?.click();
};

const handleOpenChange = (open: boolean) => {
setOpenShowMoreOptions && setOpenShowMoreOptions(open);
};

const [toolMode, setToolMode] = useState(() => {
// Check if tool mode is explicitly set on the node
const hasToolModeProperty = data.node?.tool_mode;
Expand Down Expand Up @@ -380,6 +385,7 @@ export default function NodeToolbarComponent({
}, [zoom]);

if (scale === null) return <></>;

return (
<>
<div
Expand Down Expand Up @@ -544,13 +550,22 @@ export default function NodeToolbarComponent({
</ShadTooltip>
</div>

<Select onValueChange={handleSelectChange} value={selectedValue!}>
<SelectTrigger ref={selectTriggerRef}>
<Select
onValueChange={handleSelectChange}
value={selectedValue!}
onOpenChange={handleOpenChange}
open
>
<SelectTrigger ref={selectTriggerRef} className="w-62">
<></>
</SelectTrigger>
<SelectContent
className="relative min-w-[14rem] bg-background"
style={{ transform: `scale(${scale})`, transformOrigin: "top" }}
className={"relative top-1 w-56 bg-background"}
style={{
transform: `scale(${scale})`,
transformOrigin: "top",
left: scale === 1 ? "4.5rem" : `${1.7 * (scale - 1)}rem`,
}}
>
{hasCode && (
<SelectItem value={"code"}>
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/types/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ export type nodeToolbarPropsType = {
isOutdated: boolean;
updateNode: () => void;
closeToolbar?: () => void;
setOpenShowMoreOptions?: (open: boolean) => void;
};

export type parsedDataType = {
Expand Down
Loading