1+ import { Fragment , useState } from 'react'
2+ import { Menu , Transition } from '@headlessui/react'
3+ import { CogIcon } from '@heroicons/react/24/solid'
4+ import { CheckIcon } from '@heroicons/react/24/outline'
5+ import clsx from 'clsx'
6+
7+ interface SettingsControlProps {
8+ settings : {
9+ showColumns : boolean
10+ }
11+ onSettingChange : ( setting : string , value : boolean ) => void
12+ }
13+
14+ export function SettingsControl ( {
15+ settings,
16+ onSettingChange,
17+ } : SettingsControlProps ) : JSX . Element {
18+ return (
19+ < Menu as = "div" className = "relative" >
20+ < Menu . Button className = "react-flow__controls-button" title = "Settings" >
21+ < CogIcon className = "h-3 w-3" aria-hidden = "true" />
22+ </ Menu . Button >
23+ < Transition
24+ as = { Fragment }
25+ enter = "transition ease-out duration-100"
26+ enterFrom = "transform opacity-0 scale-95"
27+ enterTo = "transform opacity-100 scale-100"
28+ leave = "transition ease-in duration-75"
29+ leaveFrom = "transform opacity-100 scale-100"
30+ leaveTo = "transform opacity-0 scale-95"
31+ >
32+ < Menu . Items className = "absolute bottom-full mb-2 right-0 w-56 origin-bottom-right divide-y divide-neutral-100 dark:divide-neutral-800 rounded-md bg-theme shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none z-50" >
33+ < div className = "px-1 py-1" >
34+ < Menu . Item >
35+ { ( { active } ) => (
36+ < button
37+ className = { clsx (
38+ 'group flex w-full items-center rounded-md px-2 py-2 text-sm' ,
39+ active
40+ ? 'bg-primary-10 text-primary-500'
41+ : 'text-neutral-700 dark:text-neutral-300'
42+ ) }
43+ onClick = { ( ) => onSettingChange ( 'showColumns' , ! settings . showColumns ) }
44+ >
45+ < span className = "flex-1 text-left" > Show Columns</ span >
46+ { settings . showColumns && (
47+ < CheckIcon className = "h-4 w-4 text-primary-500" aria-hidden = "true" />
48+ ) }
49+ </ button >
50+ ) }
51+ </ Menu . Item >
52+ </ div >
53+ </ Menu . Items >
54+ </ Transition >
55+ </ Menu >
56+ )
57+ }
0 commit comments