(props)
| 397 | } |
| 398 | |
| 399 | const DraggablePanel: Component<DevtoolsPanelProps> = (props) => { |
| 400 | const { setSelectedQueryHash, panelWidth, setPanelWidth } = useDevtoolsState() |
| 401 | |
| 402 | const theme = useTheme() |
| 403 | const themed = createThemed(theme) |
| 404 | |
| 405 | let closeBtnRef!: HTMLButtonElement |
| 406 | |
| 407 | // Focus the close button when the panel opens for screen reader accessibility |
| 408 | onMount(() => { |
| 409 | closeBtnRef.focus() |
| 410 | }) |
| 411 | |
| 412 | const [isResizing, setIsResizing] = createSignal(false) |
| 413 | |
| 414 | const position = createMemo( |
| 415 | () => |
| 416 | (props.localStore.position || |
| 417 | useQueryDevtoolsContext().position || |
| 418 | POSITION) as DevtoolsPosition, |
| 419 | ) |
| 420 | |
| 421 | const handleDragStart: JSX.EventHandler<HTMLDivElement, MouseEvent> = ( |
| 422 | event, |
| 423 | ) => { |
| 424 | const panelElement = event.currentTarget.parentElement |
| 425 | if (!panelElement) return |
| 426 | setIsResizing(true) |
| 427 | const { height, width } = panelElement.getBoundingClientRect() |
| 428 | const startX = event.clientX |
| 429 | const startY = event.clientY |
| 430 | let newSize = 0 |
| 431 | const minHeight = convertRemToPixels(3.5) |
| 432 | const minWidth = convertRemToPixels(12) |
| 433 | const runDrag = (moveEvent: MouseEvent) => { |
| 434 | moveEvent.preventDefault() |
| 435 | |
| 436 | if (position() === 'left' || position() === 'right') { |
| 437 | const valToAdd = |
| 438 | position() === 'right' |
| 439 | ? startX - moveEvent.clientX |
| 440 | : moveEvent.clientX - startX |
| 441 | newSize = Math.round(width + valToAdd) |
| 442 | if (newSize < minWidth) { |
| 443 | newSize = minWidth |
| 444 | } |
| 445 | props.setLocalStore('width', String(Math.round(newSize))) |
| 446 | |
| 447 | const newWidth = panelElement.getBoundingClientRect().width |
| 448 | // If the panel size didn't decrease, this means we have reached the minimum width |
| 449 | // of the panel so we restore the original width in local storage |
| 450 | // Restoring the width helps in smooth open/close transitions |
| 451 | if (Number(props.localStore.width) < newWidth) { |
| 452 | props.setLocalStore('width', String(newWidth)) |
| 453 | } |
| 454 | } else { |
| 455 | const valToAdd = |
| 456 | position() === 'bottom' |
nothing calls this directly
no test coverage detected