'use client' import { Icon as IconifyIcon } from '@iconify/react' import { useEditor, useSidebarStore, type ViewMode } from '@pascal-app/editor' import { useViewer } from '@pascal-app/viewer' import { ChevronsLeft, ChevronsRight, Columns2, Eye, EyeOff, Footprints, Grid2X2, Moon, Sun, } from 'lucide-react' import Image from 'next/image' import { type ReactNode, useCallback } from 'react' import { cn } from '@/lib/utils' import { Tooltip, TooltipContent, TooltipTrigger } from './toolbar-tooltip' const TOOLBAR_CONTAINER = 'inline-flex h-8 items-stretch overflow-hidden rounded-xl border border-border bg-background/90 shadow-2xl backdrop-blur-md' const TOOLBAR_BTN = 'flex w-8 items-center justify-center text-muted-foreground/80 transition-colors hover:bg-white/8 hover:text-foreground/90' function ToolbarTooltip({ children, label }: { children: ReactNode; label: string }) { return ( {children} {label} ) } const VIEW_MODES: { id: ViewMode; label: string; icon: React.ReactNode }[] = [ { id: '3d', label: '3D', icon: ( ), }, { id: '2d', label: '2D', icon: ( ), }, { id: 'split', label: 'Split', icon: , }, ] const levelModeOrder = ['stacked', 'exploded', 'solo'] as const const levelModeLabels: Record = { manual: 'Stack', stacked: 'Stack', exploded: 'Exploded', solo: 'Solo', } const wallModeOrder = ['cutaway', 'up', 'down'] as const const wallModeConfig: Record = { up: { icon: '/icons/room.png', label: 'Full height' }, cutaway: { icon: '/icons/wallcut.png', label: 'Cutaway' }, down: { icon: '/icons/walllow.png', label: 'Low' }, } function ViewModeControl() { const viewMode = useEditor((state) => state.viewMode) const setViewMode = useEditor((state) => state.setViewMode) return (
{VIEW_MODES.map((mode) => { const isActive = viewMode === mode.id return ( ) })}
) } function CollapseSidebarButton() { const isCollapsed = useSidebarStore((state) => state.isCollapsed) const setIsCollapsed = useSidebarStore((state) => state.setIsCollapsed) const toggle = useCallback(() => { setIsCollapsed(!isCollapsed) }, [isCollapsed, setIsCollapsed]) return (
) } function LevelModeToggle() { const levelMode = useViewer((state) => state.levelMode) const setLevelMode = useViewer((state) => state.setLevelMode) const isDefault = levelMode === 'stacked' || levelMode === 'manual' const cycle = () => { if (levelMode === 'manual') { setLevelMode('stacked') return } const index = levelModeOrder.indexOf(levelMode as (typeof levelModeOrder)[number]) const next = levelModeOrder[(index + 1) % levelModeOrder.length] if (next) setLevelMode(next) } const label = `Levels: ${levelMode === 'manual' ? 'Manual' : (levelModeLabels[levelMode] ?? 'Stack')}` return ( ) } function WallModeToggle() { const wallMode = useViewer((state) => state.wallMode) const setWallMode = useViewer((state) => state.setWallMode) const config = wallModeConfig[wallMode] ?? wallModeConfig.cutaway! const cycle = () => { const index = wallModeOrder.indexOf(wallMode as (typeof wallModeOrder)[number]) const next = wallModeOrder[(index + 1) % wallModeOrder.length] if (next) setWallMode(next) } return ( ) } function GridVisibilityToggle() { const showGrid = useViewer((state) => state.showGrid) const setShowGrid = useViewer((state) => state.setShowGrid) return ( ) } function UnitToggle() { const unit = useViewer((state) => state.unit) const setUnit = useViewer((state) => state.setUnit) return ( ) } function ThemeToggle() { const theme = useViewer((state) => state.theme) const setTheme = useViewer((state) => state.setTheme) return ( ) } function CameraModeToggle() { const cameraMode = useViewer((state) => state.cameraMode) const setCameraMode = useViewer((state) => state.setCameraMode) return ( ) } function WalkthroughButton() { const isFirstPersonMode = useEditor((state) => state.isFirstPersonMode) const setFirstPersonMode = useEditor((state) => state.setFirstPersonMode) return ( ) } function PreviewButton() { return ( ) } export function CommunityViewerToolbarLeft() { return ( <> ) } export function CommunityViewerToolbarRight() { return (
) }