# Motion Phase A — Filters & Dropdowns Implementation Plan

> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.

**Goal:** Replace native filter `<select>`s with Motion-enhanced Radix Select / hybrid Combobox so filter UX matches the purple shell.

**Architecture:** Extend `lib/motion.ts` tokens; polish `select.tsx` and `dropdown-menu.tsx` overlays; add `combobox.tsx` (Popover + cmdk) and `filter-select.tsx` (auto-switch at 12 options); migrate listed pages without changing filter values/handlers.

**Tech Stack:** Next.js App Router, React, Radix UI, cmdk, Motion (`motion/react`), Tailwind, Plus Jakarta Sans / purple tokens

## Global Constraints

- Phase A only — Phase B (full UI kit) deferred
- No API / auth / filter-predicate changes — same option `value` strings
- Honor `prefers-reduced-motion`
- Light + dark theme parity
- Stay on `feature/ui-ux-revamp`
- Verify with `npx tsc --noEmit` (no component test suite in repo)
- Commit only when user asks

## File map

| File | Responsibility |
|------|----------------|
| `lib/motion.ts` | Shared overlay/press tokens |
| `components/ui/select.tsx` | Motion + purple polish on Radix Select |
| `components/ui/dropdown-menu.tsx` | Same overlay language for menus |
| `components/ui/combobox.tsx` | Searchable Popover + Command |
| `components/ui/filter-select.tsx` | Hybrid API for filter bars |
| `app/dashboard/users/page.tsx` | Primary migration |
| `app/dashboard/projects/page.tsx` | Filter migration |
| `app/dashboard/departments/page.tsx` | Native select migration |
| `app/dashboard/designations/page.tsx` | Native select migration |
| `app/dashboard/logged-hours/page.tsx` | User picker migration |
| `components/users/it-work-history.tsx` | Native select migration |

---

### Task 1: Motion tokens

**Files:**
- Modify: `lib/motion.ts`

**Interfaces:**
- Produces: `overlayVariants: Variants`, `pressScale: number` (0.98)

- [x] **Step 1: Add overlay + press exports**

Append to `lib/motion.ts`:

```ts
export const overlayVariants: Variants = {
  initial: { opacity: 0, scale: 0.97, y: -4 },
  animate: {
    opacity: 1,
    scale: 1,
    y: 0,
    transition: { duration: 0.18, ease: easeOutExpo },
  },
  exit: {
    opacity: 0,
    scale: 0.98,
    y: -2,
    transition: { duration: 0.12, ease: easeOutExpo },
  },
};

export const pressScale = 0.98;
```

- [x] **Step 2: Typecheck**

Run: `npx tsc --noEmit`  
Expected: PASS

---

### Task 2: Upgrade Select + DropdownMenu

**Files:**
- Modify: `components/ui/select.tsx`
- Modify: `components/ui/dropdown-menu.tsx`

**Interfaces:**
- Consumes: `overlayVariants`, `easeOutExpo` from `@/lib/motion`
- Produces: same public exports as today (no API break)

- [ ] **Step 1: Restyle Select**

- Trigger: `rounded-lg`, `h-9`/`h-10`, `border-border`, `bg-card`, `shadow-sm`, focus ring primary
- Content: `rounded-xl`, `border-border`, `shadow-lg`, `p-1`, remove reliance on browser blue; use `focus:bg-primary/10 focus:text-foreground` and `data-[state=checked]:bg-primary/10` on items
- Chevron: `transition-transform data-[state=open]:rotate-180` via group on trigger (`group` class + `group-data-[state=open]:rotate-180`)
- Wrap content children styling; keep Radix Portal
- Prefer CSS `animate-in` refinements + Motion on Content where it doesn’t break Radix positioning — if Motion wrapper fights Portal, keep polished Tailwind enter animations aligned with overlayVariants timings (`duration-200`, `fade`+`zoom`)

- [ ] **Step 2: Restyle DropdownMenuContent / items** same visual language (`rounded-xl`, primary focus wash)

- [ ] **Step 3: Typecheck**

Run: `npx tsc --noEmit`  
Expected: PASS

---

### Task 3: Combobox + FilterSelect

**Files:**
- Create: `components/ui/combobox.tsx`
- Create: `components/ui/filter-select.tsx`

**Interfaces:**
- Produces:

```ts
export type FilterOption = { value: string; label: string };

export function Combobox(props: {
  value: string;
  onValueChange: (value: string) => void;
  options: FilterOption[];
  placeholder?: string;
  searchPlaceholder?: string;
  emptyText?: string;
  disabled?: boolean;
  className?: string;
}): JSX.Element;

export function FilterSelect(props: {
  value: string;
  onValueChange: (value: string) => void;
  options: FilterOption[];
  placeholder?: string;
  searchPlaceholder?: string;
  emptyText?: string;
  disabled?: boolean;
  className?: string;
  searchThreshold?: number; // default 12
}): JSX.Element;
```

- [ ] **Step 1: Implement Combobox**

Popover trigger button matching SelectTrigger styles; Command input + CommandItem list; on select call `onValueChange` and close; show selected label; Check icon on selected row; purple focus/selected styles.

- [ ] **Step 2: Implement FilterSelect**

If `options.length > (searchThreshold ?? 12)` render `Combobox`, else render Radix `Select` with mapped `SelectItem`s. Always include caller-provided options (including the “All …” option as first entry).

- [ ] **Step 3: Typecheck**

Run: `npx tsc --noEmit`  
Expected: PASS

---

### Task 4: Migrate Users page filters

**Files:**
- Modify: `app/dashboard/users/page.tsx` (filter bar ~1455–1560)

**Interfaces:**
- Consumes: `FilterSelect`, `FilterOption`

- [ ] **Step 1: Replace each native `<select>` with `FilterSelect`**

Build `options` arrays including the current “all” / default entries with the same values (`"all"`, `"probation"`, etc.). Preserve state setters. Use `className="w-[min(100%,11rem)]"` or similar where `min-w-[180px]` was used for Managers.

- [ ] **Step 2: Manual check + typecheck**

Run: `npx tsc --noEmit`  
Expected: PASS  
Manual: Users filters open as styled menus; Managers searchable if >12 options.

---

### Task 5: Migrate remaining native selects

**Files:**
- Modify: `app/dashboard/projects/page.tsx`
- Modify: `app/dashboard/departments/page.tsx`
- Modify: `app/dashboard/designations/page.tsx`
- Modify: `app/dashboard/logged-hours/page.tsx`
- Modify: `components/users/it-work-history.tsx`

- [ ] **Step 1: Replace native `<select>` with `FilterSelect` (or shared Select if already structured)** — same values

- [ ] **Step 2: Typecheck**

Run: `npx tsc --noEmit`  
Expected: PASS

---

### Task 6: Acceptance pass

- [ ] **Step 1: Confirm acceptance criteria from spec**

1. Users filter bar has no native `<select>`
2. Short lists → Select; long → Combobox
3. Row DropdownMenus look polished
4. Purple selected/focus, no OS blue
5. Reduced-motion safe
6. `tsc` clean

- [ ] **Step 2: Stop for user review** (commit only if asked)
