(props)
| 409 | } |
| 410 | |
| 411 | const DraggablePanel: Component<DevtoolsPanelProps> = (props) => { |
| 412 | const theme = useTheme() |
| 413 | const css = useQueryDevtoolsContext().shadowDOMTarget |
| 414 | ? goober.css.bind({ target: useQueryDevtoolsContext().shadowDOMTarget }) |
| 415 | : goober.css |
| 416 | const styles = createMemo(() => { |
| 417 | return theme() === 'dark' ? darkStyles(css) : lightStyles(css) |
| 418 | }) |
| 419 | |
| 420 | const [isResizing, setIsResizing] = createSignal(false) |
| 421 | |
| 422 | const position = createMemo( |
| 423 | () => |
| 424 | (props.localStore.position || |
| 425 | useQueryDevtoolsContext().position || |
| 426 | POSITION) as DevtoolsPosition, |
| 427 | ) |
| 428 | |
| 429 | const handleDragStart: JSX.EventHandler<HTMLDivElement, MouseEvent> = ( |
| 430 | event, |
| 431 | ) => { |
| 432 | const panelElement = event.currentTarget.parentElement |
| 433 | if (!panelElement) return |
| 434 | setIsResizing(true) |
| 435 | const { height, width } = panelElement.getBoundingClientRect() |
| 436 | const startX = event.clientX |
| 437 | const startY = event.clientY |
| 438 | let newSize = 0 |
| 439 | const minHeight = convertRemToPixels(3.5) |
| 440 | const minWidth = convertRemToPixels(12) |
| 441 | const runDrag = (moveEvent: MouseEvent) => { |
| 442 | moveEvent.preventDefault() |
| 443 | |
| 444 | if (position() === 'left' || position() === 'right') { |
| 445 | const valToAdd = |
| 446 | position() === 'right' |
| 447 | ? startX - moveEvent.clientX |
| 448 | : moveEvent.clientX - startX |
| 449 | newSize = Math.round(width + valToAdd) |
| 450 | if (newSize < minWidth) { |
| 451 | newSize = minWidth |
| 452 | } |
| 453 | props.setLocalStore('width', String(Math.round(newSize))) |
| 454 | |
| 455 | const newWidth = panelElement.getBoundingClientRect().width |
| 456 | // If the panel size didn't decrease, this means we have reached the minimum width |
| 457 | // of the panel so we restore the original width in local storage |
| 458 | // Restoring the width helps in smooth open/close transitions |
| 459 | if (Number(props.localStore.width) < newWidth) { |
| 460 | props.setLocalStore('width', String(newWidth)) |
| 461 | } |
| 462 | } else { |
| 463 | const valToAdd = |
| 464 | position() === 'bottom' |
| 465 | ? startY - moveEvent.clientY |
| 466 | : moveEvent.clientY - startY |
| 467 | newSize = Math.round(height + valToAdd) |
| 468 | // If the panel size is less than the minimum height, |
nothing calls this directly
no test coverage detected
searching dependent graphs…