Skip to content
TheChatArchiveThe Chat Archive
GLMglm-5.1-codeHugging Face Arena WebDev Preferences (2026)

Build a Mac-style dock with icon magnification on hover, draggable reordering, active…

  1. User

    Build a Mac-style dock with icon magnification on hover, draggable reordering, active indicators, bouncing launch animation, and folder stacks.

  2. GLM Assistant

    I'll build a fully-featured Mac-style dock with all the requested features. Let me start by examining the project structure, then create the implementation.

    Now let me create the CSS with all the custom animations:

    Now let me create the comprehensive Dock component with all features:

    Let me fix the unused variable errors in the Dock component:

    Now let me create the main App component with a macOS-style wallpaper and menu bar:

    Now let me build the project to verify everything compiles correctly:

    The build succeeds. Let me now improve the drag implementation to use pointer events for a much smoother and more reliable experience, and also enhance the overall polish:

    Let me fix the unused parameter:

    Now let me build the project to confirm everything works:

    Build succeeds! But I noticed a potential stale closure issue with the drag-and-drop reordering. Let me fix that by using a ref for the drag-over index to ensure the correct drop target is used:

    Now let me update the drag handler to use the refs for reliable values:

    Let me build again to verify the fix:

    The build succeeds. Let me add one important fix - preventing click events from firing after a drag operation:

    Now let me update the pointer up handler and click handler to use the ref:

    Now update the click handler to check the didDrag ref:

    Let me verify the build one final time:

    The build succeeds! Let me do a quick review of the final implementation to make sure everything is polished:

    The implementation is complete and builds successfully. Here's a summary of what was built:

    macOS Dock — Complete Feature Set

    🎯 Icon Magnification on Hover

    • Smooth cosine-based distance calculation from cursor to each icon's center
    • Icons scale up to 1.55× at the cursor, falling off to 1× at the edges of a 160px range
    • transform-origin: bottom center makes icons grow upward like real macOS
    • Adjacent icons are pushed apart via dynamic margins, replicating the dock expansion effect
    • Smooth 0.15s cubic-bezier transitions

    🔄 Draggable Reordering

    • Custom pointer-event-based drag (not HTML5 DnD) for maximum control
    • 5px movement threshold to distinguish clicks from drags
    • Floating drag preview follows the cursor with a subtle floating animation and glow
    • Drop target detection based on proximity to other icons — items shift apart to show insertion point
    • Stale closure protection via refs for reliable state access during drag
    • Click suppression after drag to prevent accidental bounces

    💡 Active Indicators

    • Small white dots below active apps with a gentle pulse animation
    • Dots scale proportionally with magnification
    • Active state toggles on click (Finder, Safari, Mail, Calendar, Terminal start active)

    🚀 Bouncing Launch Animation

    • Multi-stage decaying bounce keyframe: 30px → 18px → 10px → 5px → 2px
    • Uses cubic-bezier(0.28, 0.84, 0.42, 1) for natural elasticity
    • 1-second duration, triggered on app click
    • Bounce works alongside magnification via nested div wrappers

    📂 Folder Stacks

    • Downloads and Documents folders with 6 items each
    • Frosted glass popup with backdrop-blur(40px) appears above the folder icon
    • Grid layout with typed file icons (PDF, image, music, archive, text)
    • Triangle pointer connecting popup to folder icon
    • Pop-in animation with spring-like cubic-bezier easing
    • Click outside or on folder icon to dismiss
    • Clicking a folder item triggers a bounce on the folder

    ✨ Visual Polish

    • 14 custom SVG app icons (Finder, Safari, Messages, Mail, Music, Photos, Calendar, Notes, Terminal, Settings, App Store, Trash, + 2 folders)
    • macOS Sonoma-inspired wallpaper with layered radial gradients and subtle sparkle effects
    • Frosted glass dock with backdrop-blur(50px) and refined borders/shadows
    • macOS menu bar with Apple logo, app name, menu items, battery, WiFi, and live clock
    • Desktop icons with hover effects
    • Tooltips with frosted glass styling and fade-in animation

    Files built: index.html, src/index.css, src/components/Dock.tsx, src/App.tsx

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.