mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
## Problem Closes #31221. The applications and shared UI packages still import the former `framer-motion` package instead of Motion's React entry point. ## Solution Replace runtime imports, type imports, and three test mocks with `motion/react` across the consuming workspaces. Replace the seven direct dependency declarations with `motion: ^11.18.2`. Preserve the existing animation engine version and all other dependency resolutions, including the asynchronous `domMax` feature loader. Historical blog examples remain as published; `framer-motion` remains a transitive implementation dependency of Motion. ## Review instructions 1. Run `pnpm install --frozen-lockfile` and check the seven dependency replacements in the lockfile. 2. Open the WWW Auth page and Docs homepage at desktop and mobile widths, with normal and reduced motion preferences. 3. Open the mobile navigation, expand Product on WWW, and close the menu using Escape and the close button. 4. Check the existing animation components, shared form validation, and Studio tests for unchanged behavior. Validation: - Studio: 731 test files, 8,334 passing tests and one expected failure, with `--maxWorkers=4`. - Shared UI, UI patterns, WWW, and UI library: 615 passing tests. - `pnpm run typecheck --concurrency=1`: all 16 repository tasks pass. - All six application source lint scripts and lint ratchets pass; generated Docs example copies are excluded from local lint. - Repository Prettier source check, lockfile formatting, and case hazard check pass. - WWW: 10 existing end-to-end checks across nine pages. - Docs: 5 existing guide link and accessibility checks across Database and Auth. - WWW and Docs mobile navigation pass at desktop/mobile sizes with normal/reduced motion; SQL-to-REST translation tabs exercise the asynchronous feature loader without browser errors. - Frozen-lockfile installation passes; all existing package and snapshot resolutions are unchanged. - Learn and UI library command palettes open, filter results, and close with Escape without browser errors. - Independent code review finds no actionable defects. - `npm run build -- --filter=www --filter=docs --filter=studio --filter=learn --filter=library --concurrency=1 --continue=always`: all five affected applications build successfully (9 tasks including prerequisites); asset uploads disabled for local validation. ## Checklist - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [x] If I wrote a new docs topic or edited an existing topic, I used the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs [style guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide) (no docs topics changed) --------- Co-authored-by: Danny White <3104761+dnywh@users.noreply.github.com>
138 lines
4.6 KiB
TypeScript
138 lines
4.6 KiB
TypeScript
import { useBreakpoint, useReducedMotion } from 'common'
|
|
import { navData as DevelopersData } from 'data/Solutions'
|
|
import { ArrowLeftRight, ChevronRight } from 'lucide-react'
|
|
import { AnimatePresence, motion } from 'motion/react'
|
|
import Link from 'next/link'
|
|
import { useState } from 'react'
|
|
import { useMedia } from 'react-use'
|
|
|
|
type LinkProps = {
|
|
text: string
|
|
description?: string
|
|
url?: string
|
|
icon?: any
|
|
svg?: any
|
|
}
|
|
|
|
export const SolutionsDropdown = () => (
|
|
<div className="bg-surface-75 flex flex-col lg:flex-row">
|
|
<div className="w-full lg:w-[600px] px-6 py-5 grid gap-3 grid-cols-2 lg:grid-cols-3">
|
|
{/* Skill Level, Who it's for, App Type */}
|
|
{DevelopersData['navigation'].slice(0, 3).map((column) => (
|
|
<LinksGroup key={column.label} links={column.links} label={column.label} />
|
|
))}
|
|
</div>
|
|
|
|
<div className="flex flex-col w-full lg:flex-1 border-t lg:border-t-0 lg:border-l">
|
|
<div className="flex flex-col gap-6 p-5">
|
|
<label className="text-foreground-lighter text-xs uppercase tracking-widest font-mono">
|
|
{DevelopersData['navigation'][3].label}
|
|
</label>
|
|
|
|
<div className="flex flex-col gap-4">
|
|
{DevelopersData['navigation'][3].links.map((link) => (
|
|
<MigrationLinkCard key={link.text} link={link} />
|
|
))}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
|
|
const LinksGroup = ({ links, label }: { links: LinkProps[]; label: string }) => {
|
|
return (
|
|
<div key={label} className="p-0 flex flex-col gap-6">
|
|
<label className="text-foreground-lighter text-xs uppercase tracking-widest font-mono">
|
|
{label}
|
|
</label>
|
|
<ul className="flex flex-col gap-4">
|
|
{links.map(({ icon: Icon, ...link }: LinkProps) => (
|
|
<li key={link.text}>
|
|
<Link
|
|
href={link.url!}
|
|
className="flex group items-center gap-2 text-foreground-light text-sm hover:text-foreground focus-visible:text-foreground focus-ring rounded-sm"
|
|
>
|
|
{Icon && <Icon size={16} strokeWidth={1.3} />}
|
|
<span>{link.text}</span>
|
|
<ChevronRight
|
|
strokeWidth={2}
|
|
className="w-3 -ml-1 transition-all will-change-transform -translate-x-1 opacity-0 group-hover:translate-x-0 group-hover:opacity-100"
|
|
/>
|
|
</Link>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
const MotionLink = motion(Link)
|
|
|
|
const MigrationLinkCard = ({ link }: { link: LinkProps }) => {
|
|
const [isHighlighted, setIsHighlighted] = useState(false)
|
|
const canHover = useMedia('(hover: hover)', true)
|
|
const reduceMotion = useReducedMotion()
|
|
const isDesktop = !useBreakpoint('lg')
|
|
const duration = isDesktop && !reduceMotion ? 0.2 : 0
|
|
const isIconVisible = isHighlighted || !isDesktop || !canHover
|
|
|
|
return (
|
|
<MotionLink
|
|
href={link.url!}
|
|
className="bg-background p-3 rounded-md border flex items-center gap-4 group overflow-hidden"
|
|
onMouseEnter={() => setIsHighlighted(true)}
|
|
onMouseLeave={() => setIsHighlighted(false)}
|
|
onFocus={() => setIsHighlighted(true)}
|
|
onBlur={() => setIsHighlighted(false)}
|
|
layout
|
|
layoutDependency={isHighlighted}
|
|
transition={{ duration, ease: 'easeInOut' }}
|
|
>
|
|
<AnimatePresence mode="popLayout">
|
|
{isIconVisible && (
|
|
<motion.div
|
|
initial={{ opacity: 0, x: -10 }}
|
|
animate={{ opacity: 1, x: 0 }}
|
|
exit={{ opacity: 0, x: -10 }}
|
|
transition={{ duration, ease: 'easeInOut' }}
|
|
layout
|
|
layoutDependency={isHighlighted}
|
|
>
|
|
{link.icon && <link.icon className="size-6" />}
|
|
</motion.div>
|
|
)}
|
|
</AnimatePresence>
|
|
|
|
<motion.div
|
|
className="size-6 flex items-center justify-center"
|
|
layout
|
|
layoutDependency={isHighlighted}
|
|
transition={{ duration, ease: 'easeInOut' }}
|
|
>
|
|
<ArrowLeftRight className="size-4 text-foreground-light" strokeWidth={1.3} />
|
|
</motion.div>
|
|
|
|
<motion.div
|
|
className="flex items-center gap-1"
|
|
layout
|
|
layoutDependency={isHighlighted}
|
|
transition={{ duration, ease: 'easeInOut' }}
|
|
>
|
|
<span className="text-base font-medium">{link.text}</span>
|
|
</motion.div>
|
|
|
|
<motion.div
|
|
layout
|
|
layoutDependency={isHighlighted}
|
|
transition={{ duration, ease: 'easeInOut' }}
|
|
className="ml-auto"
|
|
>
|
|
<ChevronRight
|
|
strokeWidth={2}
|
|
className="w-3 transition-all will-change-transform -translate-x-1 opacity-0 group-hover:translate-x-0 group-hover:opacity-100"
|
|
/>
|
|
</motion.div>
|
|
</MotionLink>
|
|
)
|
|
}
|