()
| 30 | } |
| 31 | |
| 32 | export function Shell() { |
| 33 | const styles = useStyles() |
| 34 | const state = useHotkeysDevtoolsState() |
| 35 | const [selectedId, setSelectedId] = createSignal<string | null>(null) |
| 36 | const [leftPanelWidth, setLeftPanelWidth] = createSignal(300) |
| 37 | const [isDragging, setIsDragging] = createSignal(false) |
| 38 | const [shellRootEl, setShellRootEl] = createSignal<HTMLElement | null>(null) |
| 39 | const [slotHeightPx, setSlotHeightPx] = createSignal<number | undefined>( |
| 40 | undefined, |
| 41 | ) |
| 42 | |
| 43 | const selectedRegistration = createMemo(() => { |
| 44 | const id = selectedId() |
| 45 | if (!id) return null |
| 46 | const hotkey = state.registrations().find((r) => r.id === id) |
| 47 | if (hotkey) return hotkey |
| 48 | const sequence = state.sequenceRegistrations().find((r) => r.id === id) |
| 49 | return sequence ?? null |
| 50 | }) |
| 51 | |
| 52 | let dragStartX = 0 |
| 53 | let dragStartWidth = 0 |
| 54 | |
| 55 | const handleMouseDown = (e: MouseEvent) => { |
| 56 | e.preventDefault() |
| 57 | e.stopPropagation() |
| 58 | setIsDragging(true) |
| 59 | document.body.style.cursor = 'col-resize' |
| 60 | document.body.style.userSelect = 'none' |
| 61 | dragStartX = e.clientX |
| 62 | dragStartWidth = leftPanelWidth() |
| 63 | } |
| 64 | |
| 65 | const handleMouseMove = (e: MouseEvent) => { |
| 66 | if (!isDragging()) return |
| 67 | |
| 68 | e.preventDefault() |
| 69 | const deltaX = e.clientX - dragStartX |
| 70 | const newWidth = Math.max(150, Math.min(800, dragStartWidth + deltaX)) |
| 71 | setLeftPanelWidth(newWidth) |
| 72 | } |
| 73 | |
| 74 | const handleMouseUp = () => { |
| 75 | setIsDragging(false) |
| 76 | document.body.style.cursor = '' |
| 77 | document.body.style.userSelect = '' |
| 78 | } |
| 79 | |
| 80 | onMount(() => { |
| 81 | document.addEventListener('mousemove', handleMouseMove) |
| 82 | document.addEventListener('mouseup', handleMouseUp) |
| 83 | }) |
| 84 | |
| 85 | onCleanup(() => { |
| 86 | document.removeEventListener('mousemove', handleMouseMove) |
| 87 | document.removeEventListener('mouseup', handleMouseUp) |
| 88 | }) |
| 89 |
nothing calls this directly
no test coverage detected
searching dependent graphs…