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

Add sidebar width preserve in local storage #1370

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions packages/ui/src/components/Visualization/Canvas/Canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
const [selectedNode, setSelectedNode] = useState<CanvasNode | undefined>(undefined);
const [nodes, setNodes] = useState<CanvasNode[]>([]);
const [activeLayout, setActiveLayout] = useLocalStorage(LocalStorageKeys.CanvasLayout, CanvasDefaults.DEFAULT_LAYOUT);
const [sidebarWidth, setSidebarWidth] = useLocalStorage(
LocalStorageKeys.CanvasSidebarWidth,
CanvasDefaults.DEFAULT_SIDEBAR_WIDTH,
);

/** Context to interact with the Canvas catalog */
const catalogModalContext = useContext(CatalogModalContext);
Expand Down Expand Up @@ -206,6 +210,10 @@

return (
<TopologyView
defaultSideBarSize={sidebarWidth + 'px'}
onSideBarResize={(width) => {
setSidebarWidth(width);

Check warning on line 215 in packages/ui/src/components/Visualization/Canvas/Canvas.tsx

View check run for this annotation

Codecov / codecov/patch

packages/ui/src/components/Visualization/Canvas/Canvas.tsx#L214-L215

Added lines #L214 - L215 were not covered by tests
}}
sideBarResizable
sideBarOpen={isSidebarOpen}
sideBar={<CanvasSideBar selectedNode={selectedNode} onClose={handleCloseSideBar} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export class CanvasDefaults {
static readonly DEFAULT_NODE_SHAPE = NodeShape.rect;
static readonly DEFAULT_NODE_DIAMETER = 75;
static readonly DEFAULT_GROUP_PADDING = 50;
static readonly DEFAULT_SIDEBAR_WIDTH = 500;
}
1 change: 1 addition & 0 deletions packages/ui/src/models/local-storage-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export const enum LocalStorageKeys {
SourceCode = 'sourceCode',
CatalogLayout = 'catalogLayout',
CanvasLayout = 'canvasLayout',
CanvasSidebarWidth = 'canvasSidebarWidth',
NavigationExpanded = 'navigationExpanded',
SelectedCatalog = 'selectedCatalog',
Settings = 'settings',
Expand Down
Loading