diff --git a/src/components/MaintainersDirectoryFilters.tsx b/src/components/MaintainersDirectoryFilters.tsx new file mode 100644 index 000000000..6d9fa8a01 --- /dev/null +++ b/src/components/MaintainersDirectoryFilters.tsx @@ -0,0 +1,210 @@ +import { Select } from '@base-ui/react/select' +import { CaretDownIcon, CheckIcon } from '@phosphor-icons/react' +import * as v from 'valibot' +import { libraries } from '~/libraries' +import { frameworkOptions } from '~/libraries/frameworks' +import { allMaintainers } from '~/libraries/maintainers' +import { libraryIdSchema } from '~/utils/schemas' + +const frameworkChoices = frameworkOptions.filter(({ value }) => + allMaintainers.some((maintainer) => + maintainer.frameworkExpertise?.includes(value), + ), +) +const specialtyLabels = new Map() +for (const label of allMaintainers.flatMap( + (person) => person.specialties ?? [], +)) { + const value = label.toLowerCase() + if (!specialtyLabels.has(value)) specialtyLabels.set(value, label) +} +const specialtyChoices = Array.from(specialtyLabels, ([value, label]) => ({ + value, + label, +})).sort((a, b) => a.label.localeCompare(b.label)) + +const groupBySchema = v.picklist(['none', 'core', 'library', 'role']) +const sortBySchema = v.picklist(['none', 'name', 'role', 'contributions']) + +export const maintainersDirectorySearchSchema = v.object({ + libraries: v.fallback(v.optional(v.array(libraryIdSchema)), undefined), + frameworks: v.fallback( + v.optional(v.array(v.picklist(frameworkChoices.map(({ value }) => value)))), + undefined, + ), + specialties: v.fallback( + v.optional(v.array(v.picklist(specialtyChoices.map(({ value }) => value)))), + undefined, + ), + groupBy: v.fallback(v.optional(groupBySchema, 'none'), 'none'), + sortBy: v.fallback(v.optional(sortBySchema, 'none'), 'none'), +}) + +type DirectorySearch = v.InferOutput + +const groupByChoices = [ + { value: 'none', label: 'No grouping' }, + { value: 'core', label: 'Core status' }, + { value: 'library', label: 'Library' }, + { value: 'role', label: 'Role' }, +] satisfies ReadonlyArray<{ value: DirectorySearch['groupBy']; label: string }> + +const sortByChoices = [ + { value: 'none', label: 'Default' }, + { value: 'name', label: 'Name' }, + { value: 'role', label: 'Role' }, + { value: 'contributions', label: 'Contributions' }, +] satisfies ReadonlyArray<{ value: DirectorySearch['sortBy']; label: string }> + +function FilterSelect< + TValue extends string, + TMultiple extends boolean = false, +>({ + label, + choices, + ...selection +}: Pick< + Select.Root.Props, + 'multiple' | 'value' | 'onValueChange' +> & { + label: string + choices: ReadonlyArray<{ value: TValue; label: string }> +}) { + const selectionCount = Array.isArray(selection.value) + ? selection.value.length + : 0 + + return ( +
+ + {...selection} + items={choices} + modal={false} + > + + {label} + + + + {selectionCount > 1 ? `${selectionCount} selected` : undefined} + + + + + + + + + {choices.map(({ value, label }) => ( + + + + {label} + + ))} + + + + + +
+ ) +} + +export function MaintainersDirectoryFilters({ + search, + onChange, + clearAll, +}: { + search: DirectorySearch + onChange: (updates: Partial) => void + clearAll?: () => void +}) { + const libraryChoices = libraries + .filter( + ({ id, visible }) => visible !== false || search.libraries?.includes(id), + ) + .map(({ id, name }) => ({ + value: id, + label: name.replace(/^TanStack /, ''), + })) + + return ( +
+
+
+ + onChange({ libraries: libraries.length ? libraries : undefined }) + } + /> + + onChange({ + frameworks: frameworks.length ? frameworks : undefined, + }) + } + /> + + onChange({ + specialties: specialties.length ? specialties : undefined, + }) + } + /> + + onChange({ groupBy: groupBy ?? 'none' }) + } + /> + onChange({ sortBy: sortBy ?? 'none' })} + /> +
+
+ {clearAll && ( +
+ +
+ )} +
+ ) +} diff --git a/src/components/MaintainersMap.tsx b/src/components/MaintainersMap.tsx index 4cbf2fcb7..5a5df3d68 100644 --- a/src/components/MaintainersMap.tsx +++ b/src/components/MaintainersMap.tsx @@ -8,6 +8,7 @@ import { useState, } from 'react' import { ClientOnly } from '@tanstack/react-router' +import { useSuspenseQuery } from '@tanstack/react-query' import { geoDistance, select, zoom, zoomIdentity, type D3ZoomEvent } from 'd3' import { ArrowCounterClockwiseIcon, @@ -18,20 +19,17 @@ import { XIcon, } from '@phosphor-icons/react' import type { Maintainer } from '~/libraries/maintainers' -import type { LibraryId } from '~/libraries/types' import { categoryOf } from '~/libraries/categories' import { Tooltip } from '~/ui/Tooltip' import { MaintainerAvatarImage } from './MaintainerAvatarImage' -import { createChartsGlobe, globeHaloScale } from './maintainersChartsGlobe' +import { getVisitorLocation } from '~/utils/visitor-location.functions' +import { createChartsGlobe } from './maintainersChartsGlobe' import { initialMaintainersView, initialView } from './maintainersGlobeView' const zoomStep = 1.5 const maxZoom = 128 -const mobileInitialScale = zoomStep -const desktopInitialScale = initialView.scale * zoomStep +const initialScale = initialView.scale * zoomStep const mobileViewport = '(max-width: 639px)' -const mobileTopInset = 8 -const mobileCornerBleed = 6 const mobileZoomFade = 48 // Allow for rounding in rAF timestamps at 60 Hz and cap redraws on faster displays. const frameInterval = 1000 / 60 - 1 @@ -45,7 +43,7 @@ const profileClearance = 12 const viewportGutter = 16 const offscreenBadgeMinRemaining = 96 const globeRadius = 0.4 -const globeGlowDiameter = 0.92 +const globeGlowDiameter = 0.9 const zoomControls = { width: 46, height: 171 } type View = typeof initialView @@ -70,7 +68,6 @@ type ProfileViewport = { contentBottom: number helpTop: number helpBottom: number - filters: Array<{ left: number; right: number; top: number; bottom: number }> } type ProfileSize = { width: number; height: number } @@ -209,7 +206,7 @@ function placeProfiles( ) { const gap = mobile ? 4 : 8 const maxConnectorLength = mobile ? 48 : 72 - const left = mobile ? 0 : viewportGutter + const left = mobile ? bounds.contentInset : viewportGutter const right = bounds.width - left const top = Math.max(viewport.contentTop, viewport.top) const badgeTop = Math.max(0, top) @@ -246,7 +243,6 @@ function placeProfiles( top: viewport.helpTop, bottom: viewport.helpBottom, }, - ...viewport.filters, ] const labels = nodes.flatMap( ({ id, card, line, pin, sizes, pendingImages }) => { @@ -646,16 +642,10 @@ function placeProfiles( type MaintainersMapProps = { maintainers: Maintainer[] - selectedLibraries?: LibraryId[] - initialLocation: Parameters[0] } function Key({ children }: { children: React.ReactNode }) { - return ( - - {children} - - ) + return {children} } function GlobeAvatar({ @@ -684,11 +674,12 @@ function GlobeAvatar({ ) } -export function MaintainersMap({ - maintainers, - selectedLibraries, - initialLocation, -}: MaintainersMapProps) { +export function MaintainersMap({ maintainers }: MaintainersMapProps) { + const { data: initialLocation } = useSuspenseQuery({ + queryKey: ['maintainers-globe', 'visitor-location'], + queryFn: () => getVisitorLocation().catch(() => null), + staleTime: Infinity, + }) const prefix = useId().replace(/[^a-zA-Z0-9_-]/g, '') const [host, setHost] = useState((): HTMLDivElement | null => null) const [surface, setSurface] = useState((): HTMLDivElement | null => null) @@ -756,15 +747,11 @@ export function MaintainersMap({ for (const group of result) { const categories = new Set( group.members.map((member) => { - const library = [ - ...(member.creatorOf ?? []), - ...(member.maintainerOf ?? []), - ...(member.contributorOf ?? []), - ...(member.consultantOf ?? []), - ].find( - (id) => - !selectedLibraries?.length || selectedLibraries.includes(id), - ) + const library = + member.creatorOf?.[0] ?? + member.maintainerOf?.[0] ?? + member.contributorOf?.[0] ?? + member.consultantOf?.[0] return library ? categoryOf(library) : undefined }), ) @@ -775,62 +762,30 @@ export function MaintainersMap({ : 'var(--color-text-secondary)' } return result - }, [maintainers, selectedLibraries, prefix, scale]) + }, [maintainers, prefix, scale]) const selected = groups.find((group) => group.id === selectedId) // Read by the frame loop, so zooming doesn't restart it. const groupsRef = useRef(groups) useLayoutEffect(() => { if (!host || !surface) return - const mobile = window.matchMedia(mobileViewport) - let landingWidth = 0 - let landingHeight = 0 const readBounds = () => { const width = host.clientWidth const contentWidth = host.parentElement?.clientWidth ?? width const paintWidth = surface.clientWidth - let height = host.clientHeight - let centerY = height / 2 - let mobilePaintTop = 0 - let projectionHeight = Math.min( - height, - paintWidth / (desktopInitialScale * globeGlowDiameter), - ) - if (mobile.matches) { - if (paintWidth !== landingWidth || window.scrollY === 0) { - landingWidth = paintWidth - landingHeight = - window.visualViewport?.height ?? - document.documentElement.clientHeight - } - const pageTop = host.getBoundingClientRect().top + window.scrollY - mobilePaintTop = -Math.ceil(Math.max(0, pageTop)) - host.style.setProperty('--globe-paint-top', `${mobilePaintTop}px`) - const halfWidth = paintWidth / 2 + mobileCornerBleed - // Fill the first viewport's corners, then reserve room for the entire globe. - const bottomDepth = Math.max( - halfWidth, - landingHeight - pageTop - mobileTopInset, - ) - const radius = (bottomDepth ** 2 + halfWidth ** 2) / (2 * bottomDepth) - projectionHeight = radius / (mobileInitialScale * globeRadius) - centerY = mobileTopInset + radius - const globeHeight = Math.ceil( - centerY + radius * globeHaloScale + mobileTopInset, - ) - if (height !== globeHeight) - host.style.setProperty('--globe-mobile-height', `${globeHeight}px`) - height = globeHeight - } + const height = host.clientHeight const paintHeight = surface.clientHeight + // The mobile surface is taller than the viewport-wide SVG's width so + // the globe fills its height and extends past its side edges. + const projectionHeight = paintHeight / (initialScale * globeGlowDiameter) return { width, height, - centerY, + centerY: height / 2, contentInset: (width - contentWidth) / 2, paintWidth, paintHeight, - paintTop: mobile.matches ? mobilePaintTop : (height - paintHeight) / 2, + paintTop: (height - paintHeight) / 2, projectionHeight, } } @@ -899,8 +854,6 @@ export function MaintainersMap({ const section = container.closest('section') const help = section?.querySelector('#maintainers-globe-help') const intro = section?.parentElement?.querySelector(':scope > header') - const filterControls = - section?.parentElement?.querySelectorAll('[data-globe-filter]') ?? [] const navbarHeight = Number.parseFloat( getComputedStyle(document.documentElement).getPropertyValue( @@ -923,7 +876,7 @@ export function MaintainersMap({ let fadedScale: number | undefined let fadedBounds: GlobeBounds | undefined const updateViewport = () => { - const { top, left, height } = container.getBoundingClientRect() + const { top, height } = container.getBoundingClientRect() const contentTop = (intro?.getBoundingClientRect().bottom ?? top) - top + viewportGutter const helpBounds = help?.getBoundingClientRect() @@ -954,15 +907,6 @@ export function MaintainersMap({ contentBottom, helpTop: (helpBounds?.top ?? 0) - top, helpBottom: (helpBounds?.bottom ?? 0) - top, - filters: Array.from(filterControls, (control) => { - const rect = control.getBoundingClientRect() - return { - top: rect.top - top, - bottom: rect.bottom - top, - left: rect.left - left, - right: rect.right - left, - } - }), } viewportChanged = true requestFrame() @@ -1106,7 +1050,6 @@ export function MaintainersMap({ ? Number(entered || reducedMotion) : Math.min(1, (now - entranceStart) / entranceDuration) const remaining = (1 - progress) ** 4 - // Keep the mobile corners covered even at the start of the entrance. const startScale = mobile.matches ? mobileEntranceScale : entranceScale @@ -1128,17 +1071,14 @@ export function MaintainersMap({ const fade = Math.min( mobileZoomFade, mobileZoomFade * - Math.max( - 0, - (current.scale - mobileInitialScale) / (zoomStep - 1), - ), + Math.max(0, (current.scale - initialScale) / (zoomStep - 1)), ) const drawRadius = projectionHeight * current.scale * globeRadius const fadeAt = (overflow: number) => `${Math.max(0, Math.min(fade, overflow))}px` canvasSurface.style.setProperty( - '--globe-fade-bottom', - fadeAt(centerY + drawRadius - paintTop - paintHeight), + '--globe-fade-vertical', + fadeAt(drawRadius - paintHeight / 2), ) canvasSurface.style.setProperty( '--globe-fade-side', @@ -1242,9 +1182,6 @@ export function MaintainersMap({ wakeGlobe.current?.() }) selection.call(behavior) - const initialScale = window.matchMedia(mobileViewport).matches - ? mobileInitialScale - : desktopInitialScale selection.call(behavior.transform, zoomIdentity.scale(initialScale)) view.current.scale = initialScale return () => { @@ -1283,13 +1220,12 @@ export function MaintainersMap({ } @media ${mobileViewport} { [data-globe-surface] { - top: var(--globe-paint-top, 0px); - height: calc(100% - var(--globe-paint-top, 0px)); mask-image: linear-gradient( to bottom, - black, - black calc(100% - var(--globe-fade-bottom, 0px)), + transparent, + black var(--globe-fade-vertical, 0px), + black calc(100% - var(--globe-fade-vertical, 0px)), transparent ), linear-gradient( @@ -1319,7 +1255,7 @@ export function MaintainersMap({ to { opacity: 1; } } `} -
+
-
+

- Drag or Shift+arrows to rotate. Hold Ctrl/ - ⌘ and scroll to zoom. Hover or focus a profile to pause, - select to see nearby maintainers, Esc to close. + Select to see nearby maintainers, Esc to close. - Drag to rotate, pinch to zoom. Tap a profile to see nearby - maintainers. + Tap a profile to see nearby maintainers.

{selected && ( diff --git a/src/components/PartnersSponsorsSection.tsx b/src/components/PartnersSponsorsSection.tsx index 34dbae7ce..4f0efeb7c 100644 --- a/src/components/PartnersSponsorsSection.tsx +++ b/src/components/PartnersSponsorsSection.tsx @@ -9,6 +9,7 @@ import type { PartnerPlacement } from '~/utils/analytics' type PartnersSponsorsContentProps = { analyticsPlacement: PartnerPlacement + previousLinkAlign?: 'center' | 'end' } type PartnersSponsorsSectionProps = { @@ -45,6 +46,7 @@ function OssSponsorsBand() { export function PartnersSponsorsContent({ analyticsPlacement, + previousLinkAlign = 'center', }: PartnersSponsorsContentProps) { return (
@@ -60,7 +62,9 @@ export function PartnersSponsorsContent({ analyticsPlacement={analyticsPlacement} trailingBand={} /> -
+
-
+ + + + + + + +
+ + View Maintainers & Contributors + +
-
+ ) } diff --git a/src/components/home/HomeSectionFallbacks.tsx b/src/components/home/HomeSectionFallbacks.tsx index ef5913500..31b67ec70 100644 --- a/src/components/home/HomeSectionFallbacks.tsx +++ b/src/components/home/HomeSectionFallbacks.tsx @@ -52,24 +52,6 @@ export function HomeSocialProofFallback() { ) } -export function HomeCommunityFallback() { - return ( -
-
- - -
- -
-
-
- -
-
-
- ) -} - export function HomeNewsletterFallback() { return (
diff --git a/src/components/home/HomeSocialProofSection.tsx b/src/components/home/HomeSocialProofSection.tsx index 47e9370d2..59cd2d76d 100644 --- a/src/components/home/HomeSocialProofSection.tsx +++ b/src/components/home/HomeSocialProofSection.tsx @@ -78,7 +78,10 @@ function SocialProofSkeleton() { function HomeSocialProofContent({ recentPosts }: HomeSocialProofSectionProps) { return (
- + {recentPosts.length > 0 && (
@@ -98,7 +101,7 @@ function HomeSocialProofContent({ recentPosts }: HomeSocialProofSectionProps) { ))}
-
+
- ))} -
- - {/* Filter dropdown trigger */} -
- - - {/* Dropdown menu */} - {isOpen && ( -
-
-
- - Filter & Sort Options - - {hasFilters && ( - - )} -
- - {/* Group By */} -
- - -
- - {/* Sort By */} -
- - -
- - {/* Library filter */} -
- -
- {availableLibraries.map((library) => { - const isSelected = - selectedLibraries?.includes(library.id) || false - - const bgStyle = library.bgStyle ?? 'bg-category-tooling' - - return ( - - ) - })} -
-
-
-
- )} -
- - {/* Current filter chips */} -
- {selectedLibraries?.map((libraryId) => { - const library = availableLibraries.find( - (lib) => lib.id === libraryId, - ) - const bgStyle = library?.bgStyle ?? 'bg-category-tooling' - - return ( - - {library?.name || libraryId} - - - ) - })} -
-
-
- ) -} - function MaintainerGrid({ maintainers, - viewMode, title, - stats, }: { maintainers: Maintainer[] - viewMode: 'compact' | 'full' | 'row' - title?: string - stats?: Array<{ - username: string - totalCommits: number - totalPullRequests: number - totalIssues: number - totalReviews: number - }> + title: string }) { return ( -
- {title &&

{title}

} -
*>*]:max-w-none @[28rem]:grid-cols-[repeat(auto-fit,minmax(180px,1fr))] @[43rem]:grid-cols-3' - }`} - > +
+ {title &&

{title}

} +
{maintainers.map((maintainer, index) => (
- {viewMode === 'compact' ? ( - - ) : viewMode === 'row' ? ( - s.username === maintainer.github)} - /> - ) : ( - - )} +
))}
@@ -385,53 +62,28 @@ function MaintainerGrid({ } function RouteComponent() { - const initialLocation = Route.useLoaderData() const search = Route.useSearch() const navigate = Route.useNavigate() - const updateFilters = (updates: { - libraries?: Library['id'][] | undefined - viewMode?: 'compact' | 'full' | 'row' - groupBy?: 'none' | 'core' | 'library' | 'role' - sortBy?: 'none' | 'name' | 'role' | 'contributions' - }) => { + const updateFilters = (updates: Partial) => { navigate({ - search: { - ...search, - ...updates, - }, + search: (previous) => ({ ...previous, ...updates }), replace: true, }) } - // Filter maintainers based on selected criteria const filteredMaintainers = React.useMemo(() => { - let filtered = [...allMaintainers] - - // Filter by libraries - if (search.libraries && search.libraries.length > 0) { - const selectedLibraries = search.libraries - filtered = filtered.filter((maintainer) => { - const maintainerLibraries = getPersonsMaintainerOf(maintainer) - return ( - maintainerLibraries.some((lib) => - selectedLibraries.includes(lib.id as Library['id']), - ) || - maintainer.creatorOf?.some((lib) => - selectedLibraries.includes(lib), - ) || - maintainer.maintainerOf?.some((lib) => - selectedLibraries.includes(lib), - ) || - maintainer.contributorOf?.some((lib) => - selectedLibraries.includes(lib), - ) || - maintainer.consultantOf?.some((lib) => - selectedLibraries.includes(lib), - ) - ) - }) - } + const filtered = getMaintainersForLibraries(search.libraries).filter( + (maintainer) => + (!search.frameworks?.length || + search.frameworks.some((framework) => + maintainer.frameworkExpertise?.includes(framework), + )) && + (!search.specialties?.length || + maintainer.specialties?.some((specialty) => + search.specialties?.includes(specialty.toLowerCase()), + )), + ) // Sort maintainers filtered.sort((a, b) => { @@ -492,7 +144,7 @@ function RouteComponent() { }) return filtered - }, [search.libraries, search.sortBy]) + }, [search.libraries, search.frameworks, search.specialties, search.sortBy]) // Group maintainers based on groupBy setting const groupedMaintainers = React.useMemo(() => { @@ -654,7 +306,9 @@ function RouteComponent() { const hasResults = filteredMaintainers.length > 0 const hasFilters = - (search.libraries && search.libraries.length > 0) || + !!search.libraries?.length || + !!search.frameworks?.length || + !!search.specialties?.length || search.groupBy !== 'none' || search.sortBy !== 'none' @@ -674,8 +328,8 @@ function RouteComponent() { `}
-
-
+
+

Maintainers & Contributors

Meet the amazing developers who make TanStack possible through @@ -683,22 +337,14 @@ function RouteComponent() {

- updateFilters({ libraries })} - onViewModeChange={(viewMode) => updateFilters({ viewMode })} - onGroupByChange={(groupBy) => updateFilters({ groupBy })} - onSortByChange={(sortBy) => updateFilters({ sortBy })} - onClearAll={() => navigate({ search: {}, replace: true })} - /> - - navigate({ search: {}, replace: true }) + : undefined + } /> {hasResults ? ( @@ -707,15 +353,6 @@ function RouteComponent() {

Showing {filteredMaintainers.length} maintainer {filteredMaintainers.length === 1 ? '' : 's'} - {search.libraries && search.libraries.length > 0 && ( - - {' '} - for{' '} - - {search.libraries.join(', ')} - - - )}

)} @@ -723,7 +360,6 @@ function RouteComponent() { ))}