-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7d32a9f
commit 610ee7c
Showing
18 changed files
with
404 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,39 @@ | ||
'use client' | ||
|
||
import { ChartBarIcon, ClockIcon, DocumentTextIcon, GlobeAltIcon, HomeIcon, MagnifyingGlassIcon, ServerIcon } from "@heroicons/react/24/solid"; | ||
import { useEffect, useState } from 'react' | ||
import React, { useEffect } from 'react'; | ||
|
||
import Content from "./Content"; | ||
import Sidebar from "./Sidebar"; | ||
import Topbar from "./TopBar"; | ||
|
||
const navigation = [ | ||
{ name: 'Dashboard', href: '/', icon: HomeIcon, current: true }, | ||
{ name: 'Queries', href: '/queries', icon: MagnifyingGlassIcon, current: false }, | ||
{ name: 'Metrics', href: '/metrics', icon: ChartBarIcon, current: false }, | ||
{ name: 'Schedules', href: '/schedules', icon: ClockIcon, current: false }, | ||
{ name: 'Connections', href: '/connections', icon: ServerIcon, current: false }, | ||
{ name: 'Entities', href: '/entities', icon: GlobeAltIcon, current: false }, | ||
{ name: 'Definitions', href: '/definitions', icon: DocumentTextIcon, current: false }, | ||
]; | ||
|
||
export default function Example({ children }) { | ||
const [sidebarOpen, setSidebarOpen] = useState(false); | ||
const [sidebarCollapsed, setSidebarCollapsed] = useState(false); | ||
const [branding, setBranding] = useState({ | ||
name: 'Preswald', | ||
logo: '/assets/default-logo.png', | ||
favicon: '/assets/favicon.ico' | ||
}); | ||
import Content from './Content'; | ||
import Sidebar from './Sidebar'; | ||
import TopBar from './TopBar'; | ||
import { useAppState } from '../state/AppStateContext'; | ||
|
||
// Favicon component to handle dynamic favicon updates | ||
const Favicon = ({ href }) => { | ||
useEffect(() => { | ||
// Get branding from window object (set by server) | ||
if (window.PRESWALD_BRANDING) { | ||
setBranding(window.PRESWALD_BRANDING); | ||
// Update document title | ||
document.title = window.PRESWALD_BRANDING.name; | ||
const favicon = document.querySelector('link[rel="icon"]'); | ||
if (favicon && href) { | ||
favicon.href = href; | ||
} | ||
}, []); | ||
}, [href]); | ||
|
||
const toggleSidebar = () => { | ||
setSidebarCollapsed(!sidebarCollapsed); | ||
}; | ||
return null; | ||
}; | ||
|
||
const Layout = ({ children }) => { | ||
const { branding } = useAppState(); | ||
|
||
return ( | ||
<> | ||
<Sidebar | ||
sidebarOpen={sidebarOpen} | ||
setSidebarOpen={setSidebarOpen} | ||
navigation={navigation} | ||
branding={branding} | ||
isCollapsed={sidebarCollapsed} | ||
/> | ||
<div className={`transition-all duration-300 ${sidebarCollapsed ? 'lg:pl-20' : 'lg:pl-80'}`}> | ||
<Topbar | ||
setSidebarOpen={setSidebarOpen} | ||
branding={branding} | ||
onToggleSidebar={toggleSidebar} | ||
isCollapsed={sidebarCollapsed} | ||
/> | ||
<main> | ||
<Content>{children}</Content> | ||
<div className="flex h-screen bg-gray-100"> | ||
<Favicon href={branding.favicon} /> | ||
<Sidebar branding={branding} /> | ||
<div className="flex flex-col flex-1 overflow-hidden"> | ||
<TopBar branding={branding} /> | ||
<main className="flex-1 overflow-auto"> | ||
{children} | ||
</main> | ||
</div> | ||
</> | ||
</div> | ||
); | ||
} | ||
}; | ||
|
||
export default Layout; |
Oops, something went wrong.