Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions bundle-budget.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,39 @@
},
"shellJs": 296,
"routeJs": {
"/": 158,
"/": 124,
"/admin": 87,
"/admin/activity": 89,
"/admin/activity/$ip": 90,
"/admin/ai-search": 80,
"/admin/categories": 122,
"/admin/downloader": 89,
"/admin/library": 124,
"/admin/library/$memeId": 203,
"/admin/library": 123,
"/admin/library/$memeId": 187,
"/admin/proposals": 91,
"/admin/services": 65,
"/admin/users": 102,
"/admin/users/$userId": 112,
"/app": 140,
"/checkout/success": 127,
"/dmca": 133,
"/embed/$memeId": 75,
"/faq": 127,
"/memes/$memeId": 209,
"/memes/$memeId/studio": 228,
"/memes/ai-search": 178,
"/memes/bookmarks": 160,
"/memes/category/$slug": 159,
"/mentions-legales": 133,
"/password/create-new": 166,
"/password/reset": 164,
"/pricing": 140,
"/privacy": 133,
"/reels": 96,
"/settings": 177,
"/submit": 168,
"/terms-of-use": 133,
"/verify-email": 153
"/app": 113,
"/checkout/success": 97,
"/dmca": 102,
"/embed/$memeId": 58,
"/faq": 97,
"/memes/$memeId": 164,
"/memes/$memeId/studio": 188,
"/memes/ai-search": 146,
"/memes/bookmarks": 126,
"/memes/category/$slug": 133,
"/mentions-legales": 102,
"/password/create-new": 137,
"/password/reset": 135,
"/pricing": 117,
"/privacy": 102,
"/reels": 69,
"/settings": 156,
"/submit": 139,
"/terms-of-use": 102,
"/verify-email": 124
},
"firstViewCss": {
"/": 39.7,
Expand Down
5 changes: 3 additions & 2 deletions e2e/phone-journey.mobile.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const LIBRARY_PATHNAME = '/memes/category/all'

const FAR_DOWN_CARD_INDEX = 19

const REELS_MODULE_PATTERN = /\/assets\/use-register-meme-view-[\w-]+\.js$/u
const REELS_EXPORT_PANEL_MODULE_PATTERN =
/\/assets\/meme-export-panel-[\w-]{8}\.js$/u

const ALGOLIA_INSIGHTS_EVENTS_URL = new URL('/1/events', E2E_ALGOLIA_ORIGIN)
.href
Expand Down Expand Up @@ -88,7 +89,7 @@ test.describe('the phone journey', () => {

let hasFailedAModule = false

await page.route(REELS_MODULE_PATTERN, (route) => {
await page.route(REELS_EXPORT_PANEL_MODULE_PATTERN, (route) => {
if (hasFailedAModule) {
return route.fallback()
}
Expand Down
15 changes: 15 additions & 0 deletions src/@types/media-chrome.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type React from 'react'

type MediaControllerAttributes = React.HTMLAttributes<HTMLElement> & {
ref?: React.Ref<HTMLElement>
hotkeys?: string
}

declare module 'react' {
namespace JSX {
// oxlint-disable-next-line typescript/consistent-type-definitions -- only an interface merges into React's JSX element map
interface IntrinsicElements {
'media-controller': MediaControllerAttributes
}
}
}
37 changes: 17 additions & 20 deletions src/components/animate-ui/backgrounds/stars.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type React from 'react'
import { useScroll, useTransform } from 'motion/react'
import * as motion from 'motion/react-m'
import React from 'react'
import { LazyScrollFadeFallback } from '~/components/animate-ui/lazy-scroll-fade-fallback'
import { SCROLL_TIMELINE_SUPPORT } from '~/constants/media-query'
import { useNeedsCssFallback } from '~/hooks/use-needs-css-fallback'
import { cn } from '~/lib/utils'
Expand Down Expand Up @@ -46,6 +45,8 @@ const getFallbackStarShadows = () => {
return fallbackStarShadows
}

const DRIFT_CLASS_NAME = 'stars-drift'

const toDriftOpacity = (scrollY: number) => {
const depthInViewports = scrollY / window.innerHeight
const fadeProgress =
Expand All @@ -55,31 +56,27 @@ const toDriftOpacity = (scrollY: number) => {
return 1 - Math.min(Math.max(fadeProgress, 0), 1)
}

type DriftScrollFadeFallbackProps = React.PropsWithChildren

const DriftScrollFadeFallback = ({
children
}: DriftScrollFadeFallbackProps) => {
const { scrollY } = useScroll()
const opacity = useTransform(scrollY, toDriftOpacity)

return (
<motion.div className="stars-drift" style={{ opacity }}>
{children}
</motion.div>
)
}

type DriftProps = React.PropsWithChildren

const Drift = ({ children }: DriftProps) => {
const needsScrollFadeFallback = useNeedsCssFallback(SCROLL_TIMELINE_SUPPORT)

const staticDrift = <div className={DRIFT_CLASS_NAME}>{children}</div>

if (needsScrollFadeFallback) {
return <DriftScrollFadeFallback>{children}</DriftScrollFadeFallback>
return (
<React.Suspense fallback={staticDrift}>
<LazyScrollFadeFallback
className={DRIFT_CLASS_NAME}
toOpacity={toDriftOpacity}
>
{children}
</LazyScrollFadeFallback>
</React.Suspense>
)
}

return <div className="stars-drift">{children}</div>
return staticDrift
}

export type AuroraScene = 'home' | 'app' | 'library' | 'meme' | 'page'
Expand Down
7 changes: 7 additions & 0 deletions src/components/animate-ui/lazy-scroll-fade-fallback.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { lazyComponent } from '~/lib/lazy-component'

export const LazyScrollFadeFallback = lazyComponent(async () => {
const { ScrollFadeFallback } = await import('./scroll-fade-fallback')

return ScrollFadeFallback
})
23 changes: 23 additions & 0 deletions src/components/animate-ui/scroll-fade-fallback.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type React from 'react'
import { useScroll, useTransform } from 'motion/react'
import * as motion from 'motion/react-m'

type ScrollFadeFallbackProps = React.PropsWithChildren<{
className: string
toOpacity: (scrollY: number) => number
}>

export const ScrollFadeFallback = ({
className,
toOpacity,
children
}: ScrollFadeFallbackProps) => {
const { scrollY } = useScroll()
const opacity = useTransform(scrollY, toOpacity)

return (
<motion.div className={className} style={{ opacity }} aria-hidden="true">
{children}
</motion.div>
)
}
28 changes: 14 additions & 14 deletions src/components/layout/navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { User } from 'lucide-react'
import { useScroll, useTransform } from 'motion/react'
import * as motion from 'motion/react-m'
import { Link, useRouteContext } from '@tanstack/react-router'
import { LazyScrollFadeFallback } from '~/components/animate-ui/lazy-scroll-fade-fallback'
import { ThemeSwitcher } from '~/components/animate-ui/theme-switcher'
import { LanguageSwitcher } from '~/components/layout/language-switcher'
import { useIsLibraryActive } from '~/components/layout/use-is-library-active'
Expand Down Expand Up @@ -52,17 +52,12 @@ const NavigationLinks = () => {
)
}

const NavbarScrollFadeFallback = () => {
const { scrollY } = useScroll()
const opacity = useTransform(scrollY, [0, NAVBAR_SCROLL_FADE_RANGE], [0, 1])
const toNavbarBackdropOpacity = (scrollY: number) => {
return Math.min(Math.max(scrollY / NAVBAR_SCROLL_FADE_RANGE, 0), 1)
}

return (
<motion.div
className={NAVBAR_BACKDROP_CLASS_NAME}
style={{ opacity }}
aria-hidden="true"
/>
)
const NavbarBackdrop = () => {
return <div className={NAVBAR_BACKDROP_CLASS_NAME} aria-hidden="true" />
}

const AccountAction = () => {
Expand Down Expand Up @@ -106,9 +101,14 @@ export const Navbar = ({ isHomePage, isSolidOnPhone }: NavbarProps) => {
/>
) : null}
{needsFallback ? (
<NavbarScrollFadeFallback />
<React.Suspense fallback={<NavbarBackdrop />}>
<LazyScrollFadeFallback
className={NAVBAR_BACKDROP_CLASS_NAME}
toOpacity={toNavbarBackdropOpacity}
/>
</React.Suspense>
) : (
<div className={NAVBAR_BACKDROP_CLASS_NAME} aria-hidden="true" />
<NavbarBackdrop />
)}
<div className="relative container-wide flex h-full items-center justify-between gap-3 lg:gap-6">
<div className="flex min-w-max shrink-0 items-center gap-4 lg:flex-1">
Expand Down
Loading
Loading