Skip to content

Commit b42b54c

Browse files
committed
Use Activity for sidebar
1 parent b099623 commit b42b54c

File tree

3 files changed

+43
-14
lines changed

3 files changed

+43
-14
lines changed

packages/graph-explorer/src/routes/GraphExplorer/GraphExplorer.tsx

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { cn } from "@/utils";
1+
import { Activity } from "react";
2+
import { cn, isVisible } from "@/utils";
23
import { Resizable } from "re-resizable";
34
import { Link } from "react-router";
45
import {
@@ -37,7 +38,6 @@ import GraphViewer from "@/modules/GraphViewer";
3738
import Namespaces from "@/modules/Namespaces/Namespaces";
3839
import NodeExpand from "@/modules/NodeExpand";
3940
import { NodesStyling } from "@/modules/NodesStyling";
40-
4141
import { LABELS } from "@/utils/constants";
4242
import { SearchSidebarPanel } from "@/modules/SearchSidebar";
4343
import { useAtomValue } from "jotai";
@@ -106,15 +106,17 @@ const GraphExplorer = () => {
106106
</Workspace.TopBar>
107107

108108
<Workspace.Content>
109-
{!isGraphVisible && !isTableVisible && (
109+
<Activity mode={isVisible(!isGraphVisible && !isTableVisible)}>
110110
<PanelEmptyState
111111
icon={<EmptyWidgetIcon />}
112112
title="No active views"
113113
subtitle="Use toggles in the top-right corner to show/hide views"
114114
/>
115-
)}
116-
{isGraphVisible && <GraphViewer />}
117-
{isTableVisible && (
115+
</Activity>
116+
<Activity mode={isVisible(isGraphVisible)}>
117+
<GraphViewer />
118+
</Activity>
119+
<Activity mode={isVisible(isTableVisible)}>
118120
<Resizable
119121
enable={RESIZE_ENABLE_TOP}
120122
size={{
@@ -128,7 +130,7 @@ const GraphExplorer = () => {
128130
>
129131
<EntitiesTabular />
130132
</Resizable>
131-
)}
133+
</Activity>
132134
</Workspace.Content>
133135

134136
<Workspace.SideBar direction="row">
@@ -179,13 +181,27 @@ const GraphExplorer = () => {
179181
)}
180182

181183
<Workspace.SideBar.Content>
182-
{activeSidebarItem === "search" && <SearchSidebarPanel />}
183-
{activeSidebarItem === "details" && <EntityDetails />}
184-
{activeSidebarItem === "expand" && <NodeExpand />}
185-
{activeSidebarItem === "filters" && <EntitiesFilter />}
186-
{activeSidebarItem === "nodes-styling" && <NodesStyling />}
187-
{activeSidebarItem === "edges-styling" && <EdgesStyling />}
188-
{activeSidebarItem === "namespaces" && <Namespaces />}
184+
<Activity mode={isVisible(activeSidebarItem === "search")}>
185+
<SearchSidebarPanel />
186+
</Activity>
187+
<Activity mode={isVisible(activeSidebarItem === "details")}>
188+
<EntityDetails />
189+
</Activity>
190+
<Activity mode={isVisible(activeSidebarItem === "expand")}>
191+
<NodeExpand />
192+
</Activity>
193+
<Activity mode={isVisible(activeSidebarItem === "filters")}>
194+
<EntitiesFilter />
195+
</Activity>
196+
<Activity mode={isVisible(activeSidebarItem === "nodes-styling")}>
197+
<NodesStyling />
198+
</Activity>
199+
<Activity mode={isVisible(activeSidebarItem === "edges-styling")}>
200+
<EdgesStyling />
201+
</Activity>
202+
<Activity mode={isVisible(activeSidebarItem === "namespaces")}>
203+
<Namespaces />
204+
</Activity>
189205
</Workspace.SideBar.Content>
190206
</Workspace.SideBar>
191207
</Workspace>

packages/graph-explorer/src/utils/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ export * from "./formatEntityCounts";
1717
export * from "./formatRelativeDate";
1818
export * from "./numbers";
1919
export * from "./isCancellationError";
20+
export * from "./isVisible";
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import type { Activity, ComponentProps } from "react";
2+
3+
/**
4+
* Returns the mode for the Activity component based on the condition.
5+
* @param condition - The condition to check.
6+
* @returns The mode for the Activity component.
7+
*/
8+
export function isVisible(
9+
condition: boolean
10+
): ComponentProps<typeof Activity>["mode"] {
11+
return condition ? "visible" : "hidden";
12+
}

0 commit comments

Comments
 (0)