All files / src/components StatusBar.tsx

34.78% Statements 8/23
18.18% Branches 4/22
27.27% Functions 3/11
35.29% Lines 6/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160                                22x 22x   22x   22x 7x                   22x                                                                                                                                                                                                                                                              
import { useState, useRef, useEffect } from 'react'
import { Package, GitBranch, RefreshCw, Sparkles, FileText, Bell, Settings, FolderOpen, Check } from 'lucide-react'
 
export interface VaultOption {
  label: string
  path: string
}
 
interface StatusBarProps {
  noteCount: number
  vaultPath: string
  vaults: VaultOption[]
  onSwitchVault: (path: string) => void
}
 
export function StatusBar({ noteCount, vaultPath, vaults, onSwitchVault }: StatusBarProps) {
  const [showVaultMenu, setShowVaultMenu] = useState(false)
  const menuRef = useRef<HTMLDivElement>(null)
 
  const activeVault = vaults.find((v) => v.path === vaultPath)
 
  useEffect(() => {
    Eif (!showVaultMenu) return
    const handleClick = (e: MouseEvent) => {
      if (menuRef.current && !menuRef.current.contains(e.target as Node)) {
        setShowVaultMenu(false)
      }
    }
    document.addEventListener('mousedown', handleClick)
    return () => document.removeEventListener('mousedown', handleClick)
  }, [showVaultMenu])
 
  return (
    <footer
      style={{
        height: 30,
        flexShrink: 0,
        display: 'flex',
        alignItems: 'center',
        justifyContent: 'space-between',
        background: 'var(--sidebar)',
        borderTop: '1px solid var(--border)',
        padding: '0 8px',
        fontSize: 11,
        color: 'var(--muted-foreground)',
      }}
    >
      {/* Left section */}
      <div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
        <div ref={menuRef} style={{ position: 'relative' }}>
          <span
            role="button"
            onClick={() => setShowVaultMenu((v) => !v)}
            style={{
              display: 'flex',
              alignItems: 'center',
              gap: 4,
              cursor: 'pointer',
              padding: '2px 4px',
              borderRadius: 3,
              background: showVaultMenu ? 'var(--hover)' : 'transparent',
            }}
            title="Switch vault"
          >
            <FolderOpen size={13} />
            {activeVault?.label ?? 'Vault'}
          </span>
          {showVaultMenu && (
            <div
              style={{
                position: 'absolute',
                bottom: '100%',
                left: 0,
                marginBottom: 4,
                background: 'var(--sidebar)',
                border: '1px solid var(--border)',
                borderRadius: 6,
                padding: 4,
                minWidth: 160,
                boxShadow: '0 4px 12px rgba(0,0,0,0.3)',
                zIndex: 1000,
              }}
            >
              {vaults.map((v) => (
                <div
                  key={v.path}
                  role="button"
                  onClick={() => {
                    onSwitchVault(v.path)
                    setShowVaultMenu(false)
                  }}
                  style={{
                    display: 'flex',
                    alignItems: 'center',
                    gap: 6,
                    padding: '4px 8px',
                    borderRadius: 4,
                    cursor: 'pointer',
                    background: v.path === vaultPath ? 'var(--hover)' : 'transparent',
                    color: v.path === vaultPath ? 'var(--foreground)' : 'var(--muted-foreground)',
                    fontSize: 12,
                  }}
                  onMouseEnter={(e) => {
                    if (v.path !== vaultPath) e.currentTarget.style.background = 'var(--hover)'
                  }}
                  onMouseLeave={(e) => {
                    if (v.path !== vaultPath) e.currentTarget.style.background = 'transparent'
                  }}
                >
                  {v.path === vaultPath ? <Check size={12} /> : <span style={{ width: 12 }} />}
                  {v.label}
                </div>
              ))}
            </div>
          )}
        </div>
        <span style={{ color: 'var(--border)' }}>|</span>
        <span style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
          <Package size={13} />
          v0.4.2
        </span>
        <span style={{ color: 'var(--border)' }}>|</span>
        <span style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
          <GitBranch size={13} />
          main
        </span>
        <span style={{ color: 'var(--border)' }}>|</span>
        <span style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
          <RefreshCw size={13} style={{ color: 'var(--accent-green)' }} />
          Synced 2m ago
        </span>
      </div>
 
      {/* Right section */}
      <div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
        <span style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
          <Sparkles size={13} style={{ color: 'var(--accent-purple)' }} />
          Claude Sonnet 4
        </span>
        <span style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
          <FileText size={13} />
          {noteCount.toLocaleString()} notes
        </span>
        <span
          style={{ display: 'flex', alignItems: 'center', opacity: 0.4, cursor: 'not-allowed' }}
          title="Coming soon"
        >
          <Bell size={14} />
        </span>
        <span
          style={{ display: 'flex', alignItems: 'center', opacity: 0.4, cursor: 'not-allowed' }}
          title="Coming soon"
        >
          <Settings size={14} />
        </span>
      </div>
    </footer>
  )
}