Download web/src/components/shell/TopBar.tsx from EnergyVenom/patchwise-agent-studio: direct link, hf CLI and curl.
- Browser
- Download file 3.45 kB
-
https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/web/src/components/shell/TopBar.tsx
- Command line
-
hf download hf://spaces/EnergyVenom/patchwise-agent-studio/web/src/components/shell/TopBar.tsx
-
curl -L -o TopBar.tsx https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/web/src/components/shell/TopBar.tsx
3.45 kB
| import { Button } from '@mantine/core'; | |
| import { IconChevronLeft, IconMenu2, IconSearch, IconSparkles } from '@/components/icons'; | |
| import type { ReactNode } from 'react'; | |
| import { Link } from 'react-router-dom'; | |
| import { NotificationBell } from '../../notify/NotificationBell'; | |
| import { EnvBadge, envKind, useChosenEnv } from './EnvSwitcher'; | |
| import { useShell } from './prefs'; | |
| export const isMac = () => typeof navigator !== 'undefined' && /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent); | |
| /** The toolbar of every page: sidebar toggle, back link, title and one-line caption on the left; a state chip, the page's | |
| * actions and the search field (it opens the command palette, Ctrl K) on the right. Translucent, content scrolls under it. | |
| * When the sidebar is folded to its icons, the practice-environment cue is repeated here so it never disappears. */ | |
| export function TopBar({ title, sub, middle, actions, titleTestId, honesty = true, back, plainTitle = false }: { | |
| title: ReactNode; sub?: ReactNode; middle?: ReactNode; actions?: ReactNode; titleTestId?: string; honesty?: boolean; back?: { label: string; to: string }; | |
| /** The page has its own large heading: the toolbar shows the title as plain text, not a second heading. */ | |
| plainTitle?: boolean; | |
| }) { | |
| const { size, sidebarExpanded, openNav, openPalette } = useShell(); | |
| const { pod } = useChosenEnv(); | |
| const drawer = size === 'tablet' || size === 'phone'; | |
| const cue = honesty && drawer && !sidebarExpanded && pod && envKind(pod.kind) === 'mock' | |
| ? <span className="fpt-topbar-cue"><EnvBadge kind="mock" /></span> : null; | |
| const phone = size === 'phone'; | |
| return ( | |
| <header className="fpt-topbar pw-topbar" data-size={size}> | |
| {drawer | |
| ? <button type="button" className="fpt-iconbtn fpt-topbar-menu" aria-label="Open the menu" onClick={openNav}><IconMenu2 size={17} /></button> | |
| : null} | |
| {back && <Link to={back.to} className="fpt-back" aria-label={`Back to ${back.label}`}><IconChevronLeft size={16} stroke={2} aria-hidden />{back.label}</Link>} | |
| <div className="fpt-topbar-left"> | |
| <div className="fpt-topbar-row1"> | |
| {plainTitle ? <div className="fpt-title" data-testid={titleTestId}>{title}</div> : <h1 className="fpt-title" data-testid={titleTestId}>{title}</h1>} | |
| {middle && <div className="fpt-topbar-mid">{middle}</div>} | |
| </div> | |
| {(sub || cue) && <div className="fpt-topbar-sub">{sub}{sub && cue ? <span aria-hidden className="fpt-topbar-dotsep">·</span> : null}{cue}</div>} | |
| </div> | |
| <div className="fpt-topbar-actions"> | |
| {actions} | |
| {/* wide screens: notifications, search and Ask live in the top navigation */} | |
| {drawer && <NotificationBell />} | |
| {drawer && !phone && ( | |
| <Button component={Link} to="/assistant" variant="default" size="xs" className="pw-askai" aria-label="Ask AI" title="Ask AI" leftSection={<IconSparkles size={14} aria-hidden />}>Ask AI</Button> | |
| )} | |
| {drawer && ( | |
| <button type="button" className="fpt-search" onClick={openPalette} aria-label={`Search or ask ${isMac() ? '⌘K' : 'Ctrl K'}`} title="Search, go to a page or ask a question"> | |
| <IconSearch size={16} stroke={1.8} aria-hidden /><span>Search or ask</span>{' '}<kbd>{isMac() ? '⌘K' : 'Ctrl K'}</kbd> | |
| </button> | |
| )} | |
| </div> | |
| </header> | |
| ); | |
| } | |