Skip to content

Commit d46752f

Browse files
authored
Merge pull request #168 from MeshJS/Sidebar-Layout
Enhance layout: sidebar and mobile menu
2 parents 5627289 + 0ae6383 commit d46752f

File tree

8 files changed

+256
-245
lines changed

8 files changed

+256
-245
lines changed

src/components/common/overall-layout/layout.tsx

Lines changed: 34 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ import useAppWallet from "@/hooks/useAppWallet";
1212
import SessionProvider from "@/components/SessionProvider";
1313
import { getServerSession } from "next-auth";
1414

15-
import MenuWallets from "@/components/common/overall-layout/menus/wallets";
15+
// import MenuWallets from "@/components/common/overall-layout/menus/wallets";
1616
import MenuWallet from "@/components/common/overall-layout/menus/multisig-wallet";
17-
import WalletDropDown from "@/components/common/overall-layout/wallet-drop-down";
1817
import {
1918
WalletDataLoaderWrapper,
2019
DialogReportWrapper,
@@ -27,13 +26,6 @@ import ConnectWallet from "@/components/common/cardano-objects/connect-wallet";
2726
import Loading from "@/components/common/overall-layout/loading";
2827
import { MobileNavigation } from "@/components/ui/mobile-navigation";
2928
import { MobileActionsMenu } from "@/components/ui/mobile-actions-menu";
30-
import {
31-
Breadcrumb,
32-
BreadcrumbItem,
33-
BreadcrumbLink,
34-
BreadcrumbList,
35-
BreadcrumbSeparator,
36-
} from "@/components/ui/breadcrumb";
3729

3830
// Enhanced error boundary component for wallet errors
3931
class WalletErrorBoundary extends Component<
@@ -161,19 +153,6 @@ export default function RootLayout({
161153
return;
162154
}
163155

164-
// Handle connection errors with retry logic
165-
if (error instanceof Error && (
166-
error.message.includes("Could not establish connection") ||
167-
error.message.includes("Receiving end does not exist") ||
168-
error.message.includes("Cannot read properties of undefined")
169-
)) {
170-
console.log("Browser extension connection error detected, retrying in 2 seconds...");
171-
setTimeout(() => {
172-
window.location.reload();
173-
}, 2000);
174-
return;
175-
}
176-
177156
// For other errors, don't throw to prevent app crash
178157
// The user can retry by reconnecting their wallet
179158
}
@@ -187,106 +166,33 @@ export default function RootLayout({
187166
const isLoggedIn = !!user;
188167

189168
return (
190-
<div className={`grid h-screen w-screen overflow-hidden ${isLoggedIn ? 'md:grid-cols-[240px_1fr] lg:grid-cols-[260px_1fr]' : ''}`}>
169+
<div className="flex h-screen w-screen flex-col overflow-hidden">
191170
{isLoading && <Loading />}
192171

193-
{/* Sidebar for larger screens - shown when logged in */}
194-
{isLoggedIn && (
195-
<aside className="hidden border-r border-gray-200/30 bg-muted/40 dark:border-white/[0.03] md:block">
196-
<div className="flex h-full max-h-screen flex-col">
197-
<header
198-
className="flex h-14 items-center border-b border-gray-200/30 px-4 dark:border-white/[0.03] lg:h-16 lg:px-6"
199-
id="logo-header"
200-
data-header="sidebar"
201-
>
202-
<Link href="/" className="flex items-center gap-3">
203-
<Logo />
204-
<span className="select-none text-sm font-medium tracking-[-0.01em] md:text-base lg:text-lg">
205-
Multi-Sig Platform
206-
</span>
207-
</Link>
208-
</header>
209-
<nav className="flex-1 pt-2">
210-
<MenuWallets />
211-
{isWalletPath && <MenuWallet />}
212-
</nav>
213-
<div className="mt-auto p-4" />
214-
</div>
215-
</aside>
216-
)}
217-
218-
{/* Main content area */}
219-
<div className="flex h-screen flex-col">
220-
<header
221-
className="pointer-events-auto relative z-10 border-b border-gray-200/30 bg-muted/40 px-4 dark:border-white/[0.03] lg:px-6"
222-
data-header="main"
223-
>
172+
{/* Header - full width, always on top */}
173+
<header
174+
className="pointer-events-auto relative z-[100] border-b border-gray-300/50 bg-muted/40 pl-2 pr-4 dark:border-white/[0.03] lg:pl-4 lg:pr-6"
175+
data-header="main"
176+
>
224177
<div className="flex h-14 items-center gap-4 lg:h-16">
225-
{/* Mobile menu button - only when logged in */}
226-
{isLoggedIn && <MobileNavigation isWalletPath={isWalletPath} />}
178+
{/* Mobile menu button - only in wallet context */}
179+
{isWalletPath && <MobileNavigation isWalletPath={isWalletPath} />}
227180

228-
{/* Logo in header - left on landing page (all sizes), centered on mobile when logged in */}
229-
<div className={`flex flex-1 ${!isLoggedIn ? 'justify-start' : 'justify-center md:hidden'}`}>
181+
{/* Logo - in fixed-width container matching sidebar width */}
182+
<div className={`flex items-center md:w-[260px] lg:w-[280px] ${isWalletPath ? 'flex-1 justify-center md:flex-none md:justify-start' : ''}`}>
230183
<Link
231184
href="/"
232-
className="flex items-center gap-2 rounded-md px-2 py-1 transition-colors hover:bg-gray-100/50 dark:hover:bg-gray-800/50"
185+
className="flex items-center gap-2 rounded-md px-4 py-2 text-sm transition-all duration-200 hover:bg-gray-100/50 dark:hover:bg-white/5 md:px-4"
233186
>
234-
<svg
235-
className="h-7 w-7 flex-shrink-0 text-foreground"
236-
enableBackground="new 0 0 300 200"
237-
viewBox="0 0 300 200"
238-
xmlns="http://www.w3.org/2000/svg"
239-
fill="currentColor"
240-
>
241-
<path d="m289 127-45-60-45-60c-.9-1.3-2.4-2-4-2s-3.1.7-4 2l-37 49.3c-2 2.7-6 2.7-8 0l-37-49.3c-.9-1.3-2.4-2-4-2s-3.1.7-4 2l-45 60-45 60c-1.3 1.8-1.3 4.2 0 6l45 60c.9 1.3 2.4 2 4 2s3.1-.7 4-2l37-49.3c2-2.7 6-2.7 8 0l37 49.3c.9 1.3 2.4 2 4 2s3.1-.7 4-2l37-49.3c2-2.7 6-2.7 8 0l37 49.3c.9 1.3 2.4 2 4 2s3.1-.7 4-2l45-60c1.3-1.8 1.3-4.2 0-6zm-90-103.3 32.5 43.3c1.3 1.8 1.3 4.2 0 6l-32.5 43.3c-2 2.7-6 2.7-8 0l-32.5-43.3c-1.3-1.8-1.3-4.2 0-6l32.5-43.3c2-2.7 6-2.7 8 0zm-90 0 32.5 43.3c1.3 1.8 1.3 4.2 0 6l-32.5 43.3c-2 2.7-6 2.7-8 0l-32.5-43.3c-1.3-1.8-1.3-4.2 0-6l32.5-43.3c2-2.7 6-2.7 8 0zm-53 152.6-32.5-43.3c-1.3-1.8-1.3-4.2 0-6l32.5-43.3c2-2.7 6-2.7 8 0l32.5 43.3c1.3 1.8 1.3 4.2 0 6l-32.5 43.3c-2 2.7-6 2.7-8 0zm90 0-32.5-43.3c-1.3-1.8-1.3-4.2 0-6l32.5-43.3c2-2.7 6-2.7 8 0l32.5 43.3c1.3 1.8 1.3 4.2 0 6l-32.5 43.3c-2 2.7-6 2.7-8 0zm90 0-32.5-43.3c-1.3-1.8-1.3-4.2 0-6l32.5-43.3c2-2.7 6-2.7 8 0l32.5 43.3c1.3 1.8 1.3 4.2 0 6l-32.5 43.3c-2 2.7-6 2.7-8 0z" />
242-
</svg>
243-
<span className="whitespace-nowrap text-base font-medium text-foreground">
244-
Multi-Sig Platform
187+
<Logo />
188+
<span className="select-none font-medium tracking-[-0.01em]" style={{ fontSize: '17px' }}>
189+
Multisig Platform
245190
</span>
246191
</Link>
247192
</div>
248193

249-
{/* Wallet selection + breadcrumb row on desktop */}
250-
{isLoggedIn && (
251-
<div className="hidden md:block">
252-
<div className="mx-1 w-full py-2">
253-
<nav className="flex items-center">
254-
<WalletDropDown />
255-
256-
{/* Right: Breadcrumb */}
257-
<div className="flex-shrink-0">
258-
{isWalletPath && appWallet ? (
259-
<Breadcrumb>
260-
<BreadcrumbList>
261-
{walletPageNames.map((name, index) => (
262-
<React.Fragment key={index}>
263-
<BreadcrumbSeparator />
264-
<BreadcrumbItem>
265-
<BreadcrumbLink asChild>
266-
<Link
267-
href={`/wallets/${appWallet.id}/${walletPageNames
268-
.slice(0, index + 1)
269-
.join("/")}`}
270-
>
271-
{name.toUpperCase()}
272-
</Link>
273-
</BreadcrumbLink>
274-
</BreadcrumbItem>
275-
</React.Fragment>
276-
))}
277-
</BreadcrumbList>
278-
</Breadcrumb>
279-
) : (
280-
<div className="w-40" /> /* Placeholder to keep right side spacing */
281-
)}
282-
</div>
283-
</nav>
284-
</div>
285-
</div>
286-
)}
287-
288194
{/* Right: Control buttons */}
289-
<div className="ml-auto flex items-center space-x-2">
195+
<div className="ml-auto flex items-center gap-2">
290196
{!connected ? (
291197
<ConnectWallet />
292198
) : (
@@ -309,17 +215,31 @@ export default function RootLayout({
309215
)}
310216
</div>
311217
</div>
312-
</header>
218+
</header>
313219

220+
{/* Content area with sidebar + main */}
221+
<div className={`flex flex-1 overflow-hidden ${isWalletPath ? '' : ''}`}>
222+
{/* Sidebar for larger screens - only in wallet context */}
223+
{isWalletPath && (
224+
<aside className="hidden w-[260px] border-r border-gray-300/50 bg-muted/40 dark:border-white/[0.03] md:block lg:w-[280px]">
225+
<div className="flex h-full max-h-screen flex-col">
226+
<nav className="flex-1 pt-2">
227+
<MenuWallet />
228+
</nav>
229+
<div className="mt-auto p-4" />
230+
</div>
231+
</aside>
232+
)}
314233

234+
{/* Main content */}
315235
<main className="relative flex flex-1 flex-col gap-4 overflow-y-auto overflow-x-hidden p-4 md:p-8">
316-
<WalletErrorBoundary
236+
<WalletErrorBoundary
317237
fallback={
318238
<div className="flex flex-col items-center justify-center h-full">
319239
<h2 className="text-xl font-semibold mb-2">Something went wrong</h2>
320240
<p className="text-gray-600 mb-4">Please try refreshing the page or reconnecting your wallet.</p>
321-
<button
322-
onClick={() => window.location.reload()}
241+
<button
242+
onClick={() => window.location.reload()}
323243
className="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600"
324244
>
325245
Refresh Page

src/components/common/overall-layout/logo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export default function Logo() {
22
return (
33
<svg
4-
className="h-10 w-10"
4+
className="h-9 w-9"
55
enableBackground="new 0 0 300 200"
66
viewBox="0 0 300 200"
77
xmlns="http://www.w3.org/2000/svg"

src/components/common/overall-layout/menus/menu-link.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default function MenuLink({
1212
return (
1313
<Link
1414
href={href}
15-
className={`flex items-center gap-3 rounded-md px-3 py-2 text-muted-foreground transition-all duration-200 hover:bg-gray-100/50 dark:hover:bg-white/5 hover:text-foreground ${className && className === "text-white" ? "!bg-gray-900 dark:!bg-white/10 !text-white dark:!text-white !font-medium" : className}`}
15+
className={`flex items-center gap-3 rounded-md px-3 py-2 text-sm text-muted-foreground transition-all duration-200 hover:bg-gray-100/50 dark:hover:bg-white/5 hover:text-foreground ${className && className === "text-white" ? "!bg-gray-900 dark:!bg-white/10 !text-white dark:!text-white !font-medium" : className}`}
1616
>
1717
{children}
1818
</Link>

0 commit comments

Comments
 (0)