-
Notifications
You must be signed in to change notification settings - Fork 0
feat(ui): desktop page navigation + New Chat fix #315
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import { useLocation, useNavigate } from 'react-router-dom'; | ||
| import { useTabBadges } from '../hooks/useTabBadges'; | ||
|
|
||
| interface NavItem { | ||
| label: string; | ||
| path: string; | ||
| match: (pathname: string) => boolean; | ||
| badge?: number; | ||
| } | ||
|
|
||
| export function DesktopNav() { | ||
| const location = useLocation(); | ||
| const navigate = useNavigate(); | ||
| const { inboxCount, todoCount } = useTabBadges(); | ||
|
|
||
| const items: NavItem[] = [ | ||
| { | ||
| label: 'Chat', | ||
| path: '/', | ||
| match: (p) => p === '/' || p === '/chat' || p.startsWith('/chat/'), | ||
| }, | ||
| { label: 'Calendar', path: '/calendar', match: (p) => p.startsWith('/calendar') }, | ||
| { label: 'Inbox', path: '/inbox', match: (p) => p === '/inbox', badge: inboxCount }, | ||
| { | ||
| label: 'Telos', | ||
| path: '/todos', | ||
| match: (p) => p === '/todos' || p.startsWith('/todos/'), | ||
| badge: todoCount, | ||
| }, | ||
| { label: 'Tasks', path: '/tasks', match: (p) => p.startsWith('/tasks') }, | ||
| { label: 'Files', path: '/files', match: (p) => p.startsWith('/files') }, | ||
| ]; | ||
|
|
||
| return ( | ||
| <nav className="desktop-nav"> | ||
| {items.map((item) => ( | ||
| <button | ||
| key={item.label} | ||
| className={`desktop-nav-item${item.match(location.pathname) ? ' desktop-nav-item--active' : ''}`} | ||
| onClick={() => navigate(item.path)} | ||
| > | ||
| <span>{item.label}</span> | ||
| {item.badge ? <span className="desktop-nav-badge">{item.badge}</span> : null} | ||
| </button> | ||
| ))} | ||
| </nav> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,10 @@ | ||
| import { useState, useCallback, type ReactNode } from 'react'; | ||
| import { DesktopNav } from './DesktopNav'; | ||
|
|
||
| export interface DesktopShellProps { | ||
| left: ReactNode; | ||
| left?: ReactNode; | ||
| center: ReactNode; | ||
| right: ReactNode; | ||
| right?: ReactNode; | ||
| statusBar?: ReactNode; | ||
| } | ||
|
|
||
|
|
@@ -55,25 +56,32 @@ export function DesktopShell({ left, center, right, statusBar }: DesktopShellPro | |
| <button | ||
| className="desktop-collapse-btn" | ||
| onClick={toggleLeft} | ||
| title={leftCollapsed ? 'Show sessions' : 'Hide sessions'} | ||
| title={leftCollapsed ? 'Show sidebar' : 'Hide sidebar'} | ||
| > | ||
| {leftCollapsed ? '\u25B6' : '\u25C0'} | ||
| </button> | ||
| {!leftCollapsed && left} | ||
| {!leftCollapsed && ( | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 bugs: When |
||
| <> | ||
| <DesktopNav /> | ||
| {left} | ||
| </> | ||
| )} | ||
| </div> | ||
| <div className="desktop-center">{center}</div> | ||
| <div | ||
| className={`desktop-sidebar-right${rightCollapsed ? ' desktop-sidebar--collapsed' : ''}`} | ||
| > | ||
| <button | ||
| className="desktop-collapse-btn" | ||
| onClick={toggleRight} | ||
| title={rightCollapsed ? 'Show context' : 'Hide context'} | ||
| {right && ( | ||
| <div | ||
| className={`desktop-sidebar-right${rightCollapsed ? ' desktop-sidebar--collapsed' : ''}`} | ||
| > | ||
| {rightCollapsed ? '\u25C0' : '\u25B6'} | ||
| </button> | ||
| {!rightCollapsed && right} | ||
| </div> | ||
| <button | ||
| className="desktop-collapse-btn" | ||
| onClick={toggleRight} | ||
| title={rightCollapsed ? 'Show context' : 'Hide context'} | ||
| > | ||
| {rightCollapsed ? '\u25C0' : '\u25B6'} | ||
| </button> | ||
| {!rightCollapsed && right} | ||
| </div> | ||
| )} | ||
| </div> | ||
| {statusBar && <div className="desktop-status-row">{statusBar}</div>} | ||
| </div> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔵 style: The
itemsarray (with its closures) is re-allocated on every render. For 6 items this is negligible, but wrapping it inuseMemo(() => [...], [inboxCount, todoCount])would make dependencies explicit and avoid the allocation when onlylocationchanges.[fixable]