Skip to content
Merged
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
30 changes: 15 additions & 15 deletions typescript-sdk/apps/dojo/src/components/layout/main-layout.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
"use client";

import React, { useState } from "react";
import React, { Suspense, useState } from "react";
import { ViewerLayout } from "@/components/layout/viewer-layout";
import { Sidebar } from "@/components/sidebar/sidebar";

import { usePathname, useSearchParams } from "next/navigation";
import featureConfig from "@/config";
import { useSearchParams } from "next/navigation";

export function MainLayout({ children }: { children: React.ReactNode }) {
const pathname = usePathname();
const searchParams = useSearchParams();

const sidebarDisabled = searchParams.get("sidebar") === "disabled";
const integrationPickerDisabled = searchParams.get("picker") === "false";

// Extract the current demo ID from the pathname
const pathParts = pathname.split("/");
const currentFeatureId = pathParts[pathParts.length - 1];
const currentFeature = featureConfig.find((d) => d.id === currentFeatureId);

return (
<ViewerLayout showFileTree={false} showCodeEditor={false}>
<div className="flex h-full w-full overflow-hidden">
{/* Sidebar */}
{!sidebarDisabled && <Sidebar activeTab={"preview"} readmeContent={""} pickerDisabled={integrationPickerDisabled} />}
<Suspense>
<MaybeSidebar/>
</Suspense>


{/* Content */}
<div className="flex-1 overflow-auto">
Expand All @@ -33,3 +24,12 @@ export function MainLayout({ children }: { children: React.ReactNode }) {
</ViewerLayout>
);
}

function MaybeSidebar() {
const searchParams = useSearchParams();

const sidebarDisabled = searchParams.get("sidebar") === "disabled";
const integrationPickerDisabled = searchParams.get("picker") === "false";

return !sidebarDisabled && <Sidebar activeTab={"preview"} readmeContent={""} pickerDisabled={integrationPickerDisabled} />;
}