File size: 2,636 Bytes
d30af0c
 
 
 
 
 
 
 
 
 
 
 
 
 
6544822
d30af0c
 
 
 
6544822
d30af0c
 
 
 
 
 
 
 
 
 
 
 
6544822
d30af0c
 
 
 
6544822
d30af0c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6544822
d30af0c
 
 
 
6544822
d30af0c
 
 
 
 
 
 
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
import { X } from 'lucide-react'
import { t } from '../lib/i18n'
import type { InferenceMode, Lang } from '../lib/types'
import { SettingsPanel } from './SettingsPanel'

interface Props {
  lang: Lang
  open: boolean
  onClose: () => void
  groupCount: number | 'auto'
  inferenceMode: InferenceMode
  serverAvailable: boolean
  useTiling: boolean
  filterOutliers: boolean
  showConfidenceLabels: boolean
  onGroupCount: (value: number | 'auto') => void
  onInferenceMode: (mode: InferenceMode) => void
  onUseTiling: (value: boolean) => void
  onFilterOutliers: (value: boolean) => void
  onShowConfidenceLabels: (value: boolean) => void
  onRecluster: () => void
}

export function SettingsDrawer({
  lang,
  open,
  onClose,
  groupCount,
  inferenceMode,
  serverAvailable,
  useTiling,
  filterOutliers,
  showConfidenceLabels,
  onGroupCount,
  onInferenceMode,
  onUseTiling,
  onFilterOutliers,
  onShowConfidenceLabels,
  onRecluster,
}: Props) {
  if (!open) return null

  return (
    <>
      <button
        type="button"
        className="overlay-enter fixed inset-0 z-[60] bg-black/35 backdrop-blur-[2px]"
        aria-label={t(lang, 'cancel')}
        onClick={onClose}
      />

      <aside
        className="drawer-enter fixed inset-y-0 right-0 z-[70] flex w-[min(100%,20rem)] flex-col bg-[var(--surface)] shadow-2xl ring-1 ring-[var(--hairline)]"
        style={{ paddingTop: 'env(safe-area-inset-top)', paddingBottom: 'env(safe-area-inset-bottom)' }}
      >
        <div className="flex shrink-0 items-center justify-between border-b border-[var(--hairline)] px-4 py-3">
          <h2 className="text-[17px] font-bold text-[var(--text)]">{t(lang, 'settings')}</h2>
          <button
            type="button"
            className="ct-btn-ghost h-9 w-9"
            onClick={onClose}
            aria-label={t(lang, 'cancel')}
          >
            <X size={18} />
          </button>
        </div>

        <div className="native-scroll flex-1 overflow-y-auto px-4 py-4">
          <SettingsPanel
            lang={lang}
            groupCount={groupCount}
            inferenceMode={inferenceMode}
            serverAvailable={serverAvailable}
            useTiling={useTiling}
            filterOutliers={filterOutliers}
            showConfidenceLabels={showConfidenceLabels}
            onGroupCount={onGroupCount}
            onInferenceMode={onInferenceMode}
            onUseTiling={onUseTiling}
            onFilterOutliers={onFilterOutliers}
            onShowConfidenceLabels={onShowConfidenceLabels}
            onRecluster={onRecluster}
          />
        </div>
      </aside>
    </>
  )
}