agentsclimarketplace

Drawer resizable mouse drag

Skill kjuhwa/skills-hub/skills/design/drawer-resizable-mouse-drag

Make Ant Design Drawer resizable via mouse drag with styled-components handle, min/max width constraints, and transition suppression during dragFrom its SKILL.md

Install
npx -y skills add kjuhwa/skills-hub --skill drawer-resizable-mouse-drag

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

2.1 KB, 417 tokens by cl100k_base, as published. Nobody here has run it

Resizable Drawer with Mouse Drag

Steps

  1. Create resize handle with styled-components:

    const ResizableHandle = styled.div`
      position: absolute; left: 0; top: 0; bottom: 0;
      width: 4px; cursor: col-resize; z-index: 10;
      &:hover { background: var(--color-border-interactive); }
    `;
    
  2. Add mouse event listeners for drag:

    const onMouseDown = (e) => {
      e.preventDefault();
      const startX = e.clientX;
      const startWidth = currentWidth;
    
      // Suppress transition during drag
      const wrapper = document.querySelector('.ant-drawer-content-wrapper');
      if (wrapper) wrapper.style.transition = 'none';
    
      const onMouseMove = (moveE) => {
        const newWidth = Math.min(MAX_WIDTH, Math.max(MIN_WIDTH, startWidth + (startX - moveE.clientX)));
        setWidth(newWidth);
      };
    
      const onMouseUp = () => {
        if (wrapper) wrapper.style.transition = '';
        document.removeEventListener('mousemove', onMouseMove);
        document.removeEventListener('mouseup', onMouseUp);
      };
    
      document.addEventListener('mousemove', onMouseMove);
      document.addEventListener('mouseup', onMouseUp);
    };
    
  3. Define constraints:

    • MIN_WIDTH = 440 (minimum usable content width)
    • MAX_WIDTH = window.innerWidth - menuOffset (don't overlap sidebar)
  4. Apply width to Ant Drawer:

    <Drawer width={width} {...props}>
      <ResizableHandle onMouseDown={onMouseDown} />
      {children}
    </Drawer>
    

Key details

  • Setting transition: 'none' on .ant-drawer-content-wrapper during drag prevents jittery animation
  • Restore transition on mouseup for smooth open/close animation
  • menuOffset accounts for sidebar width in the host layout

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 625,605. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.