Skip to content

Commit 1e79903

Browse files
committed
fix: better perf
1 parent 302bd1c commit 1e79903

File tree

3 files changed

+24
-109
lines changed

3 files changed

+24
-109
lines changed
Lines changed: 23 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,32 @@
1-
import React from 'react'
2-
import { Pack, hierarchy } from '@visx/hierarchy'
3-
import { ParentSize } from './ParentSize'
4-
5-
// Generate realistic placeholder sponsor data with curved distribution
6-
// Simulates real sponsor ecosystems: few large sponsors, many small ones
7-
const generatePlaceholderSponsors = () => {
8-
const sponsors = []
9-
const totalSponsors = 150 // More realistic number
10-
11-
for (let i = 0; i < totalSponsors; i++) {
12-
const normalizedIndex = i / (totalSponsors - 1)
13-
const size = Math.pow(1 - normalizedIndex, 10)
14-
15-
const jitter = (Math.random() - 0.5) * 0.1
16-
const finalSize = Math.max(0.01, Math.min(1.0, size + jitter))
17-
18-
sponsors.push({
19-
login: `placeholder-${i + 1}`,
20-
name: '',
21-
imageUrl: '',
22-
linkUrl: '',
23-
size: finalSize,
24-
})
1+
function createBubbleStyle(index: number) {
2+
const left = ((index * 37) % 100) / 100
3+
const top = ((index * 61) % 100) / 100
4+
const size = 20 + ((index * 17) % 90)
5+
const opacity = 0.14 + ((index * 13) % 12) / 100
6+
7+
return {
8+
left: `${8 + left * 84}%`,
9+
top: `${6 + top * 88}%`,
10+
width: `${size}px`,
11+
height: `${size}px`,
12+
opacity,
2513
}
26-
27-
// Sort by size descending (largest first) like real sponsor data
28-
return sponsors.sort((a, b) => b.size - a.size)
2914
}
3015

3116
export default function PlaceholderSponsorPack() {
32-
const sponsors = React.useMemo(() => generatePlaceholderSponsors(), [])
33-
34-
const pack = React.useMemo(
35-
() => ({
36-
children: sponsors,
37-
name: 'root',
38-
radius: 0,
39-
distance: 0,
40-
}),
41-
[sponsors],
42-
)
43-
44-
const root = React.useMemo(
45-
() =>
46-
hierarchy(pack)
47-
.sum((d) => 0.0007 + ((d as { size?: number }).size || 0))
48-
.sort(
49-
(a, b) =>
50-
((b.data as { size?: number })?.size ?? 0) -
51-
((a.data as { size?: number })?.size ?? 0),
52-
),
53-
[pack],
54-
)
55-
5617
return (
57-
<ParentSize>
58-
{({ width = 800 }) => {
59-
return width < 10 ? null : (
18+
<div className="relative w-full h-full overflow-hidden rounded-[2rem] bg-gradient-to-br from-gray-100/80 via-white to-gray-50 dark:from-gray-900 dark:via-gray-950 dark:to-gray-900">
19+
{Array.from({ length: 48 }).map((_, index) => {
20+
const style = createBubbleStyle(index)
21+
22+
return (
6023
<div
61-
style={{
62-
width,
63-
height: width,
64-
position: 'relative',
65-
}}
66-
>
67-
<style
68-
dangerouslySetInnerHTML={{
69-
__html: `
70-
.placeholder-bubble {
71-
background: rgba(156, 163, 175, 0.3);
72-
transform: translate(-50%, -50%);
73-
}
74-
`,
75-
}}
76-
/>
77-
<Pack root={root} size={[width, width]} padding={width * 0.005}>
78-
{(packData) => {
79-
const circles = packData.descendants().slice(1) // skip first layer
80-
return (
81-
<div>
82-
{[...circles].reverse().map((circle, i) => {
83-
return (
84-
<div
85-
key={`placeholder-circle-${i}`}
86-
className="placeholder-bubble absolute rounded-full border border-gray-300/20 dark:border-gray-600/20"
87-
style={{
88-
left: circle.x,
89-
top: circle.y,
90-
width: circle.r * 2,
91-
height: circle.r * 2,
92-
}}
93-
/>
94-
)
95-
})}
96-
</div>
97-
)
98-
}}
99-
</Pack>
100-
</div>
24+
key={index}
25+
className="absolute -translate-x-1/2 -translate-y-1/2 rounded-full border border-gray-300/30 bg-gray-300/40 dark:border-gray-700/40 dark:bg-gray-700/30"
26+
style={style}
27+
/>
10128
)
102-
}}
103-
</ParentSize>
29+
})}
30+
</div>
10431
)
10532
}

src/routes/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ function Index() {
9898
2xl:[--ship-x:90px] 2xl:[--ship-y:3rem]"
9999
>
100100
<ClientOnly>
101-
{/* Ship behind splash */}
102101
<div className="absolute left-1/3 bottom-[25%] z-0 animate-ship-peek">
103102
<NetlifyImage
104103
src="/images/ship.png"
@@ -108,7 +107,6 @@ function Index() {
108107
className="w-16 xl:w-20"
109108
/>
110109
</div>
111-
{/* Invisible clickable ship in front */}
112110
<Link
113111
to="/explore"
114112
className="absolute left-1/3 bottom-[25%] z-20 animate-ship-peek-clickable"

vite.config.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export default defineConfig({
5959
return id.includes('postgres')
6060
},
6161
output: {
62+
onlyExplicitManualChunks: true,
6263
manualChunks: (id) => {
6364
// Vendor chunk splitting for better caching
6465
if (id.includes('node_modules')) {
@@ -70,17 +71,6 @@ export default defineConfig({
7071
) {
7172
return 'search'
7273
}
73-
// Charting deps (only loaded on stats/admin pages)
74-
if (
75-
id.includes('@observablehq/plot') ||
76-
(id.includes('d3') && !id.includes('d3-'))
77-
) {
78-
return 'd3-charts'
79-
}
80-
// Visualization deps
81-
if (id.includes('@visx/')) {
82-
return 'visx'
83-
}
8474
// Lucide icons (tree-shaken but still significant)
8575
if (id.includes('lucide-react')) {
8676
return 'icons'

0 commit comments

Comments
 (0)