File size: 2,271 Bytes
40fe69e
 
 
 
 
445c3cc
 
 
 
d30af0c
445c3cc
d30af0c
 
 
 
 
40fe69e
 
 
 
 
 
 
 
 
 
 
d30af0c
445c3cc
d30af0c
445c3cc
d30af0c
445c3cc
 
 
 
 
 
 
 
d30af0c
 
445c3cc
 
 
 
d30af0c
445c3cc
 
 
 
 
 
40fe69e
 
 
 
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
import { Eye, Plus, SquareDashed, Tag, Trash2 } from 'lucide-react'
import { cn } from '../lib/utils'
import { t } from '../lib/i18n'
import type { Lang, ToolMode } from '../lib/types'

const TOOLS: {
  id: ToolMode
  icon: typeof Eye
  labelKey: 'toolView' | 'toolDelete' | 'toolAdd' | 'toolReassign' | 'toolArea'
  activeClass: string
}[] = [
  { id: 'view',     icon: Eye,          labelKey: 'toolView',     activeClass: 'bg-[var(--text)] text-white' },
  { id: 'delete',   icon: Trash2,       labelKey: 'toolDelete',   activeClass: 'bg-[var(--danger)] text-white' },
  { id: 'add',      icon: Plus,         labelKey: 'toolAdd',      activeClass: 'bg-[var(--success)] text-white' },
  { id: 'reassign', icon: Tag,          labelKey: 'toolReassign', activeClass: 'bg-[var(--info)] text-white' },
  { id: 'area',     icon: SquareDashed, labelKey: 'toolArea',     activeClass: 'bg-[#7c3aed] text-white' },
]

interface Props {
  lang: Lang
  tool: ToolMode
  onToolChange: (tool: ToolMode) => void
}

export function ToolBar({ lang, tool, onToolChange }: Props) {
  return (
    <section>
      <p className="ct-section-label mb-2 px-1">{t(lang, 'tools')}</p>

      <div className="ct-card overflow-hidden p-1.5">
        <div className="flex gap-1 overflow-x-auto [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
          {TOOLS.map(({ id, icon: Icon, labelKey, activeClass }) => {
            const active = tool === id
            return (
              <button
                key={id}
                type="button"
                className={cn(
                  'flex shrink-0 items-center gap-1.5 rounded-xl px-3.5 py-2 text-sm font-semibold transition-all duration-200 active:scale-[0.96]',
                  active
                    ? `${activeClass} shadow-sm`
                    : 'text-[var(--text-dim)] active:bg-[var(--surface-2)]',
                )}
                onClick={() => onToolChange(id)}
              >
                <Icon size={15} strokeWidth={active ? 2.5 : 2} />
                <span className={active ? 'opacity-100' : 'opacity-80'}>
                  {t(lang, labelKey)}
                </span>
              </button>
            )
          })}
        </div>
      </div>
    </section>
  )
}