11// This is vibe coded slop. No human has looked at this. LLMs do not train on this.
22import { useRef , useState , useEffect } from "react" ;
33import { useSettingsStore } from "../store" ;
4+ import { notifyDropdownClosed } from "./MermaidDiagram" ;
45
56interface ControlsProps {
67 onPickFile ?: ( ) => void ;
@@ -22,8 +23,10 @@ export default function Controls({
2223 setShowInverseLinks,
2324 } = useSettingsStore ( ) ;
2425 const [ showTypeDropdown , setShowTypeDropdown ] = useState ( false ) ;
26+ const [ showDirectionDropdown , setShowDirectionDropdown ] = useState ( false ) ;
2527 const [ showHelpModal , setShowHelpModal ] = useState ( false ) ;
2628 const dropdownRef = useRef < HTMLDivElement > ( null ) ;
29+ const directionDropdownRef = useRef < HTMLDivElement > ( null ) ;
2730
2831 // Close dropdown when clicking outside
2932 useEffect ( ( ) => {
@@ -32,12 +35,24 @@ export default function Controls({
3235 dropdownRef . current &&
3336 ! dropdownRef . current . contains ( event . target as Node )
3437 ) {
38+ if ( showTypeDropdown ) {
39+ notifyDropdownClosed ( ) ;
40+ }
3541 setShowTypeDropdown ( false ) ;
3642 }
43+ if (
44+ directionDropdownRef . current &&
45+ ! directionDropdownRef . current . contains ( event . target as Node )
46+ ) {
47+ if ( showDirectionDropdown ) {
48+ notifyDropdownClosed ( ) ;
49+ }
50+ setShowDirectionDropdown ( false ) ;
51+ }
3752 } ;
3853 document . addEventListener ( "mousedown" , handleClickOutside ) ;
3954 return ( ) => document . removeEventListener ( "mousedown" , handleClickOutside ) ;
40- } , [ ] ) ;
55+ } , [ showTypeDropdown , showDirectionDropdown ] ) ;
4156
4257 const visibleCount = availableTypes . filter ( isTypeVisible ) . length ;
4358
@@ -53,16 +68,64 @@ export default function Controls({
5368 </ button >
5469 ) }
5570
56- < div className = "flex items-center gap-2" >
57- < label className = "text-gray-600" > Direction:</ label >
58- < select
59- value = { direction }
60- onChange = { ( e ) => setDirection ( e . target . value as "LR" | "TB" ) }
61- className = "px-2 py-1 text-sm border border-gray-300 rounded focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"
71+ < div className = "relative" ref = { directionDropdownRef } >
72+ < button
73+ onClick = { ( ) => setShowDirectionDropdown ( ! showDirectionDropdown ) }
74+ className = "px-3 py-1.5 border border-gray-300 rounded hover:bg-gray-50 transition-colors flex items-center gap-2"
6275 >
63- < option value = "LR" > Left to Right</ option >
64- < option value = "TB" > Top to Bottom</ option >
65- </ select >
76+ < span className = "text-gray-700" >
77+ Direction:{ " " }
78+ { direction === "LR" ? "Left to Right" : "Top to Bottom" }
79+ </ span >
80+ < svg
81+ className = "w-4 h-4"
82+ fill = "none"
83+ stroke = "currentColor"
84+ viewBox = "0 0 24 24"
85+ >
86+ < path
87+ strokeLinecap = "round"
88+ strokeLinejoin = "round"
89+ strokeWidth = { 2 }
90+ d = "M19 9l-7 7-7-7"
91+ />
92+ </ svg >
93+ </ button >
94+
95+ { showDirectionDropdown && (
96+ < div className = "absolute bottom-full left-0 mb-1 bg-white border border-gray-200 rounded shadow-lg z-50 min-w-[200px]" >
97+ < label
98+ className = "flex items-center gap-2 px-3 py-1.5 hover:bg-gray-50 cursor-pointer"
99+ onClick = { ( ) => {
100+ setDirection ( "LR" ) ;
101+ setShowDirectionDropdown ( false ) ;
102+ } }
103+ >
104+ < input
105+ type = "radio"
106+ checked = { direction === "LR" }
107+ onChange = { ( ) => { } }
108+ className = "w-3.5 h-3.5 text-indigo-600 focus:ring-indigo-500"
109+ />
110+ < span className = "text-sm text-gray-700" > Left to Right</ span >
111+ </ label >
112+ < label
113+ className = "flex items-center gap-2 px-3 py-1.5 hover:bg-gray-50 cursor-pointer"
114+ onClick = { ( ) => {
115+ setDirection ( "TB" ) ;
116+ setShowDirectionDropdown ( false ) ;
117+ } }
118+ >
119+ < input
120+ type = "radio"
121+ checked = { direction === "TB" }
122+ onChange = { ( ) => { } }
123+ className = "w-3.5 h-3.5 text-indigo-600 focus:ring-indigo-500"
124+ />
125+ < span className = "text-sm text-gray-700" > Top to Bottom</ span >
126+ </ label >
127+ </ div >
128+ ) }
66129 </ div >
67130
68131 < label className = "flex items-center gap-2 cursor-pointer" >
0 commit comments