Skip to content
Source
Sign inSign up
fuko/trytanstackdb.com

Animate the api request panel #31

Mergedfukomerged 2 commits intomain fromrefs/pull/31/headmerged by fuko View on GitHub

fukocommented

https://github.com/user-attachments/assets/bff55d9b-b899-4b47-99f8-9f97cbcbaed3

Summary by CodeRabbit

  • New Features

    • API requests panel is now collapsible, animates open/close, and preserves request history.
    • Panel header now contains the clear button and animates with the panel.
  • Style

    • Added overflow-hidden styling to the root element for more stable layout.
    • Adjusted mode toggle dropdown alignment for improved positioning.
  • Refactor

    • Simplified two-pane layout and streamlined sidebar/panel integration with reactive panel visibility.
✏️ Tip: You can customize this high-level summary in your review settings.
    1. Walkthrough

      Replaces the static API requests panel with a collapsible, animated panel driven by userPreferences.networkPanel (reactively read via useLiveQuery). Simplifies route layouts by removing the previous resizable/conditional panel and adds an overflow-hidden class to the root HTML element.

      Changes

      Cohort / File(s)Summary
      API Panel Animation & State
      src/components/ApiRequestsPanel.tsx
      Replaced always-visible panel with a motion-animated, collapsible panel controlled by userPreferences.networkPanel. Added imports: eq (from @tanstack/react-db), motion (from motion/react), userPreferencesCollection, and USER_PLACEHOLDER. Introduced API_PANEL_WIDTH and PANEL_ANIMATION_DURATION. Uses useLiveQuery to derive isApiPanelOpen. Moved header/clear button into animated header; request list now renders inside a motion-enabled ScrollArea.
      Root HTML class
      src/routes/__root.tsx
      Added overflow-hidden class to the root <html> element (no control-flow changes).
      Route Layout Simplification
      src/routes/_tutorial._db.projects.tsx
      Removed useLiveQuery user-preferences fetching and ResizablePanel conditional layout. Replaced with a simpler two-pane layout: AppSidebar + Outlet left, ApiRequestsPanel right. Removed panel sizing/open-state logic and adjusted SidebarProvider usage (className change includes overflow-hidden).
      Dropdown alignment tweak
      src/components/mode-toggle.tsx
      Changed DropdownMenuContent alignment from align="end" to align="center" (UI alignment only).

      Estimated code review effort

      🎯 3 (Moderate) | ⏱️ ~20 minutes

      Pre-merge checks and finishing touches

      ❌ Failed checks (1 warning)
      Check nameStatusExplanationResolution
      Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.You can run @coderabbitai generate docstrings to improve docstring coverage.
      ✅ Passed checks (2 passed)
      Check nameStatusExplanation
      Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
      Title check✅ PassedThe title 'Animate the api request panel' directly and accurately describes the primary change across the pull request files, focusing on the main implementation of animation for the API requests panel.
      ✨ Finishing touches
      • 📝 Generate docstrings
        🧪 Generate unit tests (beta)
      • Create PR with unit tests
      • Post copyable unit tests in a comment
      • Commit unit tests in branch `animated-api-requests-panel`

      📜 Recent review details

      Configuration used: Path: .coderabbit.yaml

      Review profile: CHILL

      Plan: Pro

      📥 Commits

      Reviewing files that changed from the base of the PR and between 49db3872ccf0de9ec3966f716aa4bcfe05425e62 and 3ecf8e067743863b6fa86cd53a9f4597b15ce4d5.

      📒 Files selected for processing (1)
      • src/components/mode-toggle.tsx
      🧰 Additional context used
      📓 Path-based instructions (1)
      **/*.{ts,tsx}

      📄 CodeRabbit inference engine (AGENTS.md)

      **/*.{ts,tsx}: Prefer functions over arrow functions for React components and everything else Prefer type declarations over interface declarations

      Files:

      • src/components/mode-toggle.tsx
      🧠 Learnings (1)
      📚 Learning: 2025-12-24T15:25:07.106Z
      Learnt from: fulopkovacs
      Repo: fulopkovacs/trytanstackdb.com PR: 22
      File: src/components/TodoBoards.tsx:63-81
      Timestamp: 2025-12-24T15:25:07.106Z
      Learning: In Tailwind CSS v4, prefer canonical classes using bg-linear-to-* (e.g., bg-linear-to-b, bg-linear-to-t, bg-linear-to-r) over the older bg-gradient-to-* syntax. This aligns with Tailwind LSP's suggestCanonicalClasses rule. Apply across TSX files (e.g., src/components/*.tsx); replace occurrences of bg-gradient-to-* with the corresponding bg-linear-to-* equivalents and verify gradients visually.

      Applied to files:

      • src/components/mode-toggle.tsx
      🧬 Code graph analysis (1)
      src/components/mode-toggle.tsx (1)
      src/components/ui/dropdown-menu.tsx (3)
      • DropdownMenu (7-11)
      • DropdownMenuTrigger (21-30)
      • DropdownMenuPortal (13-19)
      ⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
      • GitHub Check: Deploy Preview
      🔇 Additional comments (1)
      src/components/mode-toggle.tsx (1)

      23-23: LGTM! Dropdown alignment updated to center.

      The alignment change from "end" to "center" correctly implements the commit message "Mode selector list is centered now" and aligns with the PR's UI improvements.


      Comment `@coderabbitai help` to get the list of available commands and usage tips.
    2. 🚀 Preview Deployment

      Status: ✅ Ready!

      Preview URL: Open Preview

      Commit: 3ecf8e067743863b6fa86cd53a9f4597b15ce4d5

      Built and deployed successfully

    3. Actionable comments posted: 0

      🧹 Nitpick comments (2)
      src/routes/_tutorial._db.projects.tsx (1)

      38-38: Consider removing redundant overflow-hidden class.

      The overflow-hidden class on SidebarProvider may be redundant since the root <html> element also has overflow-hidden applied (in src/routes/__root.tsx line 204). This could be simplified unless there's a specific reason for the duplication.

      🔎 Proposed simplification
      -    <SidebarProvider className="w-auto overflow-hidden" defaultOpen>
      +    <SidebarProvider className="w-auto" defaultOpen>
      src/components/ApiRequestsPanel.tsx (1)

      158-169: Add explicit default for isApiPanelOpen.

      When userPreferences is undefined (e.g., during initial load before the query completes), isApiPanelOpen will be undefined, which JavaScript will coerce to false in the animation. While this works, it's better to be explicit about the default state for clarity and to avoid potential animation flicker.

      🔎 Proposed fix for explicit default
      -  const isApiPanelOpen = userPreferences?.networkPanel === "open";
      +  const isApiPanelOpen = userPreferences?.networkPanel === "open" ?? false;
      📜 Review details

      Configuration used: Path: .coderabbit.yaml

      Review profile: CHILL

      Plan: Pro

      📥 Commits

      Reviewing files that changed from the base of the PR and between 10c4b4fe2b2e44bdf4fc0fb6db29e1ffe21b5639 and 49db3872ccf0de9ec3966f716aa4bcfe05425e62.

      📒 Files selected for processing (3)
      • src/components/ApiRequestsPanel.tsx
      • src/routes/__root.tsx
      • src/routes/_tutorial._db.projects.tsx
      🧰 Additional context used
      📓 Path-based instructions (1)
      **/*.{ts,tsx}

      📄 CodeRabbit inference engine (AGENTS.md)

      **/*.{ts,tsx}: Prefer functions over arrow functions for React components and everything else Prefer type declarations over interface declarations

      Files:

      • src/components/ApiRequestsPanel.tsx
      • src/routes/__root.tsx
      • src/routes/_tutorial._db.projects.tsx
      🧠 Learnings (3)
      📚 Learning: 2025-12-27T20:43:43.168Z
      Learnt from: CR
      Repo: fulopkovacs/trytanstackdb.com PR: 0
      File: AGENTS.md:0-0
      Timestamp: 2025-12-27T20:43:43.168Z
      Learning: Project uses TanStack Start framework with React, TanStack Router, shadcn/ui, and Tailwind CSS v4

      Applied to files:

      • src/components/ApiRequestsPanel.tsx
      • src/routes/_tutorial._db.projects.tsx
      📚 Learning: 2025-12-24T15:25:07.106Z
      Learnt from: fulopkovacs
      Repo: fulopkovacs/trytanstackdb.com PR: 22
      File: src/components/TodoBoards.tsx:63-81
      Timestamp: 2025-12-24T15:25:07.106Z
      Learning: In Tailwind CSS v4, prefer canonical classes using bg-linear-to-* (e.g., bg-linear-to-b, bg-linear-to-t, bg-linear-to-r) over the older bg-gradient-to-* syntax. This aligns with Tailwind LSP's suggestCanonicalClasses rule. Apply across TSX files (e.g., src/components/*.tsx); replace occurrences of bg-gradient-to-* with the corresponding bg-linear-to-* equivalents and verify gradients visually.

      Applied to files:

      • src/components/ApiRequestsPanel.tsx
      • src/routes/__root.tsx
      • src/routes/_tutorial._db.projects.tsx
      📚 Learning: 2025-12-27T20:43:43.168Z
      Learnt from: CR
      Repo: fulopkovacs/trytanstackdb.com PR: 0
      File: AGENTS.md:0-0
      Timestamp: 2025-12-27T20:43:43.168Z
      Learning: The root route is located at `src/route/__root.tsx` in TanStack Start

      Applied to files:

      • src/routes/_tutorial._db.projects.tsx
      🧬 Code graph analysis (2)
      src/components/ApiRequestsPanel.tsx (3)
      src/collections/UserPreferences.ts (1)
      • userPreferencesCollection (12-19)
      src/utils/USER_PLACEHOLDER_CONSTANT.ts (1)
      • USER_PLACEHOLDER (7-12)
      src/components/ApiPanelToggle.tsx (4)
      • ApiPanelToggle (8-44)
      • userPreferencesCollection (28-32)
      • q (9-17)
      • draft (29-32)
      src/routes/_tutorial._db.projects.tsx (2)
      src/components/AppSidebar.tsx (1)
      • AppSidebar (28-132)
      src/components/ApiRequestsPanel.tsx (1)
      • ApiRequestsPanel (147-230)
      🔇 Additional comments (5)
      src/routes/_tutorial._db.projects.tsx (1)

      23-29: LGTM! Clean layout simplification.

      The refactored two-pane layout is much cleaner and easier to understand compared to the previous ResizablePanel-driven approach. The structure clearly separates the sidebar/outlet area from the API requests panel.

      src/components/ApiRequestsPanel.tsx (3)

      1-1: LGTM! Import additions support the new animation and state management.

      The new imports are all necessary for the collapsible, animated panel functionality:

      • eq for filtering user preferences by ID
      • motion for smooth animations
      • userPreferencesCollection for reactive state
      • USER_PLACEHOLDER for identifying the user record

      Also applies to: 8-8, 14-14, 16-16


      26-27: LGTM! Sensible animation constants.

      The panel width of 24rem and animation duration of 0.15s provide a good balance between visibility and smooth transitions.


      172-229: Excellent animation implementation with staggered timing!

      The nested motion.div structure with coordinated delays creates a polished user experience:

      • Opening: width expands first, then content fades in
      • Closing: content fades out first, then width collapses

      This prevents content from being visible in a compressed state during the transition. The use of initial={false} also prevents animation on mount, which is the correct approach here.

      src/routes/__root.tsx (1)

      204-204: No action needed — overflow-hidden on the <html> element will not clip tooltips, modals, or popovers in this codebase. All shadcn/ui components (Popover, Dialog, Sheet, DropdownMenu, Tooltip) and the Sonner Toaster use Radix UI portals with fixed positioning relative to the viewport, which are unaffected by overflow constraints on ancestor elements. The overflow-hidden class appropriately prevents document scrolling while allowing fixed-positioned portal elements to render normally.

    4. fuko merged thisd46d8d0

    5. fuko closed this

Sign in to join this conversation.